Rob Fowler
04/05/2021, 12:16 PMRob Fowler
04/05/2021, 12:23 PM__init__
at run time in the agent.
I could further hack it, like it does, by calling it if it is un-initialised but not going through any 'init' seems it might lead to other troubles.Kevin Kho
Kevin Kho
Rob Fowler
04/05/2021, 9:52 PMRob Fowler
04/05/2021, 9:53 PMKevin Kho
Kevin Kho
Kevin Kho
Result
location should work.Rob Fowler
04/05/2021, 10:43 PM__init__
method is not called at all. But, I am not sure how it can be as the init is not in the flow.Rob Fowler
04/05/2021, 10:44 PMimport os
import sys
from prefect import Flow, Parameter
sys.path.append(os.path.abspath(os.getcwd())) # noqa E402
from ext.redis_result import RedisResult
from tasks.ptest import test_task # noqa
with Flow("ptest-flow") as flow:
opts = Parameter('opts', default={})
result = test_task(opts)
from mcs_env.custom_docker_storage import ComplexDocker
# 'loading_flow': True,
# 'local_script_path': 'ptt/ptest.py',
print("========================= HERE?")
flow.storage = ComplexDocker(image_name="ptest")
flow.result = RedisResult()
flow.storage.build()
Rob Fowler
04/05/2021, 10:45 PMRob Fowler
04/05/2021, 10:47 PMRob Fowler
04/05/2021, 10:48 PM__init__
automatically during the run if the redis server is not set at runtime and this will read the environment I have injected into the agent.
This works but it's a bit of a hack.Zanie
Zanie
Zanie
Rob Fowler
04/05/2021, 11:42 PMRob Fowler
04/05/2021, 11:43 PMZanie
Zanie
Rob Fowler
04/05/2021, 11:48 PMRob Fowler
04/05/2021, 11:48 PMRob Fowler
04/05/2021, 11:48 PMRob Fowler
04/05/2021, 11:49 PMRob Fowler
04/05/2021, 11:50 PMZanie
Rob Fowler
04/06/2021, 12:09 AMRob Fowler
04/06/2021, 12:10 AMRob Fowler
04/06/2021, 12:11 AMZanie
flow.result = RedisResult(location="{foo}/{task_run_id}")
then just provide PREFECT__CONTEXT__FOO
in your flow run environment.Rob Fowler
04/06/2021, 12:21 AMZanie
Zanie
f
string formatter. We're delegating the formatting to the flow runner which templates result locations as in the doc I linked.Rob Fowler
04/06/2021, 12:23 AMRob Fowler
04/06/2021, 12:24 AMRob Fowler
04/06/2021, 12:25 AMRob Fowler
04/06/2021, 12:28 AMwith Flow("ptest-flow", result=CustomResult()) as flow:
CustomResult.__init__(..
is never called at runtime.Zanie
Result
type you should use the "approved" technique of templating the location (which can use environment variables via the Prefect context)Zanie
Zanie
Rob Fowler
04/06/2021, 12:36 AMRob Fowler
04/06/2021, 12:37 AMRob Fowler
04/06/2021, 12:38 AMZanie
Rob Fowler
04/06/2021, 2:29 AMRob Fowler
04/06/2021, 2:31 AMif 'local_script_path' in context:
from mcs_env.custom_docker_storage import ComplexDocker
flow.storage = ComplexDocker(image_name="ptest", flow_file="ptest-flow.py")
flow.storage.build()
~
Rob Fowler
04/06/2021, 9:57 AMRob Fowler
04/06/2021, 11:38 AM