Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancing get_all_bundles_list under monai.bundle to support model zoo NGC hosting #6833

Closed
KumoLiu opened this issue Aug 8, 2023 · 6 comments · Fixed by #6997
Closed

Enhancing get_all_bundles_list under monai.bundle to support model zoo NGC hosting #6833

KumoLiu opened this issue Aug 8, 2023 · 6 comments · Fixed by #6997
Assignees

Comments

@KumoLiu
Copy link
Contributor

KumoLiu commented Aug 8, 2023

Follow-up issue #6761.

In this PR, I have updated the download API under monai.bundle to support model zoo NGC hosting.

It appears that there are still several other methods that need to be updated, such as get_all_bundles_list, get_bundle_versions, and get_bundle_info which may be used in MONAILabel.
https://github.com/Project-MONAI/MONAILabel/blob/1d034726c655102cf612053842b1c45727966612/monailabel/utils/others/generic.py#L261

We can't use the search API in NGC API doc to find all models. May need the NGC team to add support for this one.

cc @wyli @ericspod @Nic-Ma @yiheng-wang-nv

@KumoLiu KumoLiu self-assigned this Aug 8, 2023
@KumoLiu KumoLiu moved this to Todo in MONAI v1.3 Aug 11, 2023
@wyli
Copy link
Contributor

wyli commented Aug 16, 2023

(This is useful for here as well: https://github.com/Project-MONAI/SlicerMONAIViz/blob/22cc28103b0b2167d9f5e973c54f2a376703cedf/MONAIViz/MONAIVizLib/utils.py#L106)

@KumoLiu
Copy link
Contributor Author

KumoLiu commented Sep 13, 2023

Looks like we can use the raw file link of "model_info.json" as a workaround. But seems not a recommend way.

request_url = f"https://raw.githubusercontent.com/Project-MONAI/model-zoo/dev/models/model_info.json"
resp = get(request_url)

@yiheng-wang-nv
Copy link
Contributor

yiheng-wang-nv commented Sep 13, 2023

Thanks @KumoLiu . Did you confirm that request this file have no rate limit restriction?

@KumoLiu
Copy link
Contributor Author

KumoLiu commented Sep 13, 2023

GitHub's rate limiting typically applies to API requests, I didn't meet rate limit restriction in a 6000loop try with this raw file link but it's not the recommended way to interact with GitHub programmatically.

@yiheng-wang-nv
Copy link
Contributor

yiheng-wang-nv commented Sep 13, 2023

GitHub's rate limiting typically applies to API requests, I didn't meet rate limit restriction in a 6000loop try with this raw file link but it's not the recommended way to interact with GitHub programmatically.

I see. If not have other methods so far, I think we can add error handling to process exceptions such as if not get expected content, and then this way is fine. I'm not sure if there are any other drawbacks, and we may need @wyli @ericspod 's suggestions here.

@ericspod
Copy link
Member

GitHub's rate limiting typically applies to API requests, I didn't meet rate limit restriction in a 6000loop try with this raw file link but it's not the recommended way to interact with GitHub programmatically.

I see. If not have other methods so far, I think we can add error handling to process exceptions such as if not get expected content, and then this way is fine. I'm not sure if there are any other drawbacks, and we may need @wyli @ericspod 's suggestions here.

Let's see if this continues to work first because it is an easy solution, if not we just have to be more careful with the API calls. The rate limits are to stop people from hammering the servers intentionally or otherwise, specifically to avoid using it as some sort of real time system. Requested information shouldn't change often so caching would be expected on the client side, eg. using something like https://pypi.org/project/requests-cache/ for our case. MONAI Label could use this to avoid checking the model zoo constantly.

@wyli wyli moved this from Todo to In Progress in MONAI v1.3 Sep 18, 2023
KumoLiu added a commit to KumoLiu/MONAI that referenced this issue Sep 18, 2023
Signed-off-by: KumoLiu <[email protected]>
@github-project-automation github-project-automation bot moved this from In Progress to Done in MONAI v1.3 Sep 18, 2023
wyli pushed a commit that referenced this issue Sep 18, 2023
…zoo NGC hosting (#6997)

Fixes #6833 

### Description
Add `model_info_url` in `get_all_bundles_list`, `get_bundle_versions`,
and `get_bundle_info`.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: KumoLiu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants