You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "kyungjunleeme (via GitHub)" <gi...@apache.org> on 2025/07/28 06:49:49 UTC
[PR] Change Default sorting in taskinstances [airflow]
kyungjunleeme opened a new pull request, #53804:
URL: https://github.com/apache/airflow/pull/53804
### Description
<img width="2800" height="1988" alt="image" src="https://github.com/user-attachments/assets/1e427b93-91f9-46c4-a887-62b4bd01ea7d" />
I add sorting field(`map_index`), before, It cause people confused with task instances order. It can maintain correct sorting default.
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change Default sorting in taskinstances [airflow]
Posted by "kyungjunleeme (via GitHub)" <gi...@apache.org>.
kyungjunleeme commented on code in PR #53804:
URL: https://github.com/apache/airflow/pull/53804#discussion_r2238075642
##########
airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx:
##########
@@ -188,7 +188,7 @@ export const TaskInstances = () => {
const { setTableURLState, tableURLState } = useTableURLState();
const { pagination, sorting } = tableURLState;
const [sort] = sorting;
- const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-start_date"];
+ const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-map_index", "-start_date"];
Review Comment:
<img width="702" height="1228" alt="image" src="https://github.com/user-attachments/assets/8109f602-8424-46fe-aa43-35a18b9297a1" />
When I tested sorting the mapped tasks with different start_date values,
adding run_after as a sorting key worked exactly as I intended.
It ensured a descending order within each start_date group,
and also descending order across different start_date values.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change Default sorting in taskinstances [airflow]
Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl commented on code in PR #53804:
URL: https://github.com/apache/airflow/pull/53804#discussion_r2237877220
##########
airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx:
##########
@@ -188,7 +188,7 @@ export const TaskInstances = () => {
const { setTableURLState, tableURLState } = useTableURLState();
const { pagination, sorting } = tableURLState;
const [sort] = sorting;
- const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-start_date"];
+ const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-map_index", "-start_date"];
Review Comment:
Yes, the additional sorting is understood. But I was wondering why you sort by "map index" _first_ and then by start date. Assuming you have multiple dynamically mapped tasks this would first display all mapped tasks by index and the others by start date. But all mapped tasks interleaved.
I was asking myself why the sort order is not first by start date and then by map index as second criteria. But I am myself not sure if mapped tasks all share the same start_date?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change Default sorting in taskinstances [airflow]
Posted by "kyungjunleeme (via GitHub)" <gi...@apache.org>.
kyungjunleeme commented on code in PR #53804:
URL: https://github.com/apache/airflow/pull/53804#discussion_r2237870155
##########
airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx:
##########
@@ -188,7 +188,7 @@ export const TaskInstances = () => {
const { setTableURLState, tableURLState } = useTableURLState();
const { pagination, sorting } = tableURLState;
const [sort] = sorting;
- const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-start_date"];
+ const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-map_index", "-start_date"];
Review Comment:
I added an additional sorting condition because sorting by start_date alone does not properly order the map_index.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change Default sorting in taskinstances [airflow]
Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl merged PR #53804:
URL: https://github.com/apache/airflow/pull/53804
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change Default sorting in taskinstances [airflow]
Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl commented on code in PR #53804:
URL: https://github.com/apache/airflow/pull/53804#discussion_r2237751894
##########
airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx:
##########
@@ -188,7 +188,7 @@ export const TaskInstances = () => {
const { setTableURLState, tableURLState } = useTableURLState();
const { pagination, sorting } = tableURLState;
const [sort] = sorting;
- const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-start_date"];
+ const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-map_index", "-start_date"];
Review Comment:
is there a reason you are not sorting by start-date / map index but map index / start-date?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change Default sorting in taskinstances [airflow]
Posted by "kyungjunleeme (via GitHub)" <gi...@apache.org>.
kyungjunleeme commented on PR #53804:
URL: https://github.com/apache/airflow/pull/53804#issuecomment-3137934225
Yes, you’re absolutely right — it’s understandable to be confused.
My original intention was to sort by map_index in descending order. During the process, I received some feedback and started considering map_index in the context of start_date. After testing, I found that using run_after gave the results I was looking for, so I ended up applying sorting based on run_after.
That said, I’m still curious why sorting by map_index alone didn’t give me the desired result — I think digging into that could help better understand the underlying logic.
In any case, I’ll update the PR description to avoid confusion for others.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change Default sorting in taskinstances [airflow]
Posted by "kyungjunleeme (via GitHub)" <gi...@apache.org>.
kyungjunleeme commented on PR #53804:
URL: https://github.com/apache/airflow/pull/53804#issuecomment-3130111250
I changed priority sort criterion.
<img width="942" height="826" alt="image" src="https://github.com/user-attachments/assets/b8e573fc-2a3c-4257-ba49-091faca23acc" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change Default sorting in taskinstances [airflow]
Posted by "kyungjunleeme (via GitHub)" <gi...@apache.org>.
kyungjunleeme commented on code in PR #53804:
URL: https://github.com/apache/airflow/pull/53804#discussion_r2237983904
##########
airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx:
##########
@@ -188,7 +188,7 @@ export const TaskInstances = () => {
const { setTableURLState, tableURLState } = useTableURLState();
const { pagination, sorting } = tableURLState;
const [sort] = sorting;
- const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-start_date"];
+ const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-map_index", "-start_date"];
Review Comment:
<img width="432" height="541" alt="image" src="https://github.com/user-attachments/assets/a04973d1-f3ba-4384-8a33-9f90bcc1143f" />
The situation you were concerned about is the following one, right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change Default sorting in taskinstances [airflow]
Posted by "kyungjunleeme (via GitHub)" <gi...@apache.org>.
kyungjunleeme commented on code in PR #53804:
URL: https://github.com/apache/airflow/pull/53804#discussion_r2237885018
##########
airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx:
##########
@@ -188,7 +188,7 @@ export const TaskInstances = () => {
const { setTableURLState, tableURLState } = useTableURLState();
const { pagination, sorting } = tableURLState;
const [sort] = sorting;
- const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-start_date"];
+ const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-map_index", "-start_date"];
Review Comment:
Thanks for the feedback!
You’re right — I initially used orderBy: ["-map_index", "-start_date"], which could lead to the interleaving issue you mentioned.
I’ll update the order to ["-start_date", "-map_index"] so that tasks are sorted by execution time first, and then by map index within the same start time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change Default sorting in taskinstances [airflow]
Posted by "kyungjunleeme (via GitHub)" <gi...@apache.org>.
kyungjunleeme commented on code in PR #53804:
URL: https://github.com/apache/airflow/pull/53804#discussion_r2238075642
##########
airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx:
##########
@@ -188,7 +188,7 @@ export const TaskInstances = () => {
const { setTableURLState, tableURLState } = useTableURLState();
const { pagination, sorting } = tableURLState;
const [sort] = sorting;
- const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-start_date"];
+ const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : ["-map_index", "-start_date"];
Review Comment:
<img width="702" height="1228" alt="image" src="https://github.com/user-attachments/assets/8109f602-8424-46fe-aa43-35a18b9297a1" />
When I tested sorting the mapped tasks with different start_date values,
adding run_after as a sorting key worked exactly as I intended.
It ensured a descending order within each start_date group,
and also descending order across different start_date values.
I initially tried using map_index for sorting, but it didn’t produce the result I wanted during testing.
So I replaced it with run_after, which worked as intended.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org