Skip to content

Commit

Permalink
Fix weekly cpu test error and add hash check [skip-gpu] (#549)
Browse files Browse the repository at this point in the history
Fixes #548 .

### Description
A few sentences describing the changes proposed in this pull request.

### Status
**Ready**

### Please ensure all the checkboxes:
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Codeformat tests passed locally by running `./runtests.sh
--codeformat`.
- [ ] In-line docstrings updated.
- [ ] Update `version` and `changelog` in `metadata.json` if changing an
existing bundle.
- [ ] Please ensure the naming rules in config files meet our
requirements (please refer to: `CONTRIBUTING.md`).
- [ ] Ensure versions of packages such as `monai`, `pytorch` and `numpy`
are correct in `metadata.json`.
- [ ] Descriptions should be consistent with the content, such as
`eval_metrics` of the provided weights and TorchScript modules.
- [ ] Files larger than 25MB are excluded and replaced by providing
download links in `large_file.yml`.
- [ ] Avoid using path that contains personal information within config
files (such as use `/home/your_name/` for `"bundle_root"`).

Signed-off-by: Yiheng Wang <[email protected]>
  • Loading branch information
yiheng-wang-nv authored Jan 25, 2024
1 parent 4ac5884 commit 08ffcd5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
12 changes: 10 additions & 2 deletions ci/download_latest_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,23 @@
import os

from monai.bundle import download
from utils import get_latest_version
from utils import get_checksum, get_hash_func, get_latest_version, get_version_checksum


def download_latest_bundle(bundle_name: str, models_path: str, download_path: str):
model_info_path = os.path.join(models_path, "model_info.json")
version = get_latest_version(bundle_name=bundle_name, model_info_path=model_info_path)

checksum = get_version_checksum(bundle_name=bundle_name, version=version, model_info_path=model_info_path)
download(name=bundle_name, source="monaihosting", version=version, bundle_dir=download_path)

# verify checksum
hash_func = get_hash_func(hash_type="sha1")
bundle_zip_name = f"{bundle_name}_v{version}.zip"
downloaded_checksum = get_checksum(dst_path=os.path.join(download_path, bundle_zip_name), hash_func=hash_func)
if checksum != downloaded_checksum:
raise ValueError(f"Checksum of {bundle_zip_name} is not correct.")
print(f"Checksum of downloaded bundle {bundle_name} is correct.")


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="")
Expand Down
5 changes: 4 additions & 1 deletion ci/get_bundle_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@

from utils import get_sub_folders

# new added bundles should temporarily be added to this list, and remove until they can be downloaded successfully
EXCLUDE_LIST = ["segmentation_template", "classification_template"]


def main(models_path):
bundle_list = get_sub_folders(root_dir=models_path)

bundle_list = [b for b in bundle_list if b not in EXCLUDE_LIST]
print(bundle_list)


Expand Down
5 changes: 5 additions & 0 deletions ci/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ def get_latest_version(bundle_name: str, model_info_path: str):
return sorted(versions)[-1]


def get_version_checksum(bundle_name: str, version: str, model_info_path: str):
model_info_dict = get_json_dict(model_info_path)
return model_info_dict[f"{bundle_name}_v{version}"]["checksum"]


def submit_pull_request(model_info_path: str):
# set required info for a pull request
branch_name = "auto-update-model-info"
Expand Down

0 comments on commit 08ffcd5

Please sign in to comment.