From 66496e58dd34337b9966d9db133b2e017b24407f Mon Sep 17 00:00:00 2001 From: Yiheng Wang Date: Fri, 1 Apr 2022 15:32:34 +0800 Subject: [PATCH 1/7] fix pil via specifying cpuonly version Signed-off-by: Yiheng Wang --- .github/workflows/conda.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index 28349a5de5..73098cd63d 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -47,7 +47,9 @@ jobs: run: | conda activate monai # this `cpuonly` and -c conda-forge is needed to reduce the paging file size on a github instance - conda install pytorch torchvision torchaudio cpuonly -c pytorch -c conda-forge + # force to install `cpuonly==2.0.0` is to fix the same issue as: + # https://github.com/pytorch/vision/issues/4240 + conda install pytorch torchvision torchaudio cpuonly==2.0.0 -c pytorch -c conda-forge conda deactivate - name: Test env(CPU ${{ runner.os }}) shell: bash -l {0} From eb52b39ac123f16da445f41fb24f90ce54ca1caa Mon Sep 17 00:00:00 2001 From: Yiheng Wang Date: Fri, 1 Apr 2022 15:34:44 +0800 Subject: [PATCH 2/7] add push branch to check Signed-off-by: Yiheng Wang --- .github/workflows/conda.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index 73098cd63d..6b8160d09e 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -5,6 +5,9 @@ on: - cron: "0 3 * * *" # at 03:00 UTC # Allows you to run this workflow manually from the Actions tab workflow_dispatch: + push: + branches: + - 4043-fix-windows-pil-issue concurrency: # automatically cancel the previously triggered workflows when there's a newer version From b83397be609b013d34a6321ddc3561af360136af Mon Sep 17 00:00:00 2001 From: Yiheng Wang Date: Fri, 1 Apr 2022 15:36:17 +0800 Subject: [PATCH 3/7] remove extra line Signed-off-by: Yiheng Wang --- .github/workflows/conda.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index 6b8160d09e..8e46ca3aae 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -16,7 +16,6 @@ concurrency: jobs: cron-conda: - if: github.repository == 'Project-MONAI/MONAI' strategy: fail-fast: false matrix: From d57d6ecd6c25c6b3f8ca2e0c52bbb17979645e7c Mon Sep 17 00:00:00 2001 From: Yiheng Wang Date: Fri, 1 Apr 2022 16:32:03 +0800 Subject: [PATCH 4/7] remove push branch for upstream Signed-off-by: Yiheng Wang --- .github/workflows/conda.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index 8e46ca3aae..73098cd63d 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -5,9 +5,6 @@ on: - cron: "0 3 * * *" # at 03:00 UTC # Allows you to run this workflow manually from the Actions tab workflow_dispatch: - push: - branches: - - 4043-fix-windows-pil-issue concurrency: # automatically cancel the previously triggered workflows when there's a newer version @@ -16,6 +13,7 @@ concurrency: jobs: cron-conda: + if: github.repository == 'Project-MONAI/MONAI' strategy: fail-fast: false matrix: From 4a055834160f313491b6b6028b39178bd4fcf639 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Fri, 1 Apr 2022 10:18:30 +0100 Subject: [PATCH 5/7] fixes #4046 Signed-off-by: Wenqi Li --- monai/handlers/utils.py | 5 ++++- tests/test_handler_metrics_saver.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/monai/handlers/utils.py b/monai/handlers/utils.py index 2912e214be..2ce52def57 100644 --- a/monai/handlers/utils.py +++ b/monai/handlers/utils.py @@ -121,7 +121,10 @@ class mean median max 5percentile 95percentile notnans with open(os.path.join(save_dir, f"{k}_raw.csv"), "w") as f: f.write(f"filename{deli}{deli.join(class_labels)}\n") for i, b in enumerate(v): - f.write(f"{images[i] if images is not None else str(i)}{deli}{deli.join([str(c) for c in b])}\n") + f.write( + f"{images[i] if images is not None else str(i)}{deli}" + f"{deli.join([f'{c:.4f}' if isinstance(c, (int, float)) else str(c) for c in b])}\n" + ) if summary_ops is not None: supported_ops = OrderedDict( diff --git a/tests/test_handler_metrics_saver.py b/tests/test_handler_metrics_saver.py index 56cfeb033b..27f107605b 100644 --- a/tests/test_handler_metrics_saver.py +++ b/tests/test_handler_metrics_saver.py @@ -66,7 +66,7 @@ def _save_metrics(engine): f_csv = csv.reader(f) for i, row in enumerate(f_csv): if i > 0: - self.assertEqual(row, [f"filepath{i}\t{float(i)}\t{float(i + 1)}\t{i + 0.5}"]) + self.assertEqual(row, [f"filepath{i}\t{float(i):.4f}\t{float(i + 1):.4f}\t{i + 0.5:.4f}"]) self.assertTrue(os.path.exists(os.path.join(tempdir, "metric3_summary.csv"))) # check the metric_summary.csv and content with open(os.path.join(tempdir, "metric4_summary.csv")) as f: From 8992d1f4b7e3b82a1675a54805789481aa362665 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Fri, 1 Apr 2022 10:52:13 +0100 Subject: [PATCH 6/7] fixes dist test Signed-off-by: Wenqi Li --- tests/test_handler_metrics_saver_dist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_handler_metrics_saver_dist.py b/tests/test_handler_metrics_saver_dist.py index 245ff492a5..a92fdf93d3 100644 --- a/tests/test_handler_metrics_saver_dist.py +++ b/tests/test_handler_metrics_saver_dist.py @@ -95,7 +95,7 @@ def _all_gather(engine): f_csv = csv.reader(f) for i, row in enumerate(f_csv): if i > 0: - expected = [f"{fnames[i-1]}\t{float(i)}\t{float(i + 1)}\t{i + 0.5}"] + expected = [f"{fnames[i-1]}\t{float(i):.4f}\t{float(i + 1):.4f}\t{i + 0.5:.4f}"] self.assertEqual(row, expected) self.assertTrue(os.path.exists(os.path.join(tempdir, "metric3_summary.csv"))) # check the metric_summary.csv and content From 7eaea32904e35ad2e770720b4947aab815f05f79 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Fri, 1 Apr 2022 11:23:35 +0100 Subject: [PATCH 7/7] fixes metrics reports Signed-off-by: Wenqi Li --- tests/test_write_metrics_reports.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_write_metrics_reports.py b/tests/test_write_metrics_reports.py index 101e1137b6..769803682a 100644 --- a/tests/test_write_metrics_reports.py +++ b/tests/test_write_metrics_reports.py @@ -45,7 +45,7 @@ def test_content(self): f_csv = csv.reader(f) for i, row in enumerate(f_csv): if i > 0: - self.assertEqual(row, [f"filepath{i}\t{float(i)}\t{float(i + 1)}\t{i + 0.5}"]) + self.assertEqual(row, [f"filepath{i}\t{float(i):.4f}\t{float(i + 1):.4f}\t{i + 0.5:.4f}"]) self.assertTrue(os.path.exists(os.path.join(tempdir, "metric3_summary.csv"))) # check the metric_summary.csv and content with open(os.path.join(tempdir, "metric3_summary.csv")) as f: