Mehdi Nazari
08/10/2021, 6:24 PMKevin Kho
Mehdi Nazari
08/10/2021, 6:28 PMMehdi Nazari
08/10/2021, 6:28 PMKevin Kho
if
inside the Flow, use the case
task instead. Are you looping in the flow?Mehdi Nazari
08/10/2021, 8:39 PMsik
variable I’m expecting to hold a python object after task is run. It is coming out as None
; any idea?Kevin Kho
sik.target
it is None right?Kevin Kho
sik
is not defined because the loggers are ran before the tasks are. The Flow
block is like a build time but the tasks are executed during the runtime. You are getting None
because you are logging the task sik
and tasks have a proper called target
which is where they can be saved. If you try <http://logger.info|logger.info>(sik.test_attribute)
that does not share a name with a Task attribute, I think you will an error.Mehdi Nazari
08/10/2021, 9:03 PMsik.target
is NoneMehdi Nazari
08/10/2021, 9:07 PMKevin Kho
Mehdi Nazari
08/10/2021, 9:13 PMlogger
statements are used here to help understand the environment execution; main objective is to realize if the sik
object is properly instantiated with the other task above it.Kevin Kho
Mehdi Nazari
08/10/2021, 9:15 PMKevin Kho
from prefect import task, Flow
import prefect
@task
def abc(x):
return x
@task
def log(x):
logger = prefect.context.get("logger")
<http://logger.info|logger.info>(x)
return x
with Flow("test") as flow:
logger = prefect.context.get("logger")
a = abc(1)
<http://logger.info|logger.info>(a)
log(a)
flow.run()
Kevin Kho
<http://logger.info|logger.info>(a)
logs a task. The log
task shows the value.