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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰[BUG]: Download API issues #182

Open
adamjstewart opened this issue Mar 10, 2024 · 1 comment
Open

馃悰[BUG]: Download API issues #182

adamjstewart opened this issue Mar 10, 2024 · 1 comment
Labels
0 - Backlog In queue waiting for assignment bug Something isn't working

Comments

@adamjstewart
Copy link

adamjstewart commented Mar 10, 2024

Version

0.1.0

On which installation method(s) does this occur?

Source

Describe the issue

The download API is a bit finicky. First, when I use earth2mip.networks.get_model(...) with a remote model name, it takes a long time to instantiate (presumably because it is downloading a model checkpoint). However, there is no progress bar (tqdm would help here). Because I didn't know what was happening, I Ctrl+C'ed the process and tried again. Every subsequent time, I get the following error:

>>> m = get_model("e2mip://pangu", device="cuda:8")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/adam/spack/opt/spack/linux-ubuntu22.04-zen2/gcc-12.3.0/py-earth2mip-0.1.0-eg37aficdacia2bylnpyisnznioeuoo2/lib/python3.10/site-packages/earth2mip/networks/__init__.py", line 345, in get_model
    return _load_package_builtin(package, device, name=url.netloc)
  File "/home/adam/spack/opt/spack/linux-ubuntu22.04-zen2/gcc-12.3.0/py-earth2mip-0.1.0-eg37aficdacia2bylnpyisnznioeuoo2/lib/python3.10/site-packages/earth2mip/networks/__init__.py", line 291, in _load_package_builtin
    return inference_loader(package, device=device)
  File "/home/adam/spack/opt/spack/linux-ubuntu22.04-zen2/gcc-12.3.0/py-earth2mip-0.1.0-eg37aficdacia2bylnpyisnznioeuoo2/lib/python3.10/site-packages/earth2mip/networks/pangu.py", line 266, in load
    model_6 = PanguStacked(PanguWeather(p6))
  File "/home/adam/spack/opt/spack/linux-ubuntu22.04-zen2/gcc-12.3.0/py-earth2mip-0.1.0-eg37aficdacia2bylnpyisnznioeuoo2/lib/python3.10/site-packages/earth2mip/networks/pangu.py", line 74, in __init__
    os.stat(self.path)
FileNotFoundError: [Errno 2] No such file or directory: '/home/adam/.cache/earth2mip/models/pangu/pangu_weather_6.onnx'

Ideally, this should just redownload the model instead of crashing just because the model hasn't been downloaded. Current workaround is to delete this model directory and try again.

Environment details

Linux Ubuntu 22.04
@adamjstewart adamjstewart added ? - Needs Triage Need team to review and classify bug Something isn't working labels Mar 10, 2024
@nbren12
Copy link
Collaborator

nbren12 commented Apr 2, 2024

Thanks for the report. I've done this myself many times.

Indeed the caching logic is not very robust right now. When writing to the cache we could write e.g. to .cache/earth2mip/models/pangu/pangu_weather_6.onnx.partial or similar, and then shutil.move to the final location. This will make the cache operations atomic, and avoid leaving it in a broken state.

And yes, a progress bar would be helpful too. Pangu is very slow to download.

@nbren12 nbren12 added 0 - Backlog In queue waiting for assignment and removed ? - Needs Triage Need team to review and classify labels Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 - Backlog In queue waiting for assignment bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants