Skip to content

Adding only_active parameter to /dags endpoint - #14306

Merged
kaxil merged 10 commits into
apache:mainfrom
SamWheating:sw-filter-active-get-dags
Jun 14, 2021
Merged

kaxil merged 10 commits into
apache:mainfrom
SamWheating:sw-filter-active-get-dags

Conversation

@SamWheating

Copy link
Copy Markdown
Contributor

I noticed that the /dags endpoint returns information on all entries in the DAG table, which is often many more DAGs than are activeand likely includes DAGs which have been removed from Airflow.

This PR adds a boolean only_active parameter to the /dags endpoint which will then only return active DAGs.

I also noticed that this endpoint was hitting a deprecated codepath by dumping a DAG object to the DAGDetailSchema, thus hitting calling DAG.is_paused() I have updated the schema to call the correct function (DAG.get_is_paused) since I'm assuming the deprecated functions may be removed some day.

@boring-cyborg boring-cyborg Bot added the area:API Airflow's REST/HTTP API label Feb 18, 2021
Comment thread airflow/api_connexion/openapi/v1.yaml Resolved
Comment thread airflow/api_connexion/openapi/v1.yaml Resolved
@SamWheating

Copy link
Copy Markdown
Contributor Author

Looks like I missed updating some Schema tests - I'll push up a fix for this shortly.

@ephraimbuddy

Copy link
Copy Markdown
Contributor

Looks like I missed updating some Schema tests - I'll push up a fix for this shortly.

Not schema test. Linting error. - name is not in line with other parameters

Comment thread airflow/api_connexion/openapi/v1.yaml Resolved
@github-actions

Copy link
Copy Markdown
Contributor

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@github-actions

Copy link
Copy Markdown
Contributor

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@github-actions

Copy link
Copy Markdown
Contributor

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

Comment thread airflow/api_connexion/openapi/v1.yaml Resolved
Comment thread airflow/models/dag.py Resolved
Comment thread airflow/api_connexion/openapi/v1.yaml Resolved
Comment thread airflow/api_connexion/openapi/v1.yaml Resolved
@kaxil
kaxil requested a review from ashb February 21, 2021 01:18
Comment thread airflow/api_connexion/openapi/v1.yaml Resolved
@kaxil kaxil added this to the Airflow 2.0.2 milestone Feb 23, 2021
@kaxil

kaxil commented Feb 25, 2021

Copy link
Copy Markdown
Member

@ephraimbuddy @ashb -- Since you folks requested changes, can you review it once more to see all your concerns are addressed

@SamWheating
SamWheating force-pushed the sw-filter-active-get-dags branch from c569b5e to f6f5801 Compare March 8, 2021 18:44
@SamWheating

Copy link
Copy Markdown
Contributor Author

Just rebased on master and fixed the merge conflicts, I believe I have addressed all of the requested changes now as well.

@github-actions

github-actions Bot commented Mar 8, 2021

Copy link
Copy Markdown
Contributor

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@SamWheating
SamWheating force-pushed the sw-filter-active-get-dags branch from 64d79f8 to a1f8d73 Compare March 24, 2021 15:16
@github-actions

Copy link
Copy Markdown
Contributor

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@ashb

ashb commented Mar 24, 2021

Copy link
Copy Markdown
Member

Code looks fine, but I wonder if we want to rename this now to match the proposed new external names as mentioned in #14459

@ashb ashb added this to the Airflow 2.0.3 milestone Apr 22, 2021
@ashb ashb modified the milestones: Airflow 2.0.3, Airflow 2.1.1 May 7, 2021
@SamWheating
SamWheating force-pushed the sw-filter-active-get-dags branch from 168ccec to 55d3713 Compare May 8, 2021 18:11
@SamWheating

Copy link
Copy Markdown
Contributor Author

Sorry for the long delay, just rebased and this should be good to go now (pending CI).

It looks like #14459 is still under early discussion, so I think we should proceed with these changes and rename fields later as required. Feel free to tag me in an issue if/when you need the wording updated.

@XD-DENG

XD-DENG commented Jun 7, 2021

Copy link
Copy Markdown
Member

Code looks fine, but I wonder if we want to rename this now to match the proposed new external names as mentioned in #14459

Hi @ashb , this issue #14459 (comment) is blocking us progressing on #14459 .

If folks have no clear clue/solution on resolving #14459 (comment), maybe can consider merging this PR first.

@SamWheating
SamWheating force-pushed the sw-filter-active-get-dags branch from 55d3713 to 81d3df6 Compare June 7, 2021 18:52
@SamWheating

Copy link
Copy Markdown
Contributor Author

Alright I've rebased on main and ran the tests locally - Happy to help update this if we change the wording or some field names later on.

Could I get your reviews when you have a chance @ashb @turbaszek?

@ashb ashb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@github-actions

Copy link
Copy Markdown
Contributor

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions Bot added the full tests needed We need to run full set of tests for this PR to merge label Jun 10, 2021
@kaxil

kaxil commented Jun 10, 2021

Copy link
Copy Markdown
Member

@SamWheating can you rebase your PR once more and fix merge conflicts too please

@SamWheating

SamWheating commented Jun 10, 2021 •

Copy link
Copy Markdown
Contributor Author

Ah, looks like the original issue leading to this PR was fixed in #16318, which prevents the API endpoint from ever returning inactive DAGs.

I'll refactor this PR accordingly, but the changes introduced by this PR are now:

  • Expose an only_active parameter on the /dags endpoint (deafult to True)
  • Include is_active and is_paused in the DAG detail schema

Update: I've updated + rebased this PR, should be good to go now.

@SamWheating
SamWheating force-pushed the sw-filter-active-get-dags branch from 81d3df6 to a331f55 Compare June 10, 2021 23:06
@SamWheating

SamWheating commented Jun 11, 2021 •

Copy link
Copy Markdown
Contributor Author

I believe the above test failures are unrelated / transient errors as I was unable to reproduce them locally in breeze.

@kaxil
kaxil merged commit 9526a24 into apache:main Jun 14, 2021
ashb pushed a commit that referenced this pull request Jun 22, 2021
I noticed that the `/dags` endpoint returns information on all entries in the DAG table, which is often many more DAGs than are activeand likely includes DAGs which have been removed from Airflow.

This PR adds a boolean `only_active` parameter to the `/dags` endpoint which will then only return active DAGs.

I also noticed that this endpoint was hitting a deprecated codepath by dumping a `DAG` object to the DAGDetailSchema, thus hitting calling `DAG.is_paused()` I have updated the schema to call the correct function (`DAG.get_is_paused`) since I'm assuming the deprecated functions may be removed some day.

(cherry picked from commit 9526a24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API full tests needed We need to run full set of tests for this PR to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants