You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like for @task.kubernetes to derive the task_id / pod_name based on the decorated function's name. To achieve this now, I would need to pass it into the decorator args, which is a bit repetitive:
We managed to do something like the above but it was more involved than expected:
# inheriting from a private class, not idealclassDefaultKubernetesDecoratedOperator(_KubernetesDecoratedOperator):
custom_operator_name="@default_kubernetes_task"# the operator removes the decorator so this is requireddef__init__(self, **kwargs: Any) ->None:
if"task_id"notinkwargsand"python_callable"inkwargs:
task_id=kwargs["python_callable"].__name__kwargs["task_id"] =task_idif"task_id"inkwargsand"name"notinkwargs:
name=f"{get_prefix()}-{kwargs['task_id']}"kwargs["name"] =namesuper().__init__(**kwargs)
defdefault_kubernetes_task(
python_callable: Callable[[], None] |None=None,
multiple_outputs: bool|None=None,
**kwargs: Any,
) ->TaskDecorator:
returntask_decorator_factory(
python_callable=python_callable,
multiple_outputs=multiple_outputs,
decorated_operator_class=DefaultKubernetesDecoratedOperator,
**kwargs,
)
Initially I tried wrapping task.kubernetes itself, but the source code scrubbing relies on a hardcoded decorator name, so it doesn't scrub the decorator and the pod fails with NameError: name 'default_kubernetes_task' is not defined:
It'd be nice if there were a more official way to achieve the above (or something similar). Perhaps:
@task.kubernetes could accept an override for the decorated_operator_class?
a list of custom operator names to remove could be set in the configuration?
Use case/motivation
I'd like for @task.kubernetes to derive the task_id / pod_name based on the decorated function's name, but more generally it could be useful to allow task.kubernetes to be overridden?
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
I would also like this to be more flexible. Thank you for pointing out that i need to override the custom_operator_name so it can strip the decorator name.
Description
I'd like for
@task.kubernetes
to derive the task_id / pod_name based on the decorated function's name. To achieve this now, I would need to pass it into the decorator args, which is a bit repetitive:We managed to do something like the above but it was more involved than expected:
Initially I tried wrapping
task.kubernetes
itself, but the source code scrubbing relies on a hardcoded decorator name, so it doesn't scrub the decorator and the pod fails withNameError: name 'default_kubernetes_task' is not defined
:It'd be nice if there were a more official way to achieve the above (or something similar). Perhaps:
@task.kubernetes
could accept an override for thedecorated_operator_class
?Use case/motivation
I'd like for
@task.kubernetes
to derive the task_id / pod_name based on the decorated function's name, but more generally it could be useful to allowtask.kubernetes
to be overridden?Related issues
No response
Are you willing to submit a PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: