better-printer-5326
01/03/2025, 4:22 PM--model val1
and run another --model val2
. They should be independent from each other, however, they share the same code.
@project(name="hello_flow")
@schedule(hourly=True)
class HelloWorld(FlowSpec):
model = Parameter(
"model",
required=True,
help="e.g. val1, val2, etc.",
)
@step
def start(self) -> None:
<http://logger.info|logger.info>("Hello World run started!")
self.next(self.greet)
@step
def greet(self) -> None:
<http://logger.info|logger.info>(" ####### Hello World from %s! #######", self.model_slug)
self.next(self.end)
@step
def end(self) -> None:
<http://logger.info|logger.info>("Hello World run completed!")
if __name__ == "__main__":
HelloWorld()
better-printer-5326
01/03/2025, 4:24 PMpoetry run python hello_flow/flow.py --model val1 argo-workflows create
pyproject_name: hello-flow
Usage: flow.py [OPTIONS] COMMAND [ARGS]...
Try 'flow.py --help' for help.
Error: no such option: --model
dry-beach-38304
01/03/2025, 6:46 PMbetter-printer-5326
01/03/2025, 6:48 PMdry-beach-38304
01/03/2025, 6:49 PMbetter-printer-5326
01/03/2025, 6:49 PMhundreds-wire-22547
01/03/2025, 9:43 PMpoetry run python hello_flow/flow.py --model <someval> argo-workflows create
it will overwrite the Argo cron workflow definition, with the only change being the value for model
? it will not create k
Argo cron workflows if I provide k
different values for model
. we would try on our side, but need to update metaflow
version to test.hundreds-wire-22547
01/03/2025, 9:47 PMk
independent Argo cron workflows where the only difference is the config/parameters.
the only other way I could think to do this to upload our target flow as an Argo workflow template and then use some sort of event triggering for the k
configs where we trigger and pass the config to the template, but I figure there has to be something simpler.dry-beach-38304
01/03/2025, 10:15 PMhundreds-wire-22547
01/03/2025, 10:21 PMmaster
and be deployed as "production" via --production
. not sure if we want to manage branches for this use case as we want to treat them as independent flows that happen to use the same flow definition.
branches feel targeted towards use case for experimentation where at some point you want to merge back to some production branch.hundreds-wire-22547
01/03/2025, 10:34 PMancient-application-36103
01/04/2025, 12:02 AMk
different workflow templates being deployed? if so, you can change the name of the deployed template using --name
- python flow.py argo-workflows --name foo create
hundreds-wire-22547
01/04/2025, 12:19 AMk
cron workflowssquare-wire-39606
01/04/2025, 12:21 AM--name
might suffice. of course, you can also just create a single deployment and trigger it using different parameter values.square-wire-39606
01/04/2025, 12:23 AMsquare-wire-39606
01/04/2025, 12:28 AMhundreds-wire-22547
01/04/2025, 12:38 AMdry-beach-38304
01/04/2025, 12:46 AMhundreds-wire-22547
01/06/2025, 6:54 PMdry-beach-38304
01/06/2025, 9:16 PMdry-beach-38304
01/12/2025, 8:11 AMfrom metaflow import project, FlowSpec, config_expr, Config
@project(name="hello_flow", branch=config_expr("config.model")
@schedule(hourly=True)
class HelloWorld(FlowSpec):
config = Config("config", required=True)
...
Then you can have various configs like:
# config1.json
{
"model": "val1",
...
}
etc (config2.json, …)
Then you can do something like this to deploy:
for config_file in ["config1.json", ...]:
Deployer("myflow.py", config=[("config", config_file)]).argo_workflows().create()
That will deploy stuff with projects called hello_flow.test.val1
, etc. You can also add production=True
to the @project
to get the hello_flow.prod.val1
.hundreds-wire-22547
01/13/2025, 7:23 PM--name
as an alternative to branch?dry-beach-38304
01/13/2025, 7:27 PMdry-beach-38304
01/13/2025, 7:28 PMname
in the @project
decorator.dry-beach-38304
01/13/2025, 7:29 PMdry-beach-38304
01/13/2025, 7:29 PMhundreds-wire-22547
01/13/2025, 7:30 PMname
will override any value set currently in the @project
decorator?dry-beach-38304
01/13/2025, 7:33 PMfrom metaflow import project, FlowSpec, config_expr, Config
@project(name=config_expr("config.model")
@schedule(hourly=True)
class HelloWorld(FlowSpec):
config = Config("config", default_value={"model": "my_default_model"})
In this case, if you have no config passed in, the name of the project would be my_default_model
and if you did have a config it would use whatever was in that. So in that sense, it would override the default but there is no @project(name="my_default")
and then magically we override my_default
if you provide a config. You have to say that the name comes from the config (but can have a default config).hundreds-wire-22547
01/13/2025, 7:35 PMdry-beach-38304
01/13/2025, 7:35 PMbetter-printer-5326
01/14/2025, 10:06 PM