Skip to content

map_index_template does not change the map index displayed in the UI #49224

@TJaniF

Description

@TJaniF

Apache Airflow version

3.0.0

If "Other Airflow 2 version" selected, which one?

main branch

What happened?

In Airflow 2.10.5 the dag below changes the map index displayed in the UI:

from airflow.decorators import dag, task

@dag()
def my_dag():

    @task
    def upstream_task():
        return [1, 2, 3]

    @task(
        map_index_template="Hello! {{ my_custom_template }}",
    )
    def map_me(x, **context):
        print(x)

        from airflow.operators.python import get_current_context

        context = get_current_context()

        context["my_custom_template"] = f"{x}"

    map_me.expand(x=upstream_task())

my_dag()

Image

In RC 2 map_index_template does not change the index. (no errors)

from airflow.decorators import dag, task


@dag
def dtm():

    @task
    def upstream_task():
        return [1, 2, 3]

    @task(
        map_index_template="Hello! {{ my_custom_template }}",
    )
    def map_me(x):
        print(x)

        from airflow.sdk.definitions.context import get_current_context

        context = get_current_context()

        context["my_custom_template"] = f"{x}"

    map_me.expand(x=upstream_task())


dtm()

Image

What you think should happen instead?

No response

How to reproduce

Use the second dag above and run it. See the integer index in the UI.

Operating System

MacOS

Versions of Apache Airflow Providers

Breeze

Deployment

Other

Deployment details

breeze

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Labels

affected_version:3.0Issues Reported for 3.0area:task-execution-interface-aip72AIP-72: Task Execution Interface (TEI) aka Task SDKkind:bugThis is a clearly a bugpriority:highHigh priority bug that should be patched quickly but does not require immediate new release

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions