Amit Singh
03/23/2020, 3:27 PMflow = flow or prefect.context.get("flow", None)
if not flow:
> raise ValueError("Could not infer an active Flow context.")
E ValueError: Could not infer an active Flow context.
josh
03/23/2020, 3:28 PM.run()
function when outside of the context of a flowIn [2]: @task
...: def a():
...: print(5)
...:
In [3]: a()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-17-8d7b4527e81d> in <module>
----> 1 a()
~/Desktop/code/prefect/src/prefect/core/task.py in __call__(self, mapped, task_args, upstream_tasks, flow, *args, **kwargs)
395 new = self.copy(**(task_args or {}))
396 new.bind(
--> 397 *args, mapped=mapped, upstream_tasks=upstream_tasks, flow=flow, **kwargs
398 )
399 return new
~/Desktop/code/prefect/src/prefect/core/task.py in bind(self, mapped, upstream_tasks, flow, *args, **kwargs)
447 flow = flow or prefect.context.get("flow", None)
448 if not flow:
--> 449 raise ValueError("Could not infer an active Flow context.")
450
451 self.set_dependencies(
ValueError: Could not infer an active Flow context.
In [4]: a.run()
5
Chris White
task.run
like @josh mentioned avoids such internalsAmit Singh
03/23/2020, 3:31 PM@task(name='create_athena_table_from_file_task')
def create_athena_table_from_file()
Chris White
Amit Singh
03/23/2020, 3:31 PMresponse = sm_lib.athena_wrapper.create_athena_table_from_file(**temp_params)
Chris White
Amit Singh
03/23/2020, 3:35 PMChris White
create_athena_table_from_file
object is actually an instance of a task classAmit Singh
03/23/2020, 3:38 PMChris White