Skip to content

Commit

Permalink
Add more fields to REST API get DAG(dags/dag_id) endpoint
Browse files Browse the repository at this point in the history
The DagModel columns have increased since this endpoint was created. This PR improves the
endpoint by including all the missing fields of the DagModel on the endpoint.

This update also touched on DAGDetails schema because it inherits from DAGSchema.
In a future PR, when more details would be added to the DAGDetails endpoint, we could
separate it from the DAGSchema. They are related but not really the same. One is a
database object while the other is not
  • Loading branch information
ephraimbuddy committed Mar 31, 2022
1 parent 55ee62e commit 1bfabbc
Show file tree
Hide file tree
Showing 5 changed files with 487 additions and 1 deletion.
128 changes: 128 additions & 0 deletions airflow/api_connexion/openapi/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,58 @@ components:
description: Whether the DAG is SubDAG.
type: boolean
readOnly: true
last_parsed_time:
type: string
format: date-time
readOnly: true
nullable: true
description: |
The last time the DAG was parsed.
*New in version 2.3.0*
last_pickled:
type: string
format: date-time
readOnly: true
nullable: true
description: |
The last time the DAG was pickled.
*New in version 2.3.0*
last_expired:
type: string
format: date-time
readOnly: true
nullable: true
description: |
Time when the DAG last received a refresh signal
(e.g. the DAG's "refresh" button was clicked in the web UI)
*New in version 2.3.0*
scheduler_lock:
type: boolean
readOnly: true
nullable: true
description: |
Whether (one of) the scheduler is scheduling this DAG at the moment
*New in version 2.3.0*
pickle_id:
type: string
readOnly: true
nullable: true
description: |
Foreign key to the latest pickle_id
*New in version 2.3.0*
default_view:
type: string
nullable: true
readOnly: true
description: |
Default view of the DAG inside the webserver
*New in version 2.3.0*
fileloc:
description: The absolute path to the file.
type: string
Expand All @@ -2136,13 +2188,89 @@ components:
describe DAG contents.
schedule_interval:
$ref: '#/components/schemas/ScheduleInterval'
timetable_description:
type: string
readOnly: true
nullable: true
description: |
Timetable/Schedule Interval description.
*New in version 2.3.0*
tags:
description: List of tags.
type: array
nullable: true
items:
$ref: '#/components/schemas/Tag'
readOnly: true
max_active_tasks:
type: integer
nullable: true
readOnly: true
description: |
Maximum number of active tasks that can be run on the DAG
*New in version 2.3.0*
max_active_runs:
type: integer
nullable: true
readOnly: true
description: |
Maximum number of active DAG runs for the DAG
*New in version 2.3.0*
has_task_concurrency_limits:
type: boolean
nullable: true
readOnly: true
description: |
Whether the DAG has task concurrency limits
*New in version 2.3.0*
has_import_errors:
type: boolean
nullable: true
readOnly: true
description: |
Whether the DAG has import errors
*New in version 2.3.0*
next_dagrun:
type: string
format: date-time
readOnly: true
nullable: true
description: |
The logical date of the next dag run.
*New in version 2.3.0*
next_dagrun_data_interval_start:
type: string
format: date-time
readOnly: true
nullable: true
description: |
The start of the interval of the next dag run.
*New in version 2.3.0*
next_dagrun_data_interval_end:
type: string
format: date-time
readOnly: true
nullable: true
description: |
The end of the interval of the next dag run.
*New in version 2.3.0*
next_dagrun_create_after:
type: string
format: date-time
readOnly: true
nullable: true
description: |
Earliest time at which this ``next_dagrun`` can be created.
*New in version 2.3.0*
DAGCollection:
description: |
Expand Down
15 changes: 15 additions & 0 deletions airflow/api_connexion/schemas/dag_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,27 @@ class Meta:
is_paused = auto_field()
is_active = auto_field(dump_only=True)
is_subdag = auto_field(dump_only=True)
last_parsed_time = auto_field(dump_only=True)
last_pickled = auto_field(dump_only=True)
last_expired = auto_field(dump_only=True)
scheduler_lock = auto_field(dump_only=True)
pickle_id = auto_field(dump_only=True)
default_view = auto_field(dump_only=True)
fileloc = auto_field(dump_only=True)
file_token = fields.Method("get_token", dump_only=True)
owners = fields.Method("get_owners", dump_only=True)
description = auto_field(dump_only=True)
schedule_interval = fields.Nested(ScheduleIntervalSchema)
timetable_description = auto_field(dump_only=True)
tags = fields.List(fields.Nested(DagTagSchema), dump_only=True)
max_active_tasks = auto_field(dump_only=True)
max_active_runs = auto_field(dump_only=True)
has_task_concurrency_limits = auto_field(dump_only=True)
has_import_errors = auto_field(dump_only=True)
next_dagrun = auto_field(dump_only=True)
next_dagrun_data_interval_start = auto_field(dump_only=True)
next_dagrun_data_interval_end = auto_field(dump_only=True)
next_dagrun_create_after = auto_field(dump_only=True)

@staticmethod
def get_owners(obj: DagModel):
Expand Down
2 changes: 1 addition & 1 deletion airflow/models/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2689,7 +2689,7 @@ class DagModel(Base):
owners = Column(String(2000))
# Description of the dag
description = Column(Text)
# Default view of the inside the webserver
# Default view of the DAG inside the webserver
default_view = Column(String(25))
# Schedule interval
schedule_interval = Column(Interval)
Expand Down
Loading

0 comments on commit 1bfabbc

Please sign in to comment.