clearml icon indicating copy to clipboard operation
clearml copied to clipboard

Fire integration is not compatible with typing library

Open smos1 opened this issue 2 years ago • 2 comments

Consider the following code:

from typing import Tuple
import clearml
import fire

def dummy() -> Tuple:
    print("Does nothing")
    return (1,2)

if __name__ == '__main__':
    fire.Fire()

When run from command line with python fireclearmltest.py dummy it results in the following error:

Traceback (most recent call last):
  File "fireclearmltest.py", line 10, in <module>
    fire.Fire()
  File "/home/sergey/miniconda3/envs/firetest/lib/python3.8/site-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/home/sergey/miniconda3/envs/firetest/lib/python3.8/site-packages/fire/core.py", line 466, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/home/sergey/miniconda3/envs/firetest/lib/python3.8/site-packages/clearml/binding/frameworks/__init__.py", line 36, in _inner_patch
    raise ex
  File "/home/sergey/miniconda3/envs/firetest/lib/python3.8/site-packages/clearml/binding/frameworks/__init__.py", line 34, in _inner_patch
    ret = patched_fn(original_fn, *args, **kwargs)
  File "/home/sergey/miniconda3/envs/firetest/lib/python3.8/site-packages/clearml/binding/fire_bind.py", line 158, in __CallAndUpdateTrace
    PatchFire.__groups, PatchFire.__commands = PatchFire.__get_all_groups_and_commands(
  File "/home/sergey/miniconda3/envs/firetest/lib/python3.8/site-packages/clearml/binding/fire_bind.py", line 229, in __get_all_groups_and_commands
    current_groups, current_commands = PatchFire.__get_groups_and_commands_for_args(
  File "/home/sergey/miniconda3/envs/firetest/lib/python3.8/site-packages/clearml/binding/fire_bind.py", line 243, in __get_groups_and_commands_for_args
    component_trace = fire.core._Fire(component, args_, parsed_flag_args, context, name=name).GetResult()  # noqa
  File "/home/sergey/miniconda3/envs/firetest/lib/python3.8/site-packages/fire/core.py", line 556, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/home/sergey/miniconda3/envs/firetest/lib/python3.8/site-packages/clearml/binding/frameworks/__init__.py", line 30, in _inner_patch
    return original_fn(*args, **kwargs)
  File "/home/sergey/miniconda3/envs/firetest/lib/python3.8/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "/home/sergey/miniconda3/envs/firetest/lib/python3.8/typing.py", line 724, in __call__
    raise TypeError(f"Type {self._name} cannot be instantiated; "
TypeError: Type Tuple cannot be instantiated; use tuple() instead

clearml version is 1.3.1 Fire version is 0.4.0

smos1 avatar Mar 19 '22 09:03 smos1

Hi @smos1,

We'll take a look at that!

erezalg avatar Mar 20 '22 13:03 erezalg

Hello @smos1, We've just release clearml 1.4.0 with a fix for this issue :) Let us know if this works!

erezalg avatar May 05 '22 17:05 erezalg

Hi @smos1, closing this. Please re-open if required.

jkhenning avatar Sep 12 '22 06:09 jkhenning