Chandrashekhar Kotekar
01/25/2024, 8:48 AM@task(
cache=False if os.environ.get("ENVIRONMENT") == "test" else True,
cache_serialize=False if os.environ.get("ENVIRONMENT") == "test" else True,
cache_version="1.0",
retries=3,
)
def my_awesome_task(common_input_1: str, common_input_2: str) -> str:
# my magical task code which returns a string
We have at least 10 such tasks. While all the tasks are working fine, is there any way to avoid this repeatative / boiler plate code and pass same config to each task? Using @wrapper
decoration won't help here.
Any idea how we can reduce this boilerplate code? or - have I written tasks in wrong way?Jake Dodd
01/25/2024, 9:27 AMtask_config = {
"cache": False if os.environ.get("ENVIRONMENT") == "test" else True,
"cache_serialize": False if os.environ.get("ENVIRONMENT") == "test" else True,
"cache_version": "1.0",
"retries": 3,
}
@task(**task_config)
def func(input_1: str) -> str:
...
Chandrashekhar Kotekar
01/25/2024, 9:35 AMKetan (kumare3)
Chandrashekhar Kotekar
01/25/2024, 9:43 PMKetan (kumare3)
Ketan (kumare3)
def my_task(... limited):
bind_vals ...
return functools.partial(task, bind_vals...)