diff --git a/.gitignore b/.gitignore index 0fcc73c..1e5475d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ rasa-demo results.json report_main.json +.history \ No newline at end of file diff --git a/README.md b/README.md index 15f8d79..f5602fa 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ jobs: | `data_validate` | Validates domain and data files to check for possible mistakes | `true` | | `data_validate_args` | Additional arguments passed to the `rasa data validate` command | `none` | | `fine_tune` | Fine-tune an existing model with new training dataset | `false` | +| `fixed_model_name` | Name of the model file will be set to the given name | `none` | | `workspace` | The root directory containing your Rasa Open Source project | `${{ github.workspace }}` | | `train_type` | The types of training (available types: `core`/`nlu`/`all`) | `all` | | `train_args` | Additional arguments passed to the `rasa train` command | `none` | diff --git a/action.yml b/action.yml index 25a4257..ab30702 100644 --- a/action.yml +++ b/action.yml @@ -21,6 +21,10 @@ inputs: description: 'Fine-tune model' required: false default: 'false' + fixed_model_name: + description: 'Name to be given to the model file' + required: false + default: '' data_validate: description: 'Validates domain and data files to check for possible mistakes' required: true @@ -159,6 +163,11 @@ runs: echo MODEL_ARGS="--model /app/${{ inputs.model }}" >> $GITHUB_ENV fi + # Set a fixed model name + if [[ -n "${{ inputs.fixed_model_name }}" ]];then + echo FIXED_MODEL_ARGS="--fixed-model-name ${{ inputs.fixed_model_name }}" >> $GITHUB_ENV + fi + # Set cross validation if [[ "${{ inputs.cross_validation }}" == "true" ]];then echo CROSS_VALIDATION_ARGS="--cross-validation" >> $GITHUB_ENV @@ -240,7 +249,7 @@ runs: elif [[ "${{ inputs.rasa_train }}" == "true" ]]; then echo "Run the rasa train" echo "" - docker run ${{ env.DOCKER_ARGS }} ${{ env.RASA_IMAGE }} train ${{ env.TRAIN_TYPE }} ${{ env.DEFAULT_ARGS }} ${{ env.FINE_TUNE }} ${{ inputs.train_args }} + docker run ${{ env.DOCKER_ARGS }} ${{ env.RASA_IMAGE }} train ${{ env.TRAIN_TYPE }} ${{ env.DEFAULT_ARGS }} ${{ env.FIXED_MODEL_ARGS }} ${{ env.FINE_TUNE }} ${{ inputs.train_args }} else echo "::warning::rasa train is disabled. To turn on the rasa train set the rasa_train parameter to 'true'." fi @@ -302,6 +311,15 @@ runs: OUTPUT="${OUTPUT}\n$(python3 ${{ github.action_path }}/scripts/cross_validation_results.py)" fi + if [[ -f "${{ inputs.workspace }}/${{ inputs.result_directory }}/failed_test_stories.yml" ]]; then + TEST_FAILED=$(grep 'None of the test stories failed' README.md > /dev/null; echo $?) + if [[ $TEST_FAILED -eq 0 ]]; then + OUTPUT="${OUTPUT}\n```yml\n$(cat ${{ inputs.workspace }}/${{ inputs.result_directory }}/failed_test_stories.yml)```" + else + OUTPUT="${OUTPUT}\n\n#$(cat ${{ inputs.workspace }}/${{ inputs.result_directory }}/failed_test_stories.yml)" + fi + fi + OUTPUT="${OUTPUT//$'\n'/'\n'}" curl -X POST -s -H "Authorization: token ${{ inputs.github_token }}" -H "Accept: application/vnd.github.v3+json" \ diff --git a/scripts/cross_validation_results.py b/scripts/cross_validation_results.py index a2d713b..1f8eb40 100644 --- a/scripts/cross_validation_results.py +++ b/scripts/cross_validation_results.py @@ -51,6 +51,7 @@ def entity_table(): cols = ["support", "f1-score", "precision", "recall"] writer.headers = ["entity"] + cols + data.pop("accuracy", None) classes = list(data.keys()) classes.sort(key=lambda x: data[x]["support"], reverse=True)