[BUG] IOMappingError when running MAP
zephyrie opened this issue · 1 comments
Describe the bug
When running any MAP built after 3/14, you'll run into a monai.deploy.exceptions.IOMappingError error.
Traceback (most recent call last):
File "/opt/monai/app/app.py", line 22, in <module>
App(do_run=True)
File "/root/.local/lib/python3.8/site-packages/monai/deploy/core/application.py", line 129, in __init__
self.run(log_level=args.log_level)
File "/root/.local/lib/python3.8/site-packages/monai/deploy/core/application.py", line 429, in run
executor_obj.run()
File "/root/.local/lib/python3.8/site-packages/monai/deploy/core/executors/single_process_executor.py", line 93, in run
op_exec_context.input_context.set(DataPath(input_path, read_only=True), input_label)
File "/root/.local/lib/python3.8/site-packages/monai/deploy/core/io_context.py", line 114, in set
raise IOMappingError(
monai.deploy.exceptions.IOMappingError: The data type of 'image' in the input of '<sobel_operator.SobelOperator object at 0x7f9cb171d310>' is <class 'monai.deploy.core.domain.datapath.DataPath'>, but the value to set is the data type of <class 'monai.deploy.core.domain.datapath.DataPath'>.
Steps/Code to reproduce bug
Build any MAP, I tried tutorial 1 and tutorial 3 from the tutorials folder. After packaging the application and trying to run it with monai-deploy run simple_app:latest input output
you'll get an the IOMappingError.
Expected behavior
Successfully run the MAP
Environment details (please complete the following information)
- OS/Platform: Ubuntu 20.04
- Python Version: 3.8
- Method of MONAI Deploy App SDK install: [pip, conda, Docker, or from source] pip
- SDK Version: 0.5.0
Additional context
The issue seems to be tied to typeguard moving to 3.0 and checking check_type to not be backward compatible. A temporary workaround is to require typeguard as a dependency for the application
As mentioned in the bug report, the current workaround is to ensure that typeguard~=2.12.1
, effective avoiding v3 of typeguard in the MAP container. There are a couple ways to implement this workaround:
- in the application class, the
env
decorator can be used to specify this pip package and its version, e.g.@monai.deploy.core.env(pip_packages=["typeguard~=2.12.1"])
- Create a requirements.txt file which will contain the line
typeguard~=2.12.1
, and then when packaging the MAP, use the requirements option to provide this requirements file,monai-deploy package --requirements <requirements.txt> ...