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

Only return non-None task summaries for grid view #23924

Closed
wants to merge 3 commits into from

Conversation

jedcunningham
Copy link
Member

If we do return None's, it breaks the grid view when a new task is added
to a DAG.

Fixes: #23908

If we do return None's, it breaks the grid view when a new task is added
to a DAG.
@boring-cyborg boring-cyborg bot added the area:webserver Webserver related Issues label May 25, 2022
@uranusjr
Copy link
Member

Would it be more straightforward to do this at the front end instead?

@jedcunningham
Copy link
Member Author

Maybe, but I'm not sure sending a bunch of nulls out to the front end is really useful. This restores the behavior pre #23813, as I'm pretty sure this new behavior wasn't intentional.

airflow/www/views.py Outdated Show resolved Hide resolved
Co-authored-by: Tzu-ping Chung <[email protected]>
@jedcunningham jedcunningham marked this pull request as ready for review May 26, 2022 05:15
Comment on lines +261 to +265
'instances': [
ts
for ts in (wwwutils.get_task_summary(dr, task_item_or_group, session) for dr in dag_runs)
if ts is not None
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to throw out another option,

Suggested change
'instances': [
ts
for ts in (wwwutils.get_task_summary(dr, task_item_or_group, session) for dr in dag_runs)
if ts is not None
],
'instances': filter(
lambda x: x is not None,
(wwwutils.get_task_summary(dr, task_item_or_group, session) for dr in dag_runs),
),

don't know if it also needs to be wrapped with list. i know we tend to prefer comprehension over map etc, but in this case it saves you that ts variable, which, since we're already iterating over DRs, is a tiny bit more cognitive load i thought.

Copy link
Member

@uranusjr uranusjr May 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW if we don’t need to care about empty summary (or if we’re OK to also filter those out), we can simply do

filter(None, (...))

But yes I believe an additional list call is necessary here, so comprehension is better IMO.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, i was thinking there must be a shorthand of some kind for this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative fix here: #23932 - I think we shoudl slowly start add typing also to views.py as this precisely the kind of errors that would have been prevented if we had typing here in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More type checking is always nice. I've been meaning to add typescript to the UI.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More type checking is always nice. I've been meaning to add typescript to the UI.

Oh yeah. Absolutely. Typescript is soooo much better than plain javascript. One thing that it makes easier - is for anyone to contribute more fixes in an easy way. (once we have a built-in automation to transpile it, which is super-easy with yarn etc). I think lack of typing support, autocomplete and verification makes it really difficult for "newcomers" to reason about their changes and it's so much easier to contribute small fixes there.

You somehow loose that when you get familiar, when you put yourselve in the shoes of new contributor - it's a world of difference.

@jedcunningham jedcunningham added this to the Airflow 2.3.2 milestone May 26, 2022
@bbovenzi
Copy link
Contributor

I'll try out this and Jarek's solution in a few hours. I'll also open a PR to make sure the UI handles this issue better. We should definitely show a blank task instance in the grid if it doesn't exist in a dag run but does in others.

@potiuk
Copy link
Member

potiuk commented May 26, 2022

I'll try out this and Jarek's solution in a few hours. I'll also open a PR to make sure the UI handles this issue better. We should definitely show a blank task instance in the grid if it doesn't exist in a dag run but does in others.

Cool.

@bbovenzi
Copy link
Contributor

UI fix: #23939

@jedcunningham
Copy link
Member Author

Closing this in favor of #23947, which fixes the same bug but also significantly improves response time.

@jedcunningham jedcunningham deleted the fix_grid_view_new_tasks branch May 26, 2022 19:29
@ephraimbuddy ephraimbuddy removed this from the Airflow 2.3.2 milestone Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:webserver Webserver related Issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants