Skip to content

Render DAGCode in the Grid View as a tab#31113

Merged
bbovenzi merged 10 commits into
apache:mainfrom
tquazi:grid_view_dag_code
May 17, 2023
Merged

Render DAGCode in the Grid View as a tab#31113
bbovenzi merged 10 commits into
apache:mainfrom
tquazi:grid_view_dag_code

Conversation

@tquazi

@tquazi tquazi commented May 6, 2023

Copy link
Copy Markdown
Contributor

closes: #29858

Using REST API to render DAG Code in the grid view as a tab when a user has no tasks selected.

image


^ 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.rst or {issue_number}.significant.rst, in newsfragments.

@boring-cyborg boring-cyborg Bot added area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues labels May 6, 2023
@tquazi
tquazi force-pushed the grid_view_dag_code branch from 5b643c6 to b84f0c0 Compare May 7, 2023 03:24
@tquazi
tquazi force-pushed the grid_view_dag_code branch from b84f0c0 to 95c0755 Compare May 8, 2023 00:48

@bbovenzi bbovenzi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking good!

Few comments:

  • Let's move the API logic to react-query and then add some basic handling for loading+error states
  • Maybe bump the font-size down? It's quite a bit larger than the rest of the grid view text

Comment thread airflow/www/static/js/dag/details/dagCode/index.tsx Outdated
Comment thread airflow/www/static/js/dag/details/dagCode/CodeBlock.tsx Outdated
@bbovenzi bbovenzi added this to the Airflow 2.7.0 milestone May 8, 2023
@tquazi

tquazi commented May 12, 2023

Copy link
Copy Markdown
Contributor Author
  • Maybe bump the font-size down? It's quite a bit larger than the rest of the grid view text

I have reduced the font size to 13.5px. Please have a look and let me know if it looks OK.

@tquazi
tquazi requested a review from bbovenzi May 12, 2023 00:58

@bbovenzi bbovenzi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking better! Left a few suggestions.

Comment thread airflow/www/static/js/dag/details/dagCode/CodeBlock.tsx Outdated
Comment thread airflow/www/static/js/api/useDagCode.ts Outdated
Comment thread airflow/www/static/js/dag/details/dagCode/index.tsx Outdated
Comment thread airflow/www/static/js/api/useDagCode.ts Outdated
@tquazi
tquazi requested a review from bbovenzi May 17, 2023 14:22

@bbovenzi bbovenzi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I added a commit to clean up our API requests. react-query is really cool, it handles most of this logic for us so we don't need to manage loading, errors, or any state and effects ourselves.
A general rule, if you're updating state inside of useEffect you're probably doing something wrong. I catch myself doing that too.

@bbovenzi
bbovenzi merged commit 4beb899 into apache:main May 17, 2023
@eladkal eladkal added the type:new-feature Changelog: New Features label Jun 8, 2023
@hduong-mwam

Copy link
Copy Markdown
Contributor

Hi, when the user modify the DAG code, is there a way refetch of the new updated code without performing a page refresh?

The question arise when I'm working on implementing the XCom tab in grid view (issue) - which suffers from the same behaviour of not refetching when say a new run occurs and XCom changes.

Thoughts on either a button to refetch or refetch on mount?

@bbovenzi

Copy link
Copy Markdown
Contributor

I would prefer to keep it to a page refetch since changing the DAG code because we're reparsing the dag and those changes could affect any number of ways we render the entire DAG page.

In your PR, isn't an xcom connected to a specific dag run so selecting a new run would then cause another request to the API?

@hduong-mwam

Copy link
Copy Markdown
Contributor

I made this comment before I fully completed my XCom tab PR. So, I agree that probably best to keep the page refresh for DAG code as there isn't a good "event" that we can use as trigger for code refresh.

Originally in my PR, I had a problem where a new try on the same run occurred (e.g., the XCom producing task is cleared) and XCom is not refetched unless the page refreshes. I fixed this by including the tryNumber in the react query key.

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

Labels

area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues type:new-feature Changelog: New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate DAG Code page to Grid Details

4 participants