Skip to content

Add DAG calendar view endpoint #52748

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

Merged
merged 7 commits into from
Jul 7, 2025

Conversation

SavingFrame
Copy link
Contributor

Hello everyone!

This PR adds a new DAG calendar view endpoint that provides scheduling information in a calendar format. This endpoint returns the calendar that existed in Airflow 2.x but provides additional functionality. The new endpoint includes filtering by logical_date and the ability to choose granularity, allowing users to customize their calendar view based on specific time periods and detail levels.

Changes in this PR:

  • Create service file that processes historical DagRuns and presumes queued runs
  • Add UI endpoint
  • Update Swagger documentation
  • Add tests for different options of this endpoint

How was this patch tested?

  • Added comprehensive unit tests for the calendar endpoint
  • Tests cover various scenarios including date filtering, granularity options, and DAG selection
  • All existing tests continue to pass
  • Static code checks and pre-commit hooks pass

API Details

Endpoint: GET /ui/calendar/{dag_id}

Path Parameters:

  • dag_id (string, required): The DAG ID

Query Parameters:

  • granularity (string, optional): Time granularity - "hourly" or "daily" (default: "daily")
  • logical_date_gte (datetime, optional): Start date for filtering (ISO 8601 format)
  • logical_date_lte (datetime, optional): End date for filtering (ISO 8601 format)

Response Format:
Returns an array of CalendarTimeRangeResult objects with the following structure:

[
  {
    "datetime": "2024-01-15 00:00:00",
    "state": "success",
    "count": 5
  },
  {
    "datetime": "2024-01-15 00:00:00",
    "state": "running",
    "count": 2
  },
  {
    "datetime": "2024-01-16 00:00:00",
    "state": "planned",
    "count": 7
  }
]

Response Fields:

  • datetime: The timestamp for the calendar entry
  • state: Task state - one of "queued", "running", "success", "failed", or "planned"
  • count: Number of task instances in this state at the given time

Related Links

Copy link

boring-cyborg bot commented Jul 2, 2025

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 Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.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: [email protected]
    Slack: https://s.apache.org/airflow-slack

@SavingFrame SavingFrame force-pushed the dag-calendar-view branch 2 times, most recently from 3e46032 to 6e8c482 Compare July 3, 2025 10:12
Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

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

Nice, thanks for the pull request.

A few suggestions

Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

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

Just a couple of Nit.

Thanks for the PR, I think it's a good start to iterate on. Since it's a UI endpoint we are free to modify this as we see fit.

SavingFrame and others added 7 commits July 4, 2025 15:19
Implement calendar view functionality that provides DAG scheduling
information in a calendar format.
The endpoint allows users to visualize DAG schedules and execution
patterns over time, improving workflow management and scheduling
oversight.
In case if you want get get data for several days you can use daily
granularity.
Change calendar endpoint to return structured response with total count
and dag runs array instead of flat list for better API consistency.
Update calendar API to return consistent ISO 8601 datetime format with
UTC timezone suffix across all database dialects and remove timezone
stripping.
@SavingFrame
Copy link
Contributor Author

Just a couple of Nit.

Thanks for the PR, I think it's a good start to iterate on. Since it's a UI endpoint we are free to modify this as we see fit.

Thank you. Everything is fixed.

@pierrejeambrun pierrejeambrun merged commit 90e638b into apache:main Jul 7, 2025
102 checks passed
Copy link

boring-cyborg bot commented Jul 7, 2025

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

@pierrejeambrun
Copy link
Member

#protm

@bbovenzi
Copy link
Contributor

bbovenzi commented Jul 8, 2025

Great work! As I said in another thread, I love the hourly or daily granularity. I'm excited to make both a monthly and a weekly calendar view.

HsiuChuanHsu pushed a commit to HsiuChuanHsu/airflow that referenced this pull request Jul 10, 2025
* Add DAG calendar view endpoint

Implement calendar view functionality that provides DAG scheduling
information in a calendar format.
The endpoint allows users to visualize DAG schedules and execution
patterns over time, improving workflow management and scheduling
oversight.
In case if you want get get data for several days you can use daily
granularity.

* restructure calendar response format

Change calendar endpoint to return structured response with total count
and dag runs array instead of flat list for better API consistency.

* Update swagger documentation

* standardize calendar datetime format to ISO 8601 with UTC

Update calendar API to return consistent ISO 8601 datetime format with
UTC timezone suffix across all database dialects and remove timezone
stripping.

* Update airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/calendar.py

Co-authored-by: Pierre Jeambrun <[email protected]>

* Update airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/calendar.py

Co-authored-by: Pierre Jeambrun <[email protected]>

* Rename pydantic models

---------

Co-authored-by: Pierre Jeambrun <[email protected]>
stephen-bracken pushed a commit to stephen-bracken/airflow that referenced this pull request Jul 15, 2025
* Add DAG calendar view endpoint

Implement calendar view functionality that provides DAG scheduling
information in a calendar format.
The endpoint allows users to visualize DAG schedules and execution
patterns over time, improving workflow management and scheduling
oversight.
In case if you want get get data for several days you can use daily
granularity.

* restructure calendar response format

Change calendar endpoint to return structured response with total count
and dag runs array instead of flat list for better API consistency.

* Update swagger documentation

* standardize calendar datetime format to ISO 8601 with UTC

Update calendar API to return consistent ISO 8601 datetime format with
UTC timezone suffix across all database dialects and remove timezone
stripping.

* Update airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/calendar.py

Co-authored-by: Pierre Jeambrun <[email protected]>

* Update airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/calendar.py

Co-authored-by: Pierre Jeambrun <[email protected]>

* Rename pydantic models

---------

Co-authored-by: Pierre Jeambrun <[email protected]>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants