Skip to content
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

FEATURE: need 'templates_dict' to ensure proper rendering of time macros. #95

Open
kuixiang opened this issue Jan 19, 2024 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@kuixiang
Copy link

When using KubernetesJobOperator in Apache Airflow and encountering issues where Jinja templating for jinja_job_args is treating Airflow time macros as string, shall we provide a mechanism similar to the templates_dict in KubernetesPodOperator?
e.g.

from datetime import datetime, timedelta
from airflow import DAG
from airflow.operators.kubernetes_pod_operator import KubernetesPodOperator

default_args = {
    'owner': 'airflow',
    'start_date': datetime(2024, 1, 1),
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
}

dag = DAG(
    'my_dag',
    default_args=default_args,
    schedule_interval='@daily',
)

my_task = KubernetesPodOperator(
    task_id='my_task',
    namespace='my_namespace',
    image='my_image:latest',
    cmds=['/bin/bash', '-c'],
    arguments=['echo', '{{ ds }}'],  # Using time macro directly
    templates_dict={'my_jinja_template': '{{ ds }}'},  # Template for Jinja templating
    dag=dag,
)
@kuixiang kuixiang added enhancement New feature or request help wanted Extra attention is needed labels Jan 19, 2024
@LamaAni
Copy link
Owner

LamaAni commented Jan 20, 2024

Hi, Sorry I dont understand what you mean. Do you want to extend the jinja template dict?
If so, feel free to send in a PR.

@LamaAni
Copy link
Owner

LamaAni commented Jan 28, 2024

Any more info on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants