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

Adding only_active parameter to /dags endpoint #14306

Merged
merged 10 commits into from Jun 14, 2021

Conversation

SamWheating
Copy link
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
airflow/api_connexion/openapi/v1.yaml Outdated Show resolved Hide resolved
airflow/api_connexion/openapi/v1.yaml Outdated Show resolved Hide resolved
@SamWheating
Copy link
Contributor Author

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

@ephraimbuddy
Copy link
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

@github-actions
Copy link

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

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

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*.

airflow/api_connexion/endpoints/dag_endpoint.py Outdated Show resolved Hide resolved
airflow/api_connexion/endpoints/dag_endpoint.py Outdated Show resolved Hide resolved
airflow/api_connexion/openapi/v1.yaml Outdated Show resolved Hide resolved
airflow/models/dag.py Show resolved Hide resolved
airflow/api_connexion/openapi/v1.yaml Show resolved Hide resolved
airflow/api_connexion/openapi/v1.yaml Outdated Show resolved Hide resolved
airflow/api_connexion/schemas/dag_schema.py Show resolved Hide resolved
@kaxil kaxil requested a review from ashb February 21, 2021 01:18
@kaxil kaxil added this to the Airflow 2.0.2 milestone Feb 23, 2021
@kaxil
Copy link
Member

kaxil commented Feb 25, 2021

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

@SamWheating
Copy link
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
Copy link

github-actions bot commented Mar 8, 2021

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

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
Copy link
Member

ashb commented Mar 24, 2021

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 modified the milestones: Airflow 2.0.2, Airflow 2.0.3 Apr 22, 2021
@ashb ashb modified the milestones: Airflow 2.0.3, Airflow 2.1.1 May 7, 2021
@SamWheating
Copy link
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
Copy link
Member

XD-DENG commented Jun 7, 2021

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
Copy link
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?

Copy link
Member

@ashb ashb left a comment

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

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
Copy link
Member

kaxil commented Jun 10, 2021

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

@SamWheating
Copy link
Contributor Author

SamWheating commented Jun 10, 2021

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
Copy link
Contributor Author

SamWheating commented Jun 11, 2021

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.

None yet

6 participants