From 572c9a835bc0992167d14f3ee474df3268f9cce1 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Mon, 4 Oct 2021 14:11:59 +0100 Subject: [PATCH 1/8] adds integration tests Signed-off-by: Wenqi Li --- .github/workflows/cron-mmar.yml | 28 +++++++++++++++++++++++++ tests/ngc_mmar_loading.py | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 .github/workflows/cron-mmar.yml create mode 100644 tests/ngc_mmar_loading.py diff --git a/.github/workflows/cron-mmar.yml b/.github/workflows/cron-mmar.yml new file mode 100644 index 0000000000..c65df1e927 --- /dev/null +++ b/.github/workflows/cron-mmar.yml @@ -0,0 +1,28 @@ +name: cron-mmar + +on: + schedule: + - cron: "0 2 * * *" # at 02:00 UTC + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + cron-load: + if: github.repository == 'Project-MONAI/MONAI' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + python -m pip install -r requirements-dev.txt + - name: Loading MMARs + run: | + # clean up temporary files + $(pwd)/runtests.sh --clean + # run tests + python -m tests.ngc_mmar_loading diff --git a/tests/ngc_mmar_loading.py b/tests/ngc_mmar_loading.py new file mode 100644 index 0000000000..894ddf1529 --- /dev/null +++ b/tests/ngc_mmar_loading.py @@ -0,0 +1,36 @@ +# Copyright 2020 - 2021 MONAI Consortium +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import glob +import os +import unittest + +from parameterized import parameterized + +from monai.apps.mmars import MODEL_DESC, load_from_mmar +from monai.config import print_debug_info + + +class TestAllDownloadingMMAR(unittest.TestCase): + def setUp(self): + print_debug_info() + self.test_dir = "./" + + @parameterized.expand((item,) for item in MODEL_DESC) + def test_loading_mmar(self, item): + pretrained_model = load_from_mmar(item=item, mmar_dir="./", map_location="cpu") + + def tearDown(self): + print(os.listdir(self.test_dir)) + + +if __name__ == "__main__": + unittest.main() From ffee575c35016ec184282e95bd0b2655ac9472f5 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Mon, 4 Oct 2021 14:18:54 +0100 Subject: [PATCH 2/8] temp tests Signed-off-by: Wenqi Li --- .github/workflows/cron-mmar.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cron-mmar.yml b/.github/workflows/cron-mmar.yml index c65df1e927..e8b10a1a8c 100644 --- a/.github/workflows/cron-mmar.yml +++ b/.github/workflows/cron-mmar.yml @@ -5,6 +5,9 @@ on: - cron: "0 2 * * *" # at 02:00 UTC # Allows you to run this workflow manually from the Actions tab workflow_dispatch: + push: + branches: + - tutorial-385-test-mmar jobs: cron-load: From 5449b84f224fb87b39447f11b03db9e40adb8781 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Mon, 4 Oct 2021 14:20:47 +0100 Subject: [PATCH 3/8] cache pip Signed-off-by: Wenqi Li --- .github/workflows/cron-mmar.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/cron-mmar.yml b/.github/workflows/cron-mmar.yml index e8b10a1a8c..b153b2eb43 100644 --- a/.github/workflows/cron-mmar.yml +++ b/.github/workflows/cron-mmar.yml @@ -19,6 +19,15 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.8 + - name: cache weekly timestamp + id: pip-cache + run: echo "::set-output name=datew::$(date '+%Y-%V')" + - name: cache for pip + uses: actions/cache@v2 + id: cache + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }} - name: Install dependencies run: | python -m pip install --upgrade pip wheel From daa0ffa9e942cf7bf2a6388de6a1d323def38b76 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Mon, 4 Oct 2021 14:21:39 +0100 Subject: [PATCH 4/8] fixes conc Signed-off-by: Wenqi Li --- .github/workflows/cron-mmar.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/cron-mmar.yml b/.github/workflows/cron-mmar.yml index b153b2eb43..fe07182159 100644 --- a/.github/workflows/cron-mmar.yml +++ b/.github/workflows/cron-mmar.yml @@ -9,6 +9,11 @@ on: branches: - tutorial-385-test-mmar +concurrency: + # automatically cancel the previously triggered workflows when there's a newer version + group: mmar-tests-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: cron-load: if: github.repository == 'Project-MONAI/MONAI' From b3618240b70ec2b6f76916501be5439f347c2ee5 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Mon, 4 Oct 2021 14:24:41 +0100 Subject: [PATCH 5/8] Revert "temp tests" This reverts commit 5a931c6ce4b237f4269a7ca1317a5715845f1f20. Signed-off-by: Wenqi Li --- .github/workflows/cron-mmar.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/cron-mmar.yml b/.github/workflows/cron-mmar.yml index fe07182159..735c23117c 100644 --- a/.github/workflows/cron-mmar.yml +++ b/.github/workflows/cron-mmar.yml @@ -5,9 +5,6 @@ on: - cron: "0 2 * * *" # at 02:00 UTC # Allows you to run this workflow manually from the Actions tab workflow_dispatch: - push: - branches: - - tutorial-385-test-mmar concurrency: # automatically cancel the previously triggered workflows when there's a newer version From fa4de080721f997d1d7cff2788aa9cdbfc90eb82 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Mon, 4 Oct 2021 14:28:33 +0100 Subject: [PATCH 6/8] print outcome Signed-off-by: Wenqi Li --- tests/ngc_mmar_loading.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ngc_mmar_loading.py b/tests/ngc_mmar_loading.py index 894ddf1529..65d916dc3b 100644 --- a/tests/ngc_mmar_loading.py +++ b/tests/ngc_mmar_loading.py @@ -27,6 +27,7 @@ def setUp(self): @parameterized.expand((item,) for item in MODEL_DESC) def test_loading_mmar(self, item): pretrained_model = load_from_mmar(item=item, mmar_dir="./", map_location="cpu") + print(pretrained_model) def tearDown(self): print(os.listdir(self.test_dir)) From 82c77a111b29071f126a00382e7ba57eaab968db Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Mon, 4 Oct 2021 14:38:47 +0100 Subject: [PATCH 7/8] fixes typo Signed-off-by: Wenqi Li --- tests/ngc_mmar_loading.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ngc_mmar_loading.py b/tests/ngc_mmar_loading.py index 65d916dc3b..3bf078b3ce 100644 --- a/tests/ngc_mmar_loading.py +++ b/tests/ngc_mmar_loading.py @@ -9,7 +9,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import glob import os import unittest From 4889f65a87c89a59caac170474851eabe2655ae0 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Mon, 4 Oct 2021 18:06:20 +0100 Subject: [PATCH 8/8] update based on comments Signed-off-by: Wenqi Li --- tests/ngc_mmar_loading.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/ngc_mmar_loading.py b/tests/ngc_mmar_loading.py index 3bf078b3ce..8aa3859d87 100644 --- a/tests/ngc_mmar_loading.py +++ b/tests/ngc_mmar_loading.py @@ -12,6 +12,7 @@ import os import unittest +import torch from parameterized import parameterized from monai.apps.mmars import MODEL_DESC, load_from_mmar @@ -26,7 +27,7 @@ def setUp(self): @parameterized.expand((item,) for item in MODEL_DESC) def test_loading_mmar(self, item): pretrained_model = load_from_mmar(item=item, mmar_dir="./", map_location="cpu") - print(pretrained_model) + self.assertTrue(isinstance(pretrained_model, torch.nn.Modules)) def tearDown(self): print(os.listdir(self.test_dir))