Mehdi Nazari
08/25/2021, 3:26 PMWith
context. Has anyone been able to successfully do that?Kevin Kho
task.run()
ill run but the Python underneath but this will not be treated as a task with it’s own states and retries.
It sounds like maybe you want to do some kind of if-else
conditional to run another task?Mehdi Nazari
08/25/2021, 3:31 PMtask.run()
from another task that gets called in flow with context.Kevin Kho
Mehdi Nazari
08/25/2021, 4:02 PMKevin Kho
Mehdi Nazari
08/25/2021, 4:09 PMKevin Kho
batch_num
needs to be in the run()
. That’s the only thing I can see immediatelyMehdi Nazari
08/25/2021, 4:26 PMKevin Kho
query_fishnet.run(batch_num=10)
Mehdi Nazari
08/25/2021, 4:32 PMKevin Kho
Kevin Kho
import prefect
from prefect import task, Flow
@task
def abc(x):
return x+1
@task
def bcd():
x = abc.run(1)
logger = prefect.context.get("logger")
<http://logger.info|logger.info>(x)
with Flow("TestFlow") as flow:
bcd()
flow.run()
Kevin Kho
x = abc(1).run()
replicates your error:
`ValueError: Could not infer an active Flow context while creating edge to <Task: abc>. This often means you called a task outside a `with Flow(...)` block. If you're trying to run this task outside of a Flow context, you need to call `abc.run(...)`
Mehdi Nazari
08/25/2021, 4:48 PMKevin Kho
run
call? x=abc().run(1)
will also throw an error. I don’t fully remember the code, but do you call that task anywhere else?Mehdi Nazari
08/25/2021, 4:51 PMMehdi Nazari
08/25/2021, 4:51 PMKevin Kho
()
right after query_fishnet
. Change query_fishnet().run(10)
to query_fishnet.run(10)
Mehdi Nazari
08/25/2021, 4:58 PM