Skip to content

Commit

Permalink
Use + as prefix for taskflow references
Browse files Browse the repository at this point in the history
  • Loading branch information
tatiana committed Dec 5, 2024
1 parent 0b07eed commit 2a2f978
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions dagfactory/dagbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,15 +987,15 @@ def make_decorator(
else operator_obj.partial(**task_params).expand(**expand_kwargs)
)
"""

callable_args_keys = inspect.getfullargspec(python_callable).args
callable_kwargs = {}
decorator_kwargs = dict(**task_params)
for arg_key, arg_value in task_params.items():
if arg_key in callable_args_keys:
decorator_kwargs.pop(arg_key)
if arg_value in tasks_dict:
callable_kwargs[arg_key] = tasks_dict[arg_value]
if arg_value.startswith("+"):
upstream_task_name = arg_value.split("+")[0]
callable_kwargs[arg_key] = tasks_dict[upstream_task_name]
else:
callable_kwargs[arg_key] = arg_value

Expand Down
8 changes: 4 additions & 4 deletions dev/dags/example_taskflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ example_taskflow:
tasks:
some_number:
decorator: airflow.decorators.task
python_callable: "sample.some_number"
python_callable: sample.some_number
numbers_list:
decorator: airflow.decorators.task
python_callable_name: build_numbers_list
python_callable_file: $CONFIG_ROOT_DIR/sample.py
double_number_from_arg:
decorator: airflow.decorators.task
python_callable: "sample.double"
python_callable: sample.double
number: 2
double_number_from_task:
decorator: airflow.decorators.task
python_callable: "sample.double"
number: some_number # this is a task previously defined
python_callable: sample.double
number: +some_number # this is a task previously defined
#dependencies: [some_number]
#double_list_dynamically:
# python_callable: !!python/name:sample.double"
Expand Down

0 comments on commit 2a2f978

Please sign in to comment.