Project-MONAI / monai-deploy-app-sdk

MONAI Deploy App SDK offers a framework and associated tools to design, develop and verify AI-driven applications in the healthcare imaging domain.
Apache License 2.0
95 stars 48 forks source link

[BUG] App SDK v0.6 Packager fails to build MAP, if a Wheel is NOT provided on the commandline #453

Closed MMelQin closed 7 months ago

MMelQin commented 1 year ago

Describe the bug

Note: a workaround is provided at the end of the bug report.

With MONAI Deploy App SDK v0.6, when packaging an application using the monai-deploy package command with only the specified mandatory arguments, e.g. monai-deploy package simple_imaging_app -c simple_imaging_app/app.yaml -t simple_app:1.0 --platform x64-workstation , the packager fails with the follow error:

ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref y8uxyvatmaopuhvxtrc49hyqj::owxhqwev8q82fnss9a02pnx2q: "/None": not found

More detailed log would show Docker build error, e.g.

#22 [16/21] COPY ./None /tmp/None
#22 ERROR: failed to calculate checksum of ref y8uxyvatmaopuhvxtrc49hyqj::owxhqwev8q82fnss9a02pnx2q: "/None": not found
------
 > [16/21] COPY ./None /tmp/None:
------
Dockerfile:78
--------------------
  76 |     
  77 |     # Copy user-specified MONAI Deploy SDK file
  78 | >>> COPY ./None /tmp/None
  79 |     RUN pip install /tmp/None
  80 |     

Steps/Code to reproduce bug

Easiest is to run one of the Jupyter notebook in the example and watch the App Packaging steps.

Expected behavior

The Packager is expected to pip install monai-deploy-app-sdk from pypi,org, but it has a bug in detecting that monai-deploy-app-sdk Wheel file is NOT provided and still enforces to copy and install the App SDK with the non-existent Wheel file.

Environment details (please complete the following information)

Workaround

The workarounds are known, and the simplest one is to download the monai-deploy-app-sdk Python Wheel file, and provide it when running the Packager (add -l DEBUG to see detailed output), e.g.

monai-deploy package simple_imaging_app -c simple_imaging_app/app.yaml -t simple_app:1.0 --platform x64-workstation --monai-deploy-sdk-file monai_deploy_app_sdk-0.6.0-py3-none-any.whl

To download the App SDK Wheel file

Advanced Workaround

Additional context

A patch release should be released to fix the simple issue in the Packager.

jordimassaguerpla commented 1 year ago

You can also use pip download. With pip download, you can specify the python version to use, and the version of the wheel to download. It can easily be that the host where you run pip does not have the same python version than the one inside the container, so it is very useful.

You can see an example here, where we use python3.9 to download the wheel for python3.8

https://github.com/Project-MONAI/monai-deploy-app-sdk/compare/main...jordimassaguerpla:monai-deploy-app-sdk:add_build_and_push_workflow4?expand=1#diff-710503ae696552592f60ebb90a34083e5d0c857aa0ab9535760c660f1915c140R86

MMelQin commented 1 year ago

You can also use pip download. With pip download, you can specify the python version to use, and the version of the wheel to download. It can easily be that the host where you run pip does not have the same python version than the one inside the container, so it is very useful.

You can see an example here, where we use python3.9 to download the wheel for python3.8

https://github.com/Project-MONAI/monai-deploy-app-sdk/compare/main...jordimassaguerpla:monai-deploy-app-sdk:add_build_and_push_workflow4?expand=1#diff-710503ae696552592f60ebb90a34083e5d0c857aa0ab9535760c660f1915c140R86

Thanks for the input, though this defect is caused by a minor coding error, detailed in the workaround, rather than mechanism/workflow.

KyteProject commented 10 months ago

Thanks for detailing the workaround. In the context of following the instructions on the example app in jupyter I just added a cell before the deployment command with:

from urllib.request import urlretrieve
urlretrieve("https://files.pythonhosted.org/packages/67/df/414c50600c56de434df8a794fadecddad42fcad46f1d6b162c795d54a376/monai_deploy_app_sdk-0.6.0-py3-none-any.whl","simple_imaging_app/monai_deploy_app_sdk-0.6.0-py3-none-any.whl")

then used the updated command above to deploy:

tag_prefix = "simple_imaging_app"

!monai-deploy package simple_imaging_app -c simple_imaging_app/app.yaml -t {tag_prefix}:1.0 --platform x64-workstation --monai-deploy-sdk-file simple_imaging_app/monai_deploy_app_sdk-0.6.0-py3-none-any.whl -l DEBUG

Allowing me to continue following the steps and keeping it contained in the notebook.

MMelQin commented 10 months ago

Thanks a lot for making it transparent to the users!