You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tests/unit/endpoints/test_infer_v2.py::TestDetectionBundleInferTask::test_lung_nodule_detector_infer
-------------------------------- live log call ---------------------------------
[ThreadPoolExecutor-40_0] [INFO] (monailabel.interfaces.utils.app:37) Initializing App from: /tmp/MONAILabel/sample-apps/monaibundle; studies: /tmp/MONAILabel/tests/data/detection; conf: {'heuristic_planner': 'false', 'server_mode': 'true', 'auto_update_scoring': 'false', 'debug': 'true', 'models': 'lung_nodule_ct_detection', 'tracking': False}
[ThreadPoolExecutor-40_0] [INFO] (monailabel.utils.others.class_utils:57) Subclass for MONAILabelApp Found: <class 'main.MyApp'>
[ThreadPoolExecutor-40_0] [INFO] (monailabel.utils.others.generic:351) +++ Adding Bundle from NGC: lung_nodule_ct_detection => /tmp/MONAILabel/sample-apps/monaibundle/model/lung_nodule_ct_detection
[ThreadPoolExecutor-40_0] [INFO] (monailabel.utils.others.generic:364) +++ Using Bundle Models: ['lung_nodule_ct_detection']
[ThreadPoolExecutor-40_0] [INFO] (monailabel.interfaces.app:135) Init Datastore for: /tmp/MONAILabel/tests/data/detection
[ThreadPoolExecutor-40_0] [INFO] (monailabel.datastore.local:130) Auto Reload: False; Extensions: ['*.nii.gz', '*.nii', '*.nrrd', '*.jpg', '*.png', '*.tif', '*.svs', '*.xml']
[ThreadPoolExecutor-40_0] [INFO] (monailabel.datastore.local:577) Invalidate count: 0
[ThreadPoolExecutor-40_0] [INFO] (main:74) +++ Adding Inferer:: lung_nodule_ct_detection => <monailabel.tasks.infer.bundle.BundleInferTask object at 0x7fd9290d94e0>
[ThreadPoolExecutor-40_0] [INFO] (main:89) +++ Adding Trainer:: lung_nodule_ct_detection => <monailabel.tasks.train.bundle.BundleTrainTask object at 0x7fd885769780>
[ThreadPoolExecutor-40_0] [INFO] (main:99) Active Learning Strategies:: ['random', 'first']
[ThreadPoolExecutor-40_0] [INFO] (monailabel.utils.sessions:51) Session Path: /tmp/MONAILabel/tests/data/sessions
[ThreadPoolExecutor-40_0] [INFO] (monailabel.utils.sessions:52) Session Expiry (max): 3600
[ThreadPoolExecutor-40_0] [INFO] (monailabel.endpoints.infer:171) Infer Request: {'model': 'lung_nodule_ct_detection', 'image': '1.3.6.1.4.1.14519.5.2.1.6279.6001.188385286346390202873004762827'}
[ThreadPoolExecutor-40_0] [INFO] (monailabel.tasks.infer.basic_infer:280) Infer Request (final): {'device': 'cuda:0', 'model_filename': ['model.pt'], 'model': 'lung_nodule_ct_detection', 'image': '/tmp/MONAILabel/tests/data/detection/1.3.6.1.4.1.14519.5.2.1.6279.6001.188385286346390202873004762827.nii.gz', 'description': 'A pre-trained model for volumetric (3D) detection of the lung lesion from CT image on LUNA16 dataset'}
FAILED [ 43%]
=================================== FAILURES ===================================
_________ TestDetectionBundleInferTask.test_lung_nodule_detector_infer _________
__path = 'monai.transforms.utility.dictionary.EnsureChannelFirstd'
__mode = default, kwargs = {'keys': 'image', 'meta_key_postfix': 'meta_dict'}
CompInitMode = <enum 'CompInitMode'>
component = <class 'monai.transforms.utility.dictionary.EnsureChannelFirstd'>
m = default
def instantiate(__path: str, __mode: str, **kwargs: Any) -> Any:
"""
Create an object instance or call a callable object from a class or function represented by ``_path``.
`kwargs` will be part of the input arguments to the class constructor or function.
The target component must be a class or a function, if not, return the component directly.
Args:
__path: if a string is provided, it's interpreted as the full path of the target class or function component.
If a callable is provided, ``__path(**kwargs)`` will be invoked and returned for ``__mode="default"``.
For ``__mode="callable"``, the callable will be returned as ``__path`` or, if ``kwargs`` are provided,
as ``functools.partial(__path, **kwargs)`` for future invoking.
__mode: the operating mode for invoking the (callable) ``component`` represented by ``__path``:
- ``"default"``: returns ``component(**kwargs)``
- ``"callable"``: returns ``component`` or, if ``kwargs`` are provided, ``functools.partial(component, **kwargs)``
- ``"debug"``: returns ``pdb.runcall(component, **kwargs)``
kwargs: keyword arguments to the callable represented by ``__path``.
"""
from monai.utils.enums import CompInitMode
component = locate(__path) if isinstance(__path, str) else __path
if component is None:
raise ModuleNotFoundError(f"Cannot locate class or function path: '{__path}'.")
m = look_up_option(__mode, CompInitMode)
try:
if kwargs.pop("_debug_", False) or run_debug:
warnings.warn(
f"\n\npdb: instantiating component={component}, mode={m}\n"
f"See also Debugger commands documentation: https://docs.python.org/3/library/pdb.html\n"
)
breakpoint()
if not callable(component):
warnings.warn(f"Component {component} is not callable when mode={m}.")
return component
if m == CompInitMode.DEFAULT:
> return component(**kwargs)
E TypeError: EnsureChannelFirstd.__init__() got an unexpected keyword argument 'meta_key_postfix'
/usr/local/lib/python3.10/dist-packages/monai/utils/module.py:264: TypeError
The above exception was the direct cause of the following exception:
self = <tests.unit.endpoints.test_infer_v2.TestDetectionBundleInferTask testMethod=test_lung_nodule_detector_infer>
def test_lung_nodule_detector_infer(self):
if not torch.cuda.is_available():
return
model = "lung_nodule_ct_detection"
image = "1.3.6.1.4.1.14519.5.2.1.6279.6001.188385286346390202873004762827"
> response = self.client.post(f"/infer/{model}?image={image}")
tests/unit/endpoints/test_infer_v2.py:67:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.10/dist-packages/starlette/testclient.py:633: in post
return super().post(
/usr/local/lib/python3.10/dist-packages/httpx/_client.py:1145: in post
return self.request(
/usr/local/lib/python3.10/dist-packages/starlette/testclient.py:516: in request
return super().request(
/usr/local/lib/python3.10/dist-packages/httpx/_client.py:827: in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
/usr/local/lib/python3.10/dist-packages/httpx/_client.py:914: in send
response = self._send_handling_auth(
/usr/local/lib/python3.10/dist-packages/httpx/_client.py:942: in _send_handling_auth
response = self._send_handling_redirects(
/usr/local/lib/python3.10/dist-packages/httpx/_client.py:979: in _send_handling_redirects
response = self._send_single_request(request)
/usr/local/lib/python3.10/dist-packages/httpx/_client.py:1015: in _send_single_request
response = transport.handle_request(request)
/usr/local/lib/python3.10/dist-packages/starlette/testclient.py:398: in handle_request
raise exc
/usr/local/lib/python3.10/dist-packages/starlette/testclient.py:395: in handle_request
portal.call(self.app, scope, receive, send)
/usr/local/lib/python3.10/dist-packages/anyio/from_thread.py:288: in call
return cast(T_Retval, self.start_task_soon(func, *args).result())
/usr/lib/python3.10/concurrent/futures/_base.py:458: in result
return self.__get_result()
/usr/lib/python3.10/concurrent/futures/_base.py:403: in __get_result
raise self._exception
/usr/local/lib/python3.10/dist-packages/anyio/from_thread.py:217: in _call_func
retval = await retval_or_awaitable
/usr/local/lib/python3.10/dist-packages/fastapi/applications.py:1054: in __call__
await super().__call__(scope, receive, send)
/usr/local/lib/python3.10/dist-packages/starlette/applications.py:123: in __call__
await self.middleware_stack(scope, receive, send)
/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py:186: in __call__
raise exc
/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py:164: in __call__
await self.app(scope, receive, _send)
/usr/local/lib/python3.10/dist-packages/starlette/middleware/cors.py:85: in __call__
await self.app(scope, receive, send)
/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py:65: in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py:64: in wrapped_app
raise exc
/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py:53: in wrapped_app
await app(scope, receive, sender)
/usr/local/lib/python3.10/dist-packages/starlette/routing.py:756: in __call__
await self.middleware_stack(scope, receive, send)
/usr/local/lib/python3.10/dist-packages/starlette/routing.py:776: in app
await route.handle(scope, receive, send)
/usr/local/lib/python3.10/dist-packages/starlette/routing.py:297: in handle
await self.app(scope, receive, send)
/usr/local/lib/python3.10/dist-packages/starlette/routing.py:77: in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py:64: in wrapped_app
raise exc
/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py:53: in wrapped_app
await app(scope, receive, sender)
/usr/local/lib/python3.10/dist-packages/starlette/routing.py:72: in app
response = await func(request)
/usr/local/lib/python3.10/dist-packages/fastapi/routing.py:278: in app
raw_response = await run_endpoint_function(
/usr/local/lib/python3.10/dist-packages/fastapi/routing.py:191: in run_endpoint_function
return await dependant.call(**values)
monailabel/endpoints/infer.py:206: in api_run_inference
return run_inference(background_tasks, model, image, session_id, params, file, label, output)
monailabel/endpoints/infer.py:172: in run_inference
result = instance.infer(request)
monailabel/interfaces/app.py:307: in infer
result_file_name, result_json = task(request)
monailabel/tasks/infer/basic_infer.py:297: in __call__
pre_transforms = self.pre_transforms(data)
monailabel/tasks/infer/bundle.py:201: in pre_transforms
c = self.bundle_config.get_parsed_content(k, instantiate=True)
/usr/local/lib/python3.10/dist-packages/monai/bundle/config_parser.py:290: in get_parsed_content
return self.ref_resolver.get_resolved_content(id=id, **kwargs)
/usr/local/lib/python3.10/dist-packages/monai/bundle/reference_resolver.py:193: in get_resolved_content
return self._resolve_one_item(id=id, **kwargs)
/usr/local/lib/python3.10/dist-packages/monai/bundle/reference_resolver.py:163: in _resolve_one_item
self._resolve_one_item(id=d, waiting_list=waiting_list, **kwargs)
/usr/local/lib/python3.10/dist-packages/monai/bundle/reference_resolver.py:171: in _resolve_one_item
self.resolved_content[id] = item.instantiate() if kwargs.get("instantiate", True) else item
/usr/local/lib/python3.10/dist-packages/monai/bundle/config_item.py:292: in instantiate
return instantiate(modname, mode, **args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
__path = 'monai.transforms.utility.dictionary.EnsureChannelFirstd'
__mode = default, kwargs = {'keys': 'image', 'meta_key_postfix': 'meta_dict'}
CompInitMode = <enum 'CompInitMode'>
component = <class 'monai.transforms.utility.dictionary.EnsureChannelFirstd'>
m = default
def instantiate(__path: str, __mode: str, **kwargs: Any) -> Any:
"""
Create an object instance or call a callable object from a class or function represented by ``_path``.
`kwargs` will be part of the input arguments to the class constructor or function.
The target component must be a class or a function, if not, return the component directly.
Args:
__path: if a string is provided, it's interpreted as the full path of the target class or function component.
If a callable is provided, ``__path(**kwargs)`` will be invoked and returned for ``__mode="default"``.
For ``__mode="callable"``, the callable will be returned as ``__path`` or, if ``kwargs`` are provided,
as ``functools.partial(__path, **kwargs)`` for future invoking.
__mode: the operating mode for invoking the (callable) ``component`` represented by ``__path``:
- ``"default"``: returns ``component(**kwargs)``
- ``"callable"``: returns ``component`` or, if ``kwargs`` are provided, ``functools.partial(component, **kwargs)``
- ``"debug"``: returns ``pdb.runcall(component, **kwargs)``
kwargs: keyword arguments to the callable represented by ``__path``.
"""
from monai.utils.enums import CompInitMode
component = locate(__path) if isinstance(__path, str) else __path
if component is None:
raise ModuleNotFoundError(f"Cannot locate class or function path: '{__path}'.")
m = look_up_option(__mode, CompInitMode)
try:
if kwargs.pop("_debug_", False) or run_debug:
warnings.warn(
f"\n\npdb: instantiating component={component}, mode={m}\n"
f"See also Debugger commands documentation: https://docs.python.org/3/library/pdb.html\n"
)
breakpoint()
if not callable(component):
warnings.warn(f"Component {component} is not callable when mode={m}.")
return component
if m == CompInitMode.DEFAULT:
return component(**kwargs)
if m == CompInitMode.CALLABLE:
return partial(component, **kwargs) if kwargs else component
if m == CompInitMode.DEBUG:
warnings.warn(
f"\n\npdb: instantiating component={component}, mode={m}\n"
f"See also Debugger commands documentation: https://docs.python.org/3/library/pdb.html\n"
)
return pdb.runcall(component, **kwargs)
except Exception as e:
> raise RuntimeError(
f"Failed to instantiate component '{__path}' with keywords: {','.join(kwargs.keys())}"
f"\n set '_mode_={CompInitMode.DEBUG}' to enter the debugging mode."
) from e
E RuntimeError: Failed to instantiate component 'monai.transforms.utility.dictionary.EnsureChannelFirstd' with keywords: keys,meta_key_postfix
E set '_mode_=debug' to enter the debugging mode.
/usr/local/lib/python3.10/dist-packages/monai/utils/module.py:274: RuntimeError
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: