Uh oh!
There was an error while loading. Please reload this page.
Bugfix: Move rendering of map_index_template so it renders for failed tasks as long as it was defined before the point of failure - #38902
Conversation
RNHTTR
left a comment
There was a problem hiding this comment.
Nice! Thanks for cleaning up my mess :)
Uh oh!
There was an error while loading. Please reload this page.
uranusjr
commented
Apr 12, 2024
This should fix things… |
TJaniF
commented
Apr 12, 2024
@uranusjr thank you! |
Uh oh!
There was an error while loading. Please reload this page.
I wonder what I've experienced is same type of the problem above:
In this case, all map_index values are integer, instead of given names. |
TJaniF
commented
May 28, 2024
@rightx2 That is interesting. I just tried that and for me the map index values from the first run "stick", but maybe I misunderstood what you are doing :) This is what I tried: This is the DAG: fromairflow.decoratorsimportdag, task@dag(start_date=None,schedule=None,catchup=False,)defmapping_test():
@task(map_index_template="{{ custom_map_index }}" )defadd_one(num):
importtimeifnum>10:
time.sleep(10)
else:
time.sleep(2)
fromairflow.operators.pythonimportget_current_contextcontext=get_current_context()
context["custom_map_index"] ="Input x="+str(num)
returnnum+1add_one.expand(num=[1, 2, 3, 4, 5, 10, 11, 12, 13])
mapping_test()I'm using Airflow 2.9.1 (Astro Runtime 11.3.0) |
rightx2
commented
May 29, 2024
I think there was a mistake in my experiment. I believe I can clarify it now.
|
@rightx2 Thanks for the added explanation. I understand what you mean now and can reproduce it, marking as success (or as failed) will lead to an integer index even if the code to define the custom map index has already run. Thanks for flagging this! @RNHTTR I think it would be nice if it worked for marking tasks the same way as for failed tasks with attempting to render the custom map index template even if interrupted. :) |


In Airflow 2.9
map_index_templatedoes not render when the task fails.I moved the rendering into the
finallyof_execute_callableso it always happens.TaskFlow:

Traditional operator:

Also attempted 2 unit tests :)
Apologies if there is already a PR addressing this. I did not see one.
cc: @RNHTTR
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in newsfragments.