<@ULVA73B9P> why does execution with a docker work...
# ask-marvin
a
@Marvin why does execution with a docker worker createds 2 flow runs. The first one is
Worker 'DockerWorker bla-bla' submitting flow run 'blu-blu'
that I can paramentrize wiht parameter=value And the second one (the submitted
blu-blu
) has no clue about the parameter I set.
m
Ah, the joys of Docker and Prefect. The first flow run you're seeing is the worker process itself. This worker is a lightweight polling process that kicks off scheduled flow runs on a certain type of infrastructure, in this case, Docker. It's like a middleman, you see. It's polling the Prefect API to request any scheduled flow runs it should pick up and then submit for execution. The second flow run, the
blu-blu
one, is the actual flow run that your worker picked up and submitted for execution. This is the one that does the actual work you've defined in your flow. As for the parameter issue, it's a bit tricky. You see, the parameters you set are for the worker flow run, not the actual flow run it submits. It's like telling the middleman to wear a hat, but expecting the guy he's sending to wear it. Doesn't quite work that way, does it? If you want to pass parameters to the actual flow run, you'll have to do it when you schedule the flow run itself, not when you start the worker. It's a bit like giving the hat to the middleman and telling him to pass it on to the guy he's sending. Makes sense, doesn't it? I hope that clears up your confusion. If not, well, I'm here to help. Or at least, I'm programmed to be.
a
@Marvin how to pass parameters to the actual flow run?
m
Ah, parameters. The lifeblood of any good flow run. Here's how you can pass parameters to your actual flow run: 1. Through the Prefect API or UI: When you create a flow run via the API or UI, you can specify parameters as a JSON object. The keys of this object should match the parameter names in your flow, and the values will be the values passed to those parameters. 2. Through the Prefect CLI: If you're creating a flow run via the Prefect CLI, you can pass parameters using the
--parameters
flag followed by a JSON string. For example:
prefect run flow --name my-flow --parameters '{"my_param": "my_value"}'
. 3. In your flow definition: If you want to set default values for your parameters, you can do so in your flow definition using the
Parameter
task. For example:
my_param = Parameter("my_param", default="my_default_value")
. These default values will be used if no other value is provided when the flow run is created. Remember, parameters are resolved at runtime into a dictionary of parameters mapping name to value. These parameters are stored by the Prefect orchestration engine on the flow run object. I hope that helps. If not, well, I'm sure you'll figure it out eventually. You humans are surprisingly resourceful when you put your minds to it.