Chris Histe
06/22/2022, 3:58 PM@op()
def my_string():
return "my_string"
Then I call it like this
my_op(my_string(), other_var)
But that’s kind of a smell. I’d like to use this but it doesn’t work:
my_op("my_string", other_var)
Is there a cleaner way?Zach
06/22/2022, 4:13 PMChris Histe
06/22/2022, 4:33 PMChris Histe
06/22/2022, 4:34 PMmy_op("name", other_var)
my_op("age", other_var)
Zach
06/22/2022, 4:53 PMChris Histe
06/22/2022, 5:30 PMZach
06/22/2022, 5:37 PMChris Histe
06/22/2022, 5:41 PMZach
06/22/2022, 5:42 PMZach
06/22/2022, 5:42 PMZach
06/22/2022, 5:43 PMChris Histe
06/22/2022, 5:47 PMChris Histe
06/22/2022, 5:48 PMChris Histe
06/22/2022, 5:49 PMAndrew Leverentz
06/22/2022, 5:49 PMdef my_op(subtype: str):
@op(
name=f"my_op_{subtype}"
)
def wrapped(context, value):
"""
do something with value + subtype here
"""
return wrapped
@graph
def my_graph():
other_var = some_other_op()
my_op("name")(other_var)
my_op("age")(other_var)
Chris Histe
06/22/2022, 5:51 PMAndrew Leverentz
06/22/2022, 5:53 PMChris Histe
06/22/2022, 5:53 PMZach
06/22/2022, 5:54 PM@op(config_schema={"configurable_strings": [str]})
def get_config(context):
for i, s in enumerate(context.op_config["configurable_strings"]):
yield DynamicOutput(s, mapping_key=str(i))
@graph
def my_graph():
data = get_data()
get_config().map(lambda x: handle_data(x, data))
Zach
06/22/2022, 5:55 PMChris Histe
06/22/2022, 5:56 PMChris Histe
06/22/2022, 5:57 PMChris Histe
06/22/2022, 5:57 PMsandy
06/22/2022, 6:00 PM@op(config_schema=str)
def my_op(context, other_input):
my_str = context.op_config
@graph
def my_graph():
my_op.configured("age", name="age_my_op")(other_var)
my_op.configured("name", name="name_my_op")(other_var)
Zach
06/22/2022, 6:09 PM