Skip to content

Commit

Permalink
Merge branch 'Project-MONAI:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Saelra authored Aug 3, 2024
2 parents de41c64 + ae5a04d commit e30869d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ jobs:
key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }}
- name: Install dependencies
run: |
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
python -m pip install --user --upgrade pip setuptools wheel twine
# install the latest pytorch for testing
# however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated
Expand Down
21 changes: 16 additions & 5 deletions monai/bundle/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,15 @@ def _remove_ngc_prefix(name: str, prefix: str = "monai_") -> str:


def _download_from_ngc(
download_path: Path, filename: str, version: str, remove_prefix: str | None, progress: bool
download_path: Path,
filename: str,
version: str,
prefix: str = "monai_",
remove_prefix: str | None = "monai_",
progress: bool = True,
) -> None:
# ensure prefix is contained
filename = _add_ngc_prefix(filename)
filename = _add_ngc_prefix(filename, prefix=prefix)
url = _get_ngc_bundle_url(model_name=filename, version=version)
filepath = download_path / f"{filename}_v{version}.zip"
if remove_prefix:
Expand All @@ -231,10 +236,16 @@ def _download_from_ngc(


def _download_from_ngc_private(
download_path: Path, filename: str, version: str, remove_prefix: str | None, repo: str, headers: dict | None = None
download_path: Path,
filename: str,
version: str,
repo: str,
prefix: str = "monai_",
remove_prefix: str | None = "monai_",
headers: dict | None = None,
) -> None:
# ensure prefix is contained
filename = _add_ngc_prefix(filename)
filename = _add_ngc_prefix(filename, prefix=prefix)
request_url = _get_ngc_private_bundle_url(model_name=filename, version=version, repo=repo)
if has_requests:
headers = {} if headers is None else headers
Expand Down Expand Up @@ -491,7 +502,7 @@ def download(
url: url to download the data. If not `None`, data will be downloaded directly
and `source` will not be checked.
If `name` is `None`, filename is determined by `monai.apps.utils._basename(url)`.
remove_prefix: This argument is used when `source` is "ngc". Currently, all ngc bundles
remove_prefix: This argument is used when `source` is "ngc" or "ngc_private". Currently, all ngc bundles
have the ``monai_`` prefix, which is not existing in their model zoo contrasts. In order to
maintain the consistency between these two sources, remove prefix is necessary.
Therefore, if specified, downloaded folder name will remove the prefix.
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ black>=22.12
isort>=5.1
ruff
pytype>=2020.6.1; platform_system != "Windows"
types-pkg_resources
types-setuptools
mypy>=1.5.0
ninja
torchvision
Expand Down

0 comments on commit e30869d

Please sign in to comment.