Skip to content

template_fields not working in the decorator task.docker  #29585

Closed

Description

@jeffery9876

Apache Airflow Provider(s)

docker

Versions of Apache Airflow Providers

apache-airflow-providers-docker 3.4.0

Apache Airflow version

2.5.1

Operating System

Linux

Deployment

Docker-Compose

Deployment details

No response

What happened

The templated fields are not working under task.docker

@task.docker(image="python:3.9-slim-bullseye", container_name='python_{{macros.datetime.now() | ts_nodash}}', multiple_outputs=True)
def transform(order_data_dict: dict):
    """
    #### Transform task
    A simple Transform task which takes in the collection of order data and
    computes the total order value.
    """
    total_order_value = 0

    for value in order_data_dict.values():
        total_order_value += value

    return {"total_order_value": total_order_value}

Will throws error with un-templated container_name

Bad Request ("Invalid container name (python_{macros.datetime.now() | ts_nodash}), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed")

What you think should happen instead

All these fields should work with docker operator:

https://airflow.apache.org/docs/apache-airflow-providers-docker/stable/_api/airflow/providers/docker/operators/docker/index.html

template_fields: Sequence[str]= ('image', 'command', 'environment', 'env_file', 'container_name')

How to reproduce

with the example above

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. boring-cyborg commented on Feb 17, 2023

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions