https://prefect.io logo
Title
m

Maximilian Schulz

04/20/2023, 3:23 PM
Hello everyone! I am just starting to evaluate Prefect with DaskTaskRunners, migrating from Luigi. The workflow is highly parametrized - for now users would call a prefect script from the command line and input a setting file, but I would like it to be compatible to the "deployment parameters" in the future It is unclear to me where I find more information about flow parametrization? I have seen this article which seems to use Prefect 1.x (https://www.prefect.io/guide/blog/how-to-make-your-data-pipelines-more-dynamic-using-parameters-in-prefect/ ) and then the tutorial using Pydantic: https://docs.prefect.io/latest/concepts/flows/#parameters
n

Nate

04/21/2023, 4:23 PM
hi @Maximilian Schulz - it sounds like in your case, in practice you'll be dealing with deployment parameters so you can set default parameters on a flow that you will deploy like
@flow
def my_flow(param1: str = "marvin", param2: int = 42):
   ...
which will be picked up during deployment creation or you can edit the parameters in deployment yaml as mentioned the linked docs and then users can kick off flow runs from the UI, API, or CLI by running the deployment with custom parameters
m

Maximilian Schulz

04/24/2023, 6:59 AM
Thank you @Nate for your response! Do you know if there is any built-in support to call a Prefect flow from command line (not the Prefect Server) and use a config file instead of a deployment? (similar to e.g. Luigi or Nextflow)
n

Nate

04/24/2023, 2:39 PM
we don't necessarily have a config file for flows, but if you're just interested in running a flow locally and using a standalone file to hold values, you could define default param values in one file and import them into your flow file, so that you can change the param defaults without changing your flow code. you could run your flow locally with
python yourfile.py
-- if you're looking for something else, let me know! I'm not the most familiar with luigi / nextflow 🙂
values.py
(or use yaml and
safe_load
if you wanted)
param1 = "marvin"
param2 = 42
my_flow.py
from values import param1, param2

@flow
def my_flow(param1: str = param1, param2: int = param2):
   ...