Coverage for /home/airflow/.local/lib/python3.12/site-packages/airflow/api_fastapi/core_api/datamodels/backfills.py: 100%

38 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 14:22 +0000

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 

18from __future__ import annotations 

19 

20from collections.abc import Iterable 

21from datetime import datetime 

22 

23from pydantic import AliasPath, Field, NonNegativeInt 

24 

25from airflow.api_fastapi.core_api.base import BaseModel, StrictBaseModel 

26from airflow.models.backfill import ReprocessBehavior 

27 

28 

29class BackfillPostBody(StrictBaseModel): 

30 """Object used for create backfill request.""" 

31 

32 dag_id: str 

33 from_date: datetime 

34 to_date: datetime 

35 run_backwards: bool = False 

36 dag_run_conf: dict | None = None 

37 reprocess_behavior: ReprocessBehavior = ReprocessBehavior.NONE 

38 max_active_runs: int = 10 

39 run_on_latest_version: bool | None = Field( 

40 default=None, 

41 description="Run on the latest bundle version of the Dag for each backfilled run. " 

42 "If not specified, falls back to the DAG-level ``rerun_with_latest_version`` parameter, " 

43 "then the ``[core] rerun_with_latest_version`` config option, " 

44 "and finally ``True`` (the historical default for backfills).", 

45 ) 

46 

47 

48class BackfillResponse(BaseModel): 

49 """Base serializer for Backfill.""" 

50 

51 id: NonNegativeInt 

52 dag_id: str 

53 from_date: datetime 

54 to_date: datetime 

55 dag_run_conf: dict | None 

56 is_paused: bool 

57 reprocess_behavior: ReprocessBehavior 

58 max_active_runs: int 

59 created_at: datetime 

60 completed_at: datetime | None 

61 updated_at: datetime 

62 dag_display_name: str = Field(validation_alias=AliasPath("dag_model", "dag_display_name")) 

63 

64 

65class BackfillCollectionResponse(BaseModel): 

66 """Backfill Collection serializer for responses.""" 

67 

68 backfills: Iterable[BackfillResponse] 

69 total_entries: int 

70 

71 

72class DryRunBackfillResponse(BaseModel): 

73 """Backfill serializer for responses in dry-run mode.""" 

74 

75 logical_date: datetime | None 

76 partition_key: str | None 

77 partition_date: datetime | None 

78 

79 

80class DryRunBackfillCollectionResponse(BaseModel): 

81 """Backfill collection serializer for responses in dry-run mode.""" 

82 

83 backfills: list[DryRunBackfillResponse] 

84 total_entries: int