Skip to content

Allow templating for more arguments in RunPipelineJobOperator #50206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
ferenc-hechler opened this issue May 5, 2025 · 6 comments · Fixed by #50220
Closed
2 tasks done

Allow templating for more arguments in RunPipelineJobOperator #50206

ferenc-hechler opened this issue May 5, 2025 · 6 comments · Fixed by #50220
Labels
area:providers kind:feature Feature Requests provider:google Google (including GCP) related issues

Comments

@ferenc-hechler
Copy link
Contributor

Apache Airflow Provider(s)

google

Versions of Apache Airflow Providers

No response

Apache Airflow version

2.10.2

Operating System

GCP Composer 2.9.11

Deployment

Google Cloud Composer

Deployment details

No response

What happened

I tried to use jinja templating to set parameters like "template_path", "pipeline_root" or "service_account".
The templates are not replaced with actual values, instead of service_account is set to the string {{ var.value... }}.

What you think should happen instead

templates should also be supported for these fields and the value of the environment variable should be given.

How to reproduce

Executing the following task fails:

    run_task = RunPipelineJobOperator(
        task_id="run_pipeline_job",
        display_name="Run Pipeline Job",
        template_path="{{ var.value.KFP_TEMPLATE_URL }}",
        parameter_values={},
        region="europe-west3",
        project_id="my-project-id",
    )

The AirFlow variable KFP_TEMPLATE_URL is set to a valid template uploaded to an Kubeflow Pipeline Artifact Registry.
In the error message it is to see, that template_path was not resolved.

invalid URL "{{ var.value.KFP_TEMPLATE_URL }}"

Anything else

I was able to activate templating by inheriting the RunPipelineJobOperator and extend the class variable tempalte_fields:

template_fields = [
"region",
"project_id",
"input_artifacts",
"impersonation_chain",
]

    template_fields = [
        "region",
        "project_id",
        "input_artifacts",
        "impersonation_chain",
[+]     "template_path",
[+]     "pipeline_root",
[+]     "parameter_values",
[+]     "service_account",
    ]

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@ferenc-hechler ferenc-hechler added kind:bug This is a clearly a bug area:providers labels May 5, 2025
Copy link

boring-cyborg bot commented May 5, 2025

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.

@ferenc-hechler ferenc-hechler added the needs-triage label for new issues that we didn't triage yet label May 5, 2025
@dosubot dosubot bot added kind:feature Feature Requests provider:google Google (including GCP) related issues labels May 5, 2025
ferenc-hechler added a commit to ferenc-hechler/airflow that referenced this issue May 5, 2025
the fields "template_path", "pipeline_root", "parameter_values", "service_account" where added to allow jinja templating these args.
@ferenc-hechler
Copy link
Contributor Author

There exists also a discussion for this: #48627

ferenc-hechler added a commit to ferenc-hechler/airflow that referenced this issue May 6, 2025
the fields "template_path", "pipeline_root", "parameter_values", "service_account" where added to allow jinja templating these args.
@gyli
Copy link
Collaborator

gyli commented May 7, 2025

I don't see a problem adding these fields to template fields. @MaksYermak do you remember why they were not template field at the beginning?

@MaksYermak
Copy link
Contributor

I don't see a problem adding these fields to template fields. @MaksYermak do you remember why they were not template field at the beginning?

At the beginning we, always, don't know what fields users want to have as templated. We add only the most useful to template_fields and then extended it. I, also, do not see any problems with these new fields.

@gyli
Copy link
Collaborator

gyli commented May 9, 2025

Hi @ferenc-hechler shall I assign this issue to you if you want to create a PR for this?

@ferenc-hechler
Copy link
Contributor Author

There is already a PR for this: #50220

@gyli gyli removed kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet labels May 10, 2025
shahar1 pushed a commit that referenced this issue May 12, 2025
* issue #50206: add more template_fields to RunPipelineJobOperator

the fields "template_path", "pipeline_root", "parameter_values", "service_account" where added to allow jinja templating these args.

* add new template_fields to unit tests

* rollback templating tests for wrong operator

---------

Co-authored-by: feri <feri@DESKTOP-QSATAT0.speedport.ip>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers kind:feature Feature Requests provider:google Google (including GCP) related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants