luigi
luigi copied to clipboard
Parsing sets in configuration
import luigi
class cfg(luigi.Config):
param = set([1,2])
#param = [1,2] this works
d = luigi.DictParameter(default={'param': param})
mycfg = cfg()
The snippet above causes the error below:
$ python3 TESTLUIGI.py
Traceback (most recent call last):
(...)
TypeError: unhashable type: 'set'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "TESTLUIGI.py", line 6, in <module>
mycfg = cfg()
File "py3-luigi/3.0.3-236d2596d9d05d7a543a747ab3dbc082/lib/python3.9/site-packages/luigi/task_register.py", line 95, in __call__
return instantiate() # unhashable types in parameters
File "py3-luigi/3.0.3-236d2596d9d05d7a543a747ab3dbc082/lib/python3.9/site-packages/luigi/task_register.py", line 79, in instantiate
return super(Register, cls).__call__(*args, **kwargs)
File "py3-luigi/3.0.3-236d2596d9d05d7a543a747ab3dbc082/lib/python3.9/site-packages/luigi/task.py", line 443, in __init__
self.task_id = task_id_str(self.get_task_family(), self.to_str_params(only_significant=True, only_public=True))
File "py3-luigi/3.0.3-236d2596d9d05d7a543a747ab3dbc082/lib/python3.9/site-packages/luigi/task.py", line 494, in to_str_params
params_str[param_name] = params[param_name].serialize(param_value)
File "py3-luigi/3.0.3-236d2596d9d05d7a543a747ab3dbc082/lib/python3.9/site-packages/luigi/parameter.py", line 1007, in serialize
return json.dumps(x, cls=_DictParamEncoder)
File "python3/3.9.6/lib/python3.9/json/__init__.py", line 234, in dumps
return cls(
File "python3/3.9.6/lib/python3.9/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "python3/3.9.6/lib/python3.9/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "py3-luigi/3.0.3-236d2596d9d05d7a543a747ab3dbc082/lib/python3.9/site-packages/luigi/parameter.py", line 948, in default
return json.JSONEncoder.default(self, obj)
File "python3/3.9.6/lib/python3.9/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type set is not JSON serializable