-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
AIP-84: Migrating GET Dataset events for DAG runs api to fastAPI #43874
Open
amoghrajesh
wants to merge
25
commits into
apache:main
Choose a base branch
from
astronomer:AIP84-get-dataset-events-dagrun
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+698
−1
Open
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
cf5218c
AIP-84: Migrating GET Assets to fastAPI
amoghrajesh 5a49280
matching response to legacy
amoghrajesh 962572b
Adding unit tests - part 1
amoghrajesh 428cb6c
Update airflow/api_fastapi/common/parameters.py
amoghrajesh a78d3cb
fixing the dag_ids filter
amoghrajesh 882d20c
fixing the dag_ids filter
amoghrajesh 25bb08e
Adding unit tests - part 2
amoghrajesh 658479d
Merge branch 'main' into AIP84-get-asset-to-fastapi
amoghrajesh fa0cd23
fixing unit tests & updating parameter type
amoghrajesh dd791c2
review comments pierre
amoghrajesh 06fa0a7
fixing last commit
amoghrajesh 3bd803b
Merge branch 'main' into AIP84-get-asset-to-fastapi
amoghrajesh fc29d7d
Merge branch 'main' into AIP84-get-asset-to-fastapi
amoghrajesh 7a97220
fixing unit tests
amoghrajesh df1ff8e
AIP-84: Migrating GET Dataset events for DAG runs to fastAPI
amoghrajesh 6c80ced
adding test cases
amoghrajesh e344263
adding test cases
amoghrajesh 0df9ebd
Merge branch 'main' into AIP84-get-asset-to-fastapi
amoghrajesh 5fb8bc1
Merge branch 'main' into AIP84-get-asset-to-fastapi
amoghrajesh 6426b0b
Merge branch 'AIP84-get-asset-to-fastapi' into AIP84-get-dataset-even…
amoghrajesh 80c4da0
Merge branch 'main' into AIP84-get-dataset-events-dagrun
amoghrajesh e7b96aa
review comments pierre
amoghrajesh c4d7dfc
fixing unit tests
amoghrajesh e269dd3
Merge branch 'main' into AIP84-get-dataset-events-dagrun
amoghrajesh 0da44d0
review comments pierre
amoghrajesh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from __future__ import annotations | ||
|
||
from datetime import datetime | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class DagScheduleAssetReference(BaseModel): | ||
"""Serializable version of the DagScheduleAssetReference ORM SqlAlchemyModel.""" | ||
|
||
dag_id: str | ||
created_at: datetime | ||
updated_at: datetime | ||
|
||
|
||
class TaskOutletAssetReference(BaseModel): | ||
"""Serializable version of the TaskOutletAssetReference ORM SqlAlchemyModel.""" | ||
|
||
dag_id: str | ||
task_id: str | ||
created_at: datetime | ||
updated_at: datetime | ||
|
||
|
||
class AssetAliasSchema(BaseModel): | ||
"""Serializable version of the AssetAliasSchema ORM SqlAlchemyModel.""" | ||
|
||
id: int | ||
name: str | ||
|
||
|
||
class AssetResponse(BaseModel): | ||
"""Asset serializer for responses.""" | ||
|
||
id: int | ||
uri: str | ||
extra: dict | None = None | ||
created_at: datetime | ||
updated_at: datetime | ||
consuming_dags: list[DagScheduleAssetReference] | ||
producing_tasks: list[TaskOutletAssetReference] | ||
aliases: list[AssetAliasSchema] | ||
|
||
|
||
class AssetCollectionResponse(BaseModel): | ||
"""Asset collection response.""" | ||
|
||
assets: list[AssetResponse] | ||
total_entries: int | ||
|
||
|
||
class DagRunAssetReference(BaseModel): | ||
"""Serializable version of the DagRunAssetReference ORM SqlAlchemyModel.""" | ||
|
||
run_id: str | ||
dag_id: str | ||
execution_date: datetime = Field(alias="logical_date") | ||
start_date: datetime | ||
end_date: datetime | None = None | ||
state: str | ||
data_interval_start: datetime | ||
data_interval_end: datetime | ||
|
||
|
||
class AssetEventResponse(BaseModel): | ||
"""Asset event serializer for responses.""" | ||
|
||
id: int | ||
asset_id: int | ||
# piggyback on the fix for https://github.com/apache/airflow/issues/43845 for asset_uri | ||
# meanwhile, unblock by adding uri below | ||
amoghrajesh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uri: str | ||
extra: dict | None = None | ||
source_task_id: str | None = None | ||
source_dag_id: str | None = None | ||
source_run_id: str | None = None | ||
source_map_index: int | ||
created_dagruns: list[DagRunAssetReference] | ||
timestamp: datetime | ||
|
||
|
||
class AssetEventCollectionResponse(BaseModel): | ||
"""Asset collection response.""" | ||
amoghrajesh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
asset_events: list[AssetEventResponse] | ||
total_entries: int |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no model
DagRunAssetReference
, maybe you meantDagRun
?Maybe:
Also I would remove everywhere the mention of
ORM SqlAlchemyModel
because the serializer can serialize much more than just an SQLAlchemy model. (any arbitrary object with appropriate attributes, a plain dictionnary, etc...).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to:
"""Dag Run Asset Reference serializer for responses."""
and removed reference of ORM.Does this make sense? Or I am open to any other docstring too