|
54 | 54 | from airflow.sdk.definitions.context import Context
|
55 | 55 | from airflow.typing_compat import Self
|
56 | 56 |
|
| 57 | + |
| 58 | +class DagFileParseRequest(BaseModel): |
| 59 | + """ |
| 60 | + Request for DAG File Parsing. |
| 61 | +
|
| 62 | + This is the request that the manager will send to the DAG parser with the dag file and |
| 63 | + any other necessary metadata. |
| 64 | + """ |
| 65 | + |
| 66 | + file: str |
| 67 | + |
| 68 | + bundle_path: Path |
| 69 | + """Passing bundle path around lets us figure out relative file path.""" |
| 70 | + |
| 71 | + requests_fd: int |
| 72 | + callback_requests: list[CallbackRequest] = Field(default_factory=list) |
| 73 | + type: Literal["DagFileParseRequest"] = "DagFileParseRequest" |
| 74 | + |
| 75 | + |
| 76 | +class DagFileParsingResult(BaseModel): |
| 77 | + """ |
| 78 | + Result of DAG File Parsing. |
| 79 | +
|
| 80 | + This is the result of a successful DAG parse, in this class, we gather all serialized DAGs, |
| 81 | + import errors and warnings to send back to the scheduler to store in the DB. |
| 82 | + """ |
| 83 | + |
| 84 | + fileloc: str |
| 85 | + serialized_dags: list[LazyDeserializedDAG] |
| 86 | + warnings: list | None = None |
| 87 | + import_errors: dict[str, str] | None = None |
| 88 | + type: Literal["DagFileParsingResult"] = "DagFileParsingResult" |
| 89 | + |
| 90 | + |
57 | 91 | ToManager = Annotated[
|
58 |
| - Union["DagFileParsingResult", GetConnection, GetVariable, PutVariable, DeleteVariable], |
| 92 | + Union[DagFileParsingResult, GetConnection, GetVariable, PutVariable, DeleteVariable], |
59 | 93 | Field(discriminator="type"),
|
60 | 94 | ]
|
61 | 95 |
|
62 | 96 | ToDagProcessor = Annotated[
|
63 |
| - Union["DagFileParseRequest", ConnectionResult, VariableResult, ErrorResponse, OKResponse], |
| 97 | + Union[DagFileParseRequest, ConnectionResult, VariableResult, ErrorResponse, OKResponse], |
64 | 98 | Field(discriminator="type"),
|
65 | 99 | ]
|
66 | 100 |
|
@@ -182,39 +216,6 @@ def _execute_dag_callbacks(dagbag: DagBag, request: DagCallbackRequest, log: Fil
|
182 | 216 | Stats.incr("dag.callback_exceptions", tags={"dag_id": request.dag_id})
|
183 | 217 |
|
184 | 218 |
|
185 |
| -class DagFileParseRequest(BaseModel): |
186 |
| - """ |
187 |
| - Request for DAG File Parsing. |
188 |
| -
|
189 |
| - This is the request that the manager will send to the DAG parser with the dag file and |
190 |
| - any other necessary metadata. |
191 |
| - """ |
192 |
| - |
193 |
| - file: str |
194 |
| - |
195 |
| - bundle_path: Path |
196 |
| - """Passing bundle path around lets us figure out relative file path.""" |
197 |
| - |
198 |
| - requests_fd: int |
199 |
| - callback_requests: list[CallbackRequest] = Field(default_factory=list) |
200 |
| - type: Literal["DagFileParseRequest"] = "DagFileParseRequest" |
201 |
| - |
202 |
| - |
203 |
| -class DagFileParsingResult(BaseModel): |
204 |
| - """ |
205 |
| - Result of DAG File Parsing. |
206 |
| -
|
207 |
| - This is the result of a successful DAG parse, in this class, we gather all serialized DAGs, |
208 |
| - import errors and warnings to send back to the scheduler to store in the DB. |
209 |
| - """ |
210 |
| - |
211 |
| - fileloc: str |
212 |
| - serialized_dags: list[LazyDeserializedDAG] |
213 |
| - warnings: list | None = None |
214 |
| - import_errors: dict[str, str] | None = None |
215 |
| - type: Literal["DagFileParsingResult"] = "DagFileParsingResult" |
216 |
| - |
217 |
| - |
218 | 219 | def in_process_api_server() -> InProcessExecutionAPI:
|
219 | 220 | from airflow.api_fastapi.execution_api.app import InProcessExecutionAPI
|
220 | 221 |
|
|
0 commit comments