From 63d52b0d8937fe4608e843ac52714fd2b0b794aa Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:07:32 +0100 Subject: [PATCH 01/12] Fixing git dependency issues with weekly build Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/weekly-preview.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/weekly-preview.yml b/.github/workflows/weekly-preview.yml index 7b5dd442aa..81cfa2c2c0 100644 --- a/.github/workflows/weekly-preview.yml +++ b/.github/workflows/weekly-preview.yml @@ -9,6 +9,7 @@ on: pull_request: branches: - dev + workflow_dispatch: env: PYTHON_VER: '3.10' @@ -70,6 +71,8 @@ jobs: - name: Build distribution run: | export HEAD_COMMIT_ID=$(git rev-parse HEAD) + # remove git clone dependencies, see https://github.com/Project-MONAI/MONAI/issues/5882 + sed -i /git+/d pyproject.toml sed -i 's/name\ =\ "monai"$/name\ =\ "monai-weekly"/g' pyproject.toml echo "__commit_id__ = \"$HEAD_COMMIT_ID\"" >> monai/__init__.py git diff pyproject.toml monai/__init__.py @@ -90,6 +93,13 @@ jobs: pip install dist/*.whl pip list (cd "$(mktemp -d)" && python -c 'import monai; print(monai.__version__)') + - name: Publish to Test PyPI + if: github.event_name != 'schedule' # only test publish on PR + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + user: __token__ + password: ${{ secrets.TEST_PYPI_TOKEN }} - name: Publish to PyPI if: github.event_name == 'schedule' # only publish on cron run uses: pypa/gh-action-pypi-publish@release/v1 From 388121f2d097003654bfeb533b3ce5bb61f54306 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:22:06 +0100 Subject: [PATCH 02/12] Update to test with twine Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/weekly-preview.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/weekly-preview.yml b/.github/workflows/weekly-preview.yml index 81cfa2c2c0..9eccbca0cc 100644 --- a/.github/workflows/weekly-preview.yml +++ b/.github/workflows/weekly-preview.yml @@ -67,7 +67,7 @@ jobs: cache: 'pip' - name: Install tools run: | - python -m pip install -U pip build + python -m pip install -U pip build twine - name: Build distribution run: | export HEAD_COMMIT_ID=$(git rev-parse HEAD) @@ -94,14 +94,15 @@ jobs: pip list (cd "$(mktemp -d)" && python -c 'import monai; print(monai.__version__)') - name: Publish to Test PyPI - if: github.event_name != 'schedule' # only test publish on PR - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ - user: __token__ - password: ${{ secrets.TEST_PYPI_TOKEN }} + if: github.event_name == 'pull_request' # only test publish on PR + run: | + twine upload -r testpypi dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} + TWINE_NON_INTERACTIVE: true - name: Publish to PyPI - if: github.event_name == 'schedule' # only publish on cron run + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' # only publish on cron or manual run uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ From 5cefaa0f0a3fff67e9e83d57bf122ea9ba07a1a2 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:46:29 +0100 Subject: [PATCH 03/12] Disable testing for now Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/weekly-preview.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/weekly-preview.yml b/.github/workflows/weekly-preview.yml index 9eccbca0cc..dde2acdd9c 100644 --- a/.github/workflows/weekly-preview.yml +++ b/.github/workflows/weekly-preview.yml @@ -93,14 +93,15 @@ jobs: pip install dist/*.whl pip list (cd "$(mktemp -d)" && python -c 'import monai; print(monai.__version__)') - - name: Publish to Test PyPI - if: github.event_name == 'pull_request' # only test publish on PR - run: | - twine upload -r testpypi dist/* - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} - TWINE_NON_INTERACTIVE: true + # TODO: re-enable once the test token works, currently this is getting 403 Forbidden + # - name: Publish to Test PyPI + # if: github.event_name == 'pull_request' # only test publish on PR + # run: | + # twine upload -r testpypi dist/* + # env: + # TWINE_USERNAME: __token__ + # TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} + # TWINE_NON_INTERACTIVE: true - name: Publish to PyPI if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' # only publish on cron or manual run uses: pypa/gh-action-pypi-publish@release/v1 From 0a94d81d11b8bf8c49c062df39a27f56fc77759b Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 1 Sep 2026 14:00:33 +0100 Subject: [PATCH 04/12] Remove manual dispatch Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/weekly-preview.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/weekly-preview.yml b/.github/workflows/weekly-preview.yml index dde2acdd9c..e11af9a3f1 100644 --- a/.github/workflows/weekly-preview.yml +++ b/.github/workflows/weekly-preview.yml @@ -9,7 +9,6 @@ on: pull_request: branches: - dev - workflow_dispatch: env: PYTHON_VER: '3.10' @@ -95,7 +94,7 @@ jobs: (cd "$(mktemp -d)" && python -c 'import monai; print(monai.__version__)') # TODO: re-enable once the test token works, currently this is getting 403 Forbidden # - name: Publish to Test PyPI - # if: github.event_name == 'pull_request' # only test publish on PR + # if: github.event_name == 'pull_request' && github.repository == 'Project-MONAI/MONAI' # only test publish on PR # run: | # twine upload -r testpypi dist/* # env: @@ -103,7 +102,7 @@ jobs: # TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} # TWINE_NON_INTERACTIVE: true - name: Publish to PyPI - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' # only publish on cron or manual run + if: github.event_name == 'schedule' # only publish on cron run uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ From db77bc220c4744e75a045154168db9025fcc5089 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 1 Sep 2026 16:27:57 +0100 Subject: [PATCH 05/12] Re-enable pypi test with the new token Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/weekly-preview.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/weekly-preview.yml b/.github/workflows/weekly-preview.yml index e11af9a3f1..f2dde4c717 100644 --- a/.github/workflows/weekly-preview.yml +++ b/.github/workflows/weekly-preview.yml @@ -92,15 +92,14 @@ jobs: pip install dist/*.whl pip list (cd "$(mktemp -d)" && python -c 'import monai; print(monai.__version__)') - # TODO: re-enable once the test token works, currently this is getting 403 Forbidden - # - name: Publish to Test PyPI - # if: github.event_name == 'pull_request' && github.repository == 'Project-MONAI/MONAI' # only test publish on PR - # run: | - # twine upload -r testpypi dist/* - # env: - # TWINE_USERNAME: __token__ - # TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} - # TWINE_NON_INTERACTIVE: true + - name: Publish to Test PyPI + if: github.event_name == 'pull_request' && github.repository == 'Project-MONAI/MONAI' # only test publish on PR + run: | + twine upload -r testpypi dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} + TWINE_NON_INTERACTIVE: true - name: Publish to PyPI if: github.event_name == 'schedule' # only publish on cron run uses: pypa/gh-action-pypi-publish@release/v1 From a614f4755bf827bd0e33b2604d602d5baf87a740 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 1 Sep 2026 16:41:19 +0100 Subject: [PATCH 06/12] Adding verbose Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/weekly-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/weekly-preview.yml b/.github/workflows/weekly-preview.yml index f2dde4c717..71b4cabd9e 100644 --- a/.github/workflows/weekly-preview.yml +++ b/.github/workflows/weekly-preview.yml @@ -95,7 +95,7 @@ jobs: - name: Publish to Test PyPI if: github.event_name == 'pull_request' && github.repository == 'Project-MONAI/MONAI' # only test publish on PR run: | - twine upload -r testpypi dist/* + twine upload --verbose -r testpypi dist/* env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} From 44b137f1a0106c446023837c5030a0c0950cb4fa Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 1 Sep 2026 16:51:58 +0100 Subject: [PATCH 07/12] Password test Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/weekly-preview.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/weekly-preview.yml b/.github/workflows/weekly-preview.yml index 71b4cabd9e..c4c8bcf20a 100644 --- a/.github/workflows/weekly-preview.yml +++ b/.github/workflows/weekly-preview.yml @@ -95,10 +95,11 @@ jobs: - name: Publish to Test PyPI if: github.event_name == 'pull_request' && github.repository == 'Project-MONAI/MONAI' # only test publish on PR run: | + wc "$TWINE_PASSWORD" twine upload --verbose -r testpypi dist/* env: TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} + TWINE_PASSWORD: foobar TWINE_NON_INTERACTIVE: true - name: Publish to PyPI if: github.event_name == 'schedule' # only publish on cron run From c6d504129ff8b659f0a6a24c1c64f756ca8f7551 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 1 Sep 2026 16:55:46 +0100 Subject: [PATCH 08/12] Try again Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/weekly-preview.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/weekly-preview.yml b/.github/workflows/weekly-preview.yml index c4c8bcf20a..cbc70380b4 100644 --- a/.github/workflows/weekly-preview.yml +++ b/.github/workflows/weekly-preview.yml @@ -95,11 +95,11 @@ jobs: - name: Publish to Test PyPI if: github.event_name == 'pull_request' && github.repository == 'Project-MONAI/MONAI' # only test publish on PR run: | - wc "$TWINE_PASSWORD" + echo "$TWINE_PASSWORD" | wc twine upload --verbose -r testpypi dist/* env: TWINE_USERNAME: __token__ - TWINE_PASSWORD: foobar + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} TWINE_NON_INTERACTIVE: true - name: Publish to PyPI if: github.event_name == 'schedule' # only publish on cron run From 6ab14569f96d873df1721ad914b391681956a6df Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Wed, 2 Sep 2026 14:48:55 +0100 Subject: [PATCH 09/12] Remove PR test Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/weekly-preview.yml | 7 +++++-- pyproject.toml | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/weekly-preview.yml b/.github/workflows/weekly-preview.yml index cbc70380b4..951441b7eb 100644 --- a/.github/workflows/weekly-preview.yml +++ b/.github/workflows/weekly-preview.yml @@ -89,13 +89,16 @@ jobs: ls -lh dist - name: Test Installation run: | + twine check --strict dist/* pip install dist/*.whl pip list (cd "$(mktemp -d)" && python -c 'import monai; print(monai.__version__)') - name: Publish to Test PyPI - if: github.event_name == 'pull_request' && github.repository == 'Project-MONAI/MONAI' # only test publish on PR + if: | # run this test only on a PR coming from a branch in this repo + github.event_name == 'pull_request' && + github.repository == 'Project-MONAI/MONAI' && + github.event.pull_request.head.repo.full_name == github.repository run: | - echo "$TWINE_PASSWORD" | wc twine upload --verbose -r testpypi dist/* env: TWINE_USERNAME: __token__ diff --git a/pyproject.toml b/pyproject.toml index fcd57adac5..5b2e70f2f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -125,6 +125,7 @@ jsonschema = ["jsonschema"] lmdb = ["lmdb"] lpips = ["lpips==0.1.4"] matplotlib = ["matplotlib>=3.6.3"] +# per #5882 this requirement must be on one line to get removed by sed in weekly-preview.yml metrics_reloaded = ["MetricsReloaded @ git+https://github.com/Project-MONAI/MetricsReloaded@monai-support"] mlflow = ["mlflow>=3.15.2"] nibabel = ["nibabel"] @@ -146,6 +147,7 @@ pynrrd = ["pynrrd"] pynvml = ["nvidia-ml-py"] pyyaml = ["pyyaml"] requests = ["requests"] +# per #5882 this requirement must be on one line to get removed by sed in weekly-preview.yml segment_anything = ["segment_anything @ git+https://github.com/facebookresearch/segment-anything.git@6fdee8f2727f4506cfbbe553e23b895e27956588"] scipy = ["scipy>=1.12.0"] skimage = ["scikit-image>=0.19.0"] From 41b049a51a01e9b6d1324d201f12786270c54e48 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Wed, 2 Sep 2026 14:49:18 +0100 Subject: [PATCH 10/12] Remove PR test Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/weekly-preview.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/weekly-preview.yml b/.github/workflows/weekly-preview.yml index 951441b7eb..8c32e9f38a 100644 --- a/.github/workflows/weekly-preview.yml +++ b/.github/workflows/weekly-preview.yml @@ -9,6 +9,7 @@ on: pull_request: branches: - dev + env: PYTHON_VER: '3.10' @@ -93,17 +94,6 @@ jobs: pip install dist/*.whl pip list (cd "$(mktemp -d)" && python -c 'import monai; print(monai.__version__)') - - name: Publish to Test PyPI - if: | # run this test only on a PR coming from a branch in this repo - github.event_name == 'pull_request' && - github.repository == 'Project-MONAI/MONAI' && - github.event.pull_request.head.repo.full_name == github.repository - run: | - twine upload --verbose -r testpypi dist/* - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} - TWINE_NON_INTERACTIVE: true - name: Publish to PyPI if: github.event_name == 'schedule' # only publish on cron run uses: pypa/gh-action-pypi-publish@release/v1 From bd7b646020ac7ae62cc0e4d373cea13a036a42bd Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Wed, 2 Sep 2026 14:52:51 +0100 Subject: [PATCH 11/12] Fix Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/weekly-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/weekly-preview.yml b/.github/workflows/weekly-preview.yml index 8c32e9f38a..09ee4fd3ee 100644 --- a/.github/workflows/weekly-preview.yml +++ b/.github/workflows/weekly-preview.yml @@ -9,7 +9,7 @@ on: pull_request: branches: - dev - + env: PYTHON_VER: '3.10' From 666a9a06440cc4f88049a1e893d563a7f33d344e Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Thu, 3 Sep 2026 10:09:51 +0100 Subject: [PATCH 12/12] Adding profile fix from previous PR Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- monai/utils/profiling.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monai/utils/profiling.py b/monai/utils/profiling.py index e325953298..d26da6e8ce 100644 --- a/monai/utils/profiling.py +++ b/monai/utils/profiling.py @@ -57,7 +57,7 @@ def torch_profiler_full(func): @wraps(func) def wrapper(*args, **kwargs): - with torch.autograd.profiler.profile() as prof: + with torch.autograd.profiler.profile(use_device="cuda") as prof: result = func(*args, **kwargs) print(prof, flush=True) @@ -76,7 +76,7 @@ def torch_profiler_time_cpu_gpu(func): @wraps(func) def wrapper(*args, **kwargs): - with torch.autograd.profiler.profile() as prof: + with torch.autograd.profiler.profile(use_device="cuda") as prof: result = func(*args, **kwargs) cpu_time = prof.self_cpu_time_total