Ihor Ramskyi
08/14/2024, 1:53 PMfrom prefect import flow, task
from prefect.states import Completed
@task
def task_a():
return Completed(message='A', data={'A': 1})
@flow
def some_flow():
a = task_a.submit().result()
return
if __name__ == '__main__':
some_flow()
It works on Prefect2.20.0, but doesn't on Prefect3.0.0rc16. On Prefect3 it produces such error message:
16:44:46.929 | ERROR | Task run 'task_a-0' - Task run failed with exception: TypeError("Can't instantiate abstract class BaseResult with abstract methods create, get") - Retries are exhausted
Traceback (most recent call last):
File "My_Path\venv\lib\site-packages\prefect\task_engine.py", line 804, in run_context
yield self
File "My_Path\venv\lib\site-packages\prefect\task_engine.py", line 1420, in run_task_sync
engine.call_task_fn(txn)
File "My_Path\venv\lib\site-packages\prefect\task_engine.py", line 832, in call_task_fn
result = call_with_parameters(self.task.fn, parameters)
File "My_Path\venv\lib\site-packages\prefect\utilities\callables.py", line 208, in call_with_parameters
return fn(*args, **kwargs)
File "My_Path\test_flow4.py", line 6, in task_a
return Completed(message='A', data={"A": 1})
File "My_Path\venv\lib\site-packages\prefect\states.py", line 556, in Completed
return cls(type=StateType.COMPLETED, **kwargs)
File "My_Path\venv\lib\site-packages\pydantic\main.py", line 176, in __init__
self.__pydantic_validator__.validate_python(data, self_instance=self)
File "My_Path\venv\lib\site-packages\prefect\results.py", line 405, in __new__
return super().__new__(cls)
TypeError: Can't instantiate abstract class BaseResult with abstract methods create, get
16:44:47.005 | ERROR | Task run 'task_a-0' - Finished in state Failed("Task run encountered an exception TypeError: Can't instantiate abstract class BaseResult with abstract methods create, get")
Seems that I cannot pass a dict as data on Prefect3, because the code works for data='A'
, data=1
, and data={1}
. Is there something that should be done differently (if I want to pass dict as a parameter) or it's unexpected type as of now?Chris White