Daniel Lomartra
10/31/2023, 7:23 PMclass testEnum1(Enum):
a = "a"
b = "b"
class testEnum2(Enum):
c = "c"
d = "d"
@task(log_prints=True)
def task1(enum1, enum2):
print(f"enum1: {enum1}")
print(f"enum2: {enum2}")
@flow
def test_flow(
param1: testEnum1,
param2: testEnum2,
):
task1(enum1=param1, enum2=param2)
if __name__ == "__main__":
deployment = test_flow.deploy(parameters={"param1": "a"})
Chris White
param1
as a parameter to your flow?Daniel Lomartra
11/01/2023, 3:12 PMundecorated_flow_function.__name__ = flow_name
and manually adding the decorated flow to globals globals()[flow_name] = decorated_flow
.
It would be preferred to generate these flows as deployments of a single flow instead of different flows. param1
is something that needs to vary between the flow versions at deployment time but should always be the same when the flow is run. For example, let's say I need to deploy 1 flow per customer, param1
could be something like the customer's name.Chris White
freeze
too):
from prefect import freeze
deployment = test_flow.deploy(parameters={"param1": freeze("a")})
Basically all we have to do is manipulate the underlying OpenAPI schema (which is what the API uses to expose choices / types) so that "param1" is stored as an Enum with only one possible value ("a"). All of this logic can live on the client too which is nice.Daniel Lomartra
11/01/2023, 8:06 PMChris White