Avinash Santhanagopalan
02/01/2024, 4:59 PMwith_options
for an async flow. It says the below error. Has anyone else faced the same issue? Any workarounds?
AttributeError: 'coroutine' object has no attribute 'with_options'
Nate
02/01/2024, 5:52 PMAvinash Santhanagopalan
02/01/2024, 6:05 PMjobs = [
refresh_data_for_plugin(
plugin_name,
environment,
*additional_args,
**batch_kwargs,
).with_options(name=f"refresh-{plugin_name}-{environment}")
for plugin_name in plugins
]
asyncio.gather(*jobs)
That refresh_data_for_plugin
is the flow I’m trying to rename using with_options
@flow
async def refresh_data_for_plugin(
plugin_name: str,
environment: str,
*additional_args,
**batch_kwargs,
) -> None:
Nate
02/01/2024, 6:09 PMrefresh_data_for_plugin
instead of the coro you get when you call it
so as is you'd want
jobs = [
refresh_data_for_plugin.with_options(name=f"refresh-{plugin_name}-{environment}")(
plugin_name,
environment,
*additional_args,
**batch_kwargs,
)
for plugin_name in plugins
]
asyncio.gather(*jobs)
but what I would do instead is this
@flow(name="refresh-{plugin_name}-{environment}")
async def refresh_data_for_plugin(
plugin_name: str,
environment: str,
*additional_args,
**batch_kwargs,
) -> None:
and then
jobs = [
refresh_data_for_plugin(
plugin_name,
environment,
*additional_args,
**batch_kwargs,
)
for plugin_name in plugins
]
asyncio.gather(*jobs)
Avinash Santhanagopalan
02/01/2024, 6:10 PMAvinash Santhanagopalan
02/02/2024, 3:37 PM{plugin_name}
and {environment}
do not get applied for the flow if used in a decorator. f-strings also don’t work. I guess that substitution only works for flow_run_name
.
But refresh_data_for_plugin.with_options(name=f"refresh-{plugin_name}-{environment}")
did work so thanks for that!