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

[API] can return the specified field when get dag/dagRun #36641

Merged
merged 7 commits into from
Jan 14, 2024
Merged

[API] can return the specified field when get dag/dagRun #36641

merged 7 commits into from
Jan 14, 2024

Conversation

HarryWu99
Copy link
Contributor

relate to #29893

Hard to add generic retrieve capability to all get endpoints, so this PR is just add this capability in dag/dag_detail and dagRuns get endpoints, which I think need this capability most.

For example, if call https://airflow.apache.org/api/v1/dags?fields=dag_id,is_paused API, it returns JSON body contains only {dag_id, is_paused} fields.

@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues labels Jan 7, 2024
Copy link

boring-cyborg bot commented Jan 7, 2024

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

Very nice! Indeed that nicely solves the most pressing need of partial retrieval of the DAG / DAGRun.

Can you please add some tests covering this ?

@HarryWu99
Copy link
Contributor Author

Very nice! Indeed that nicely solves the most pressing need of partial retrieval of the DAG / DAGRun.

Can you please add some tests covering this ?

@potiuk Hi! Since I am new to airflow, could you please tell me in a nutshell how the test code works? Does my PR just need to add tests code in tests/api_connexion/endpoints/test_dag_endpoint.py#TestGetDag, TestGetDagDetails etc ?

Do I need to test anything specifically? such as each field be returned correctly?

@potiuk
Copy link
Member

potiuk commented Jan 7, 2024

Very nice! Indeed that nicely solves the most pressing need of partial retrieval of the DAG / DAGRun.
Can you please add some tests covering this ?

@potiuk Hi! Since I am new to airflow, could you please tell me in a nutshell how the test code works? Does my PR just need to add tests code in tests/api_connexion/endpoints/test_dag_endpoint.py#TestGetDag, TestGetDagDetails etc ?

Do I need to test anything specifically? such as each field be returned correctly?

Yes. You should add code there just a few examples testing what happens when you run API call with and without field specieifcation - ideally look at other test cases and write similar tests, this is the easiest way to get started with your tests. Your tests should add a few asserts - that the fields are there when expected and that they aren't there when not expected.

Generally the tests will be executed automatically in CI and all the tests of ours are easily runnable locally. We have various kinds of tests, but the API tests are just standard unit tests and you have all the docs about running tests - both in local venv, IDE and also in breeze (which is 1-1 replica of what happens in CI using docker compose) in https://github.com/apache/airflow/blob/main/TESTING.rst#running-unit-tests - it contains screenshots of how to configure your IDEs etc.

We have also a more generic CONTRIBUTING information https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst how to setup your environment and you will even find QUICK_START quides there specific for popular IDES.

@HarryWu99 HarryWu99 changed the title [API] can return the specified field when get dag/dagRun WIP: [API] can return the specified field when get dag/dagRun Jan 7, 2024
@HarryWu99
Copy link
Contributor Author

@potiuk Hi! I have added some tests to cover this

@HarryWu99 HarryWu99 changed the title WIP: [API] can return the specified field when get dag/dagRun [API] can return the specified field when get dag/dagRun Jan 10, 2024
@eladkal eladkal added this to the Airflow 2.9.0 milestone Jan 10, 2024
@HarryWu99 HarryWu99 requested a review from potiuk January 13, 2024 14:17
@potiuk potiuk merged commit 8767357 into apache:main Jan 14, 2024
51 checks passed
Copy link

boring-cyborg bot commented Jan 14, 2024

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@ephraimbuddy ephraimbuddy added the type:improvement Changelog: Improvements label Feb 19, 2024
abhishekbhakat pushed a commit to abhishekbhakat/my_airflow that referenced this pull request Mar 5, 2024
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 area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues type:improvement Changelog: Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants