https://prefect.io logo
Title
t

Tim-Oliver

11/03/2022, 3:34 PM
Hey, I would like to use a string-block value during the flow configuration. How would I do that?
What I have tried so far:
@flow(
    name="Create Experiment",
    task_runner=DaskTaskRunner(
        cluster_class="dask_jobqueue.SLURMCluster",
        cluster_kwargs={
            ...
            "job_script_prologue": [
                String.load("log-slurm-job").value,
            ],
        },
    ),
)
def my_flow():
But this will not build a deployment because the load was not
awaited
. What would be the correct way to use blocks for flow-configurations?
k

Khuyen Tran

11/03/2022, 3:44 PM
This works for me:
from prefect import flow 
from prefect.blocks.system import String 

@flow(name=String.load("test").value)
def my_flow():
    ...

if __name__=="__main__":
    my_flow()
I wonder if it has something to do with using DaskTaskRunner
t

Tim-Oliver

11/03/2022, 3:46 PM
Does it also work once it is deployed?
k

Khuyen Tran

11/03/2022, 3:49 PM
Hmm I see. It doesn’t work when it is deployed
t

Tim-Oliver

11/03/2022, 3:51 PM
But interesting that deployment works for you. Even if I use the block for the flow name
@flow(
    name=String.load("test").value
I get
RuntimeWarning: coroutine 'Block.load' was never awaited
when I run
prefect deployment build ...
.
I can wrap
String.load("test").value
into a `async`function and await the result inside it. Then the deployment works, but when I run the deployment it hangs forever (waited for 10min and then killed it).
k

Khuyen Tran

11/03/2022, 4:34 PM
This is a bug and we will solve it with this PR
🙏 1