Skip to content

[AIP-31] Create PythonFunctionalOperator #8056

@casassg

Description

@casassg

Description

Operator that enables wrapping a python function and call it as a function in the DAG.

  • Should have __call__ method that captures args and kwargs and sets them as op_args and op_kwargs.

Use case / motivation

Base class needed to implement functions wrapped in operators. See Python function decorator in AIP-31

Example implementation: https://github.com/casassg/corrent/blob/master/corrent/operators.py

Stretch goal

  • Add copy(new_task_id:str) method that allows you to create a new PythonFunctionOperator from the previous operator and changing the task_id. This should make it easier to reuse functional operators in a DAG without affecting the constraint of having a unique ID.
  • Another option is to append a number in the function if no new_task_id is set by looking in the DAG object for other operators with the same task_id.

Metadata

Metadata

Assignees

Labels

AIP-31Task Flow API for nicer DAG definitionkind:featureFeature Requests

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions