From 0a50169a600f32febfb66b1565b43e9cea0451c3 Mon Sep 17 00:00:00 2001 From: mart-r Date: Tue, 27 Aug 2024 12:41:57 +0100 Subject: [PATCH 1/4] CU-8695hghww: Add bash script to run backwards compatibility --- .../model_compatibility/run_regression.sh | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/resources/model_compatibility/run_regression.sh diff --git a/tests/resources/model_compatibility/run_regression.sh b/tests/resources/model_compatibility/run_regression.sh new file mode 100644 index 000000000..906b71fa8 --- /dev/null +++ b/tests/resources/model_compatibility/run_regression.sh @@ -0,0 +1,51 @@ +# CONSTANTs/ shouldn't change +REGRESSION_MODULE="medcat.utils.regression.regression_checker" +REGRESSION_OPTIONS="--strictness STRICTEST --require-fully-correct" + +# CHANGABLES +# target models +DL_LINK="https://cogstack-medcat-example-models.s3.eu-west-2.amazonaws.com/medcat-example-models/all_fake_medcat_models.zip" +ZIP_FILE_NAME="all_fake_medcat_models.zip" +# target regression set +REGRESSION_TEST_SET="../../../tests/resources/regression/testing/test_model_regresssion.yml" +# folder to house models under test +MODEL_FOLDER="fake_models" + +# START WORK + +echo "Downloading models" +wget $DL_LINK +# Create folder if it doesn't exit +if [ ! -d "$MODEL_FOLDER" ]; then + mkdir "$MODEL_FOLDER" + CREATED=1 +else + # mark to NOT remove if folder already existed + CREATED=0 +fi +echo "Uncompressing files" +unzip $ZIP_FILE_NAME -d $MODEL_FOLDER +echo "Cleaning up the overall zip" +rm $ZIP_FILE_NAME +for model_path in `ls $MODEL_FOLDER/*.zip`; do + if [ -f "$model_path" ]; then + echo "Processing $model_path" + python -m $REGRESSION_MODULE \ + "$model_path" \ + $REGRESSION_TEST_SET \ + $REGRESSION_OPTIONS + # this is a sanity check - needst to run after so that the folder has been created + grep "MedCAT Version" "${model_path%.*}/model_card.json" + # clean up here so we don't leave both the .zip'ed model + # and the folder so we don't fill the disk + echo "Cleaning up at: ${model_path%.*}" + rm -rf ${model_path%.*}* + else + echo "No files found matching the pattern: $file" + fi +done + +# Remove the folder if it was created by the script +if [ $CREATED -eq 1 ]; then + rm -r "$MODEL_FOLDER" +fi From 55e3534e9ededc5f7040e3fa999c18bce24d1096 Mon Sep 17 00:00:00 2001 From: mart-r Date: Tue, 27 Aug 2024 12:43:44 +0100 Subject: [PATCH 2/4] CU-8695hghww: Rename backwards compatibility running bash script --- .../{run_regression.sh => check_backwards_compatibility.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/resources/model_compatibility/{run_regression.sh => check_backwards_compatibility.sh} (100%) diff --git a/tests/resources/model_compatibility/run_regression.sh b/tests/resources/model_compatibility/check_backwards_compatibility.sh similarity index 100% rename from tests/resources/model_compatibility/run_regression.sh rename to tests/resources/model_compatibility/check_backwards_compatibility.sh From cbc40773beddacc8043982427ee7d0d4ae3e39db Mon Sep 17 00:00:00 2001 From: mart-r Date: Tue, 27 Aug 2024 12:46:00 +0100 Subject: [PATCH 3/4] CU-8695hghww: Add new step to workflow to run model backwards compatibility --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d446160c9..6398f9d02 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,8 @@ jobs: second_half_nl=$(echo "$all_files" | tail -n +$(($midpoint + 1))) timeout 25m python -m unittest ${first_half_nl[@]} timeout 25m python -m unittest ${second_half_nl[@]} - + - name: Model backwards compatibility + run: source tests/resources/model_compatibility/check_backwards_compatibility.sh - name: Get the latest release version id: get_latest_release uses: actions/github-script@v6 From 731693bbee8fb7c41aeed52c51da67aa889a0967 Mon Sep 17 00:00:00 2001 From: mart-r Date: Wed, 28 Aug 2024 12:06:20 +0100 Subject: [PATCH 4/4] CU-8695hghww: Fix model compatibility regression suite path --- .../model_compatibility/check_backwards_compatibility.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resources/model_compatibility/check_backwards_compatibility.sh b/tests/resources/model_compatibility/check_backwards_compatibility.sh index 906b71fa8..bdaa88072 100644 --- a/tests/resources/model_compatibility/check_backwards_compatibility.sh +++ b/tests/resources/model_compatibility/check_backwards_compatibility.sh @@ -7,7 +7,7 @@ REGRESSION_OPTIONS="--strictness STRICTEST --require-fully-correct" DL_LINK="https://cogstack-medcat-example-models.s3.eu-west-2.amazonaws.com/medcat-example-models/all_fake_medcat_models.zip" ZIP_FILE_NAME="all_fake_medcat_models.zip" # target regression set -REGRESSION_TEST_SET="../../../tests/resources/regression/testing/test_model_regresssion.yml" +REGRESSION_TEST_SET="tests/resources/regression/testing/test_model_regresssion.yml" # folder to house models under test MODEL_FOLDER="fake_models"