dataset.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing,
  12. # software distributed under the License is distributed on an
  13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. # KIND, either express or implied. See the License for the
  15. # specific language governing permissions and limitations
  16. # under the License.
  17. from datetime import datetime
  18. from typing import List, Optional
  19. from airflow.utils.pydantic import BaseModel as BaseModelPydantic, ConfigDict
  20. class DagScheduleDatasetReferencePydantic(BaseModelPydantic):
  21. """Serializable version of the DagScheduleDatasetReference ORM SqlAlchemyModel used by internal API."""
  22. dataset_id: int
  23. dag_id: str
  24. created_at: datetime
  25. updated_at: datetime
  26. model_config = ConfigDict(from_attributes=True)
  27. class TaskOutletDatasetReferencePydantic(BaseModelPydantic):
  28. """Serializable version of the TaskOutletDatasetReference ORM SqlAlchemyModel used by internal API."""
  29. dataset_id: int
  30. dag_id: str
  31. task_id: str
  32. created_at: datetime
  33. updated_at: datetime
  34. model_config = ConfigDict(from_attributes=True)
  35. class DatasetPydantic(BaseModelPydantic):
  36. """Serializable representation of the Dataset ORM SqlAlchemyModel used by internal API."""
  37. id: int
  38. uri: str
  39. extra: Optional[dict]
  40. created_at: datetime
  41. updated_at: datetime
  42. is_orphaned: bool
  43. consuming_dags: List[DagScheduleDatasetReferencePydantic]
  44. producing_tasks: List[TaskOutletDatasetReferencePydantic]
  45. model_config = ConfigDict(from_attributes=True)
  46. class DatasetEventPydantic(BaseModelPydantic):
  47. """Serializable representation of the DatasetEvent ORM SqlAlchemyModel used by internal API."""
  48. id: int
  49. dataset_id: Optional[int]
  50. extra: dict
  51. source_task_id: Optional[str]
  52. source_dag_id: Optional[str]
  53. source_run_id: Optional[str]
  54. source_map_index: Optional[int]
  55. timestamp: datetime
  56. dataset: Optional[DatasetPydantic]
  57. model_config = ConfigDict(from_attributes=True, arbitrary_types_allowed=True)