Skip to content

Commit 56c1242

Browse files
authored
Update Python Client to 3.0.0 (#128)
This brings in the new Airflow API v2 to the Python client As part of this change the following breaking changes have occurred: - The API returns 422 status code instead of 400 for validation errors. For instance when the request payload, path params, or query params are invalid. - When listing a resource for instance on GET ``/dags``, ``fields`` parameter is not supported anymore to obtain a partial response. The full objects will be returned by the endpoint. This feature might be added back in upcoming 3.x versions. - Passing list in query parameters switched from ``form, non exploded`` to ``form, exploded`` i.e before ``?my_list=item1,item2`` now ``?my_list=item1&my_list=item2`` - ``execution_date`` was deprecated and has been removed. Any payload or parameter mentioning this field has been removed. - Datetime format are RFC3339-compliant in FastAPI, more permissive than ISO8601, meaning that the API returns zulu datetime for responses, more info here fastapi/fastapi#7693 (comment). Both ``Z`` and ``00+xx`` are supported for payload and params. This is due FastAPI and pydantic v2 default behavior. - PATCH on ``DagRun`` and ``TaskInstance`` are more generic and allow in addition to update the resource state and the note content. Therefore the two legacy dedicated endpoints to update a ``DagRun`` note and ``TaskInstance`` note have been removed. Same for the set task instance state, it is now handled by the broader PATCH on task instances. - ``assets/queuedEvent`` endpoints have moved to ``assets/queuedEvents`` for consistency. - dag_parsing endpoint now returns a 409 when the DagPriorityParsingRequest already exists. It was returning 201 before. - ``clearTaskInstances`` endpoint default value for ``reset_dag_runs`` field has been updated from ``False`` to ``True``. - Pool name can't be modified in the PATCH pool endpoint anymore. Pool name shouldn't be updated via pool PATCH API call. - Logical date is now a nullable. In addition it is a nullable required payload field for Triggering a DagRun endpoint.
1 parent 4bd5b25 commit 56c1242

File tree

873 files changed

+77611
-69438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

873 files changed

+77611
-69438
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Python
1616
uses: actions/setup-python@v5
1717
with:
18-
python-version: 3.8
18+
python-version: 3.9
1919
cache: 'pip'
2020
- name: Install hatch
2121
run: |

CHANGELOG.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,58 @@
1717
under the License.
1818
-->
1919

20+
# v3.0.0
21+
22+
This is the first release of the **Airflow 3.0.0** Python client. It introduces compatibility with the new [Airflow 3.0 REST API](https://airflow.apache.org/docs/apache-airflow/3.0.0/stable-rest-api-ref.html), and includes several **breaking changes** and behavior updates.
23+
24+
Below is a list of important changes. Refer to individual endpoint documentation for full details.
25+
26+
- API v1 (`/api/v1`) has been dropped and replaced with API v2(`/api/v2`).
27+
28+
- **422 Validation Errors (instead of 400)**
29+
30+
The API now returns `422 Unprocessable Entity` for validation errors (e.g. bad payload, path params, or query params), instead of `400 Bad Request`.
31+
32+
- **Partial response support removed (`fields` parameter)**
33+
34+
Endpoints like `GET /dags` no longer support the `fields` query param for partial responses. Full objects are returned by default. This feature may return in a future 3.x release.
35+
36+
- Passing list in query parameters switched from ``form, non exploded`` to ``form, exploded`` i.e before ``?my_list=item1,item2`` now ``?my_list=item1&my_list=item2``
37+
38+
- **`execution_date` has been removed**
39+
40+
The previously deprecated `execution_date` parameter and fields are now fully removed. Use `logical_date` instead.
41+
42+
- **Datetime format updated to RFC3339-compliant**
43+
44+
Datetimes returned are now in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339) format (e.g. `2024-10-01T13:00:00Z`). Both `Z` and `+00:00` forms are accepted in inputs.
45+
→ This change comes from FastAPI & Pydantic v2 behavior.
46+
[More info](https://github.com/fastapi/fastapi/discussions/7693#discussioncomment-5143311)
47+
48+
- PATCH on ``DagRun`` and ``TaskInstance`` are more generic and allow in addition to update the resource state and the note content.
49+
50+
Therefore, the two legacy dedicated endpoints to update a ``DagRun`` note and ``TaskInstance`` note have been removed.
51+
52+
Same for the set task instance state, it is now handled by the broader PATCH on task instances.
53+
54+
- ``assets/queuedEvent`` endpoints have moved to ``assets/queuedEvents`` for consistency.
55+
56+
- **`dag_parsing` returns 409 for duplicates**
57+
58+
If a `DagPriorityParsingRequest` already exists, `POST /dag_parsing` now returns `409 Conflict` instead of `201 Created`.
59+
60+
- **Default value change in `clearTaskInstances`**
61+
62+
The `reset_dag_runs` field now defaults to `true` instead of `false`.
63+
64+
- **Pool name is no longer editable**
65+
66+
`PATCH /pools/{pool_name}` can no longer be used to rename a pool. Pool names are immutable via the API.
67+
68+
- **`logical_date` is now a required nullable field**
69+
70+
When triggering a DAG run (`POST /dags/{dag_id}/dagRuns`), `logical_date` is now required but can explicitly be set to `null`.
71+
2072
# v2.10.0
2173

2274
## Major changes:

INSTALL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# INSTALL / BUILD instructions for Apache Airflow Python Client
22

3-
This ia a generic installation method that requires a number of dependencies to be installed.
3+
This is a generic installation method that requires a number of dependencies to be installed.
44

55
Depending on your system you might need different prerequisites, but the Python3.6 or above is a must.
66

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ The text of each license is also included at licenses/LICENSE-[project].txt.
247247

248248
(BSD 3 License) d3 v5.16.0 (https://d3js.org)
249249
(BSD 3 License) d3-shape v2.1.0 (https://github.com/d3/d3-shape)
250-
(BSD 3 License) cgroupspy 0.2.1 (https://github.com/cloudsigma/cgroupspy)
251250

252251
========================================================================
253252
See licenses/LICENSES-ui.txt for packages used in `/airflow/www`

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ If you want to check which auth backend is currently set, you can use
182182

183183
```bash
184184
$ airflow config get-value api auth_backends
185-
airflow.api.auth.backend.basic_auth
185+
airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
186186
```
187187

188188
The default is to deny all requests.
@@ -248,7 +248,7 @@ For more information, please visit [https://airflow.apache.org](https://airflow.
248248

249249
## Requirements.
250250

251-
Python >=3.8
251+
Python >=3.9
252252

253253
## Installation & Usage
254254

@@ -282,7 +282,7 @@ Please follow the [installation procedure](#installation--usage) and then run th
282282

283283
```python
284284
import time
285-
from airflow_client import client
285+
import airflow_client.client
286286
from pprint import pprint
287287
from airflow_client.client.api import config_api
288288
from airflow_client.client.model.config import Config
@@ -343,15 +343,15 @@ Class | Method | HTTP request | Description
343343
*DAGRunApi* | [**get_dag_run**](docs/DAGRunApi.md#get_dag_run) | **GET** /dags/{dag_id}/dagRuns/{dag_run_id} | Get a DAG run
344344
*DAGRunApi* | [**get_dag_runs**](docs/DAGRunApi.md#get_dag_runs) | **GET** /dags/{dag_id}/dagRuns | List DAG runs
345345
*DAGRunApi* | [**get_dag_runs_batch**](docs/DAGRunApi.md#get_dag_runs_batch) | **POST** /dags/~/dagRuns/list | List DAG runs (batch)
346-
*DAGRunApi* | [**get_upstream_dataset_events**](docs/DAGRunApi.md#get_upstream_dataset_events) | **GET** /dags/{dag_id}/dagRuns/{dag_run_id}/upstreamDatasetEvents | Get dataset events for a DAG run
346+
*DAGRunApi* | [**get_upstream_asset_events**](docs/DAGRunApi.md#get_upstream_asset_events) | **GET** /dags/{dag_id}/dagRuns/{dag_run_id}/upstreamAssetEvents | Get asset events for a DAG run
347347
*DAGRunApi* | [**post_dag_run**](docs/DAGRunApi.md#post_dag_run) | **POST** /dags/{dag_id}/dagRuns | Trigger a new DAG run
348348
*DAGRunApi* | [**set_dag_run_note**](docs/DAGRunApi.md#set_dag_run_note) | **PATCH** /dags/{dag_id}/dagRuns/{dag_run_id}/setNote | Update the DagRun note.
349349
*DAGRunApi* | [**update_dag_run_state**](docs/DAGRunApi.md#update_dag_run_state) | **PATCH** /dags/{dag_id}/dagRuns/{dag_run_id} | Modify a DAG run
350350
*DagWarningApi* | [**get_dag_warnings**](docs/DagWarningApi.md#get_dag_warnings) | **GET** /dagWarnings | List dag warnings
351-
*DatasetApi* | [**get_dataset**](docs/DatasetApi.md#get_dataset) | **GET** /datasets/{uri} | Get a dataset
352-
*DatasetApi* | [**get_dataset_events**](docs/DatasetApi.md#get_dataset_events) | **GET** /datasets/events | Get dataset events
353-
*DatasetApi* | [**get_datasets**](docs/DatasetApi.md#get_datasets) | **GET** /datasets | List datasets
354-
*DatasetApi* | [**get_upstream_dataset_events**](docs/DatasetApi.md#get_upstream_dataset_events) | **GET** /dags/{dag_id}/dagRuns/{dag_run_id}/upstreamDatasetEvents | Get dataset events for a DAG run
351+
*AssetApi* | [**get_asset**](docs/DatasetApi.md#get_asset) | **GET** /assets/{uri} | Get an asset
352+
*AssetApi* | [**get_asset_events**](docs/DatasetApi.md#get_asset_events) | **GET** /assets/events | Get asset events
353+
*DatasetApi* | [**get_assets**](docs/DatasetApi.md#get_assets) | **GET** /assets | List assets
354+
*DatasetApi* | [**get_upstream_asset_events**](docs/DatasetApi.md#get_upstream_asset_events) | **GET** /dags/{dag_id}/dagRuns/{dag_run_id}/upstreamAssetEvents | Get dataset events for a DAG run
355355
*EventLogApi* | [**get_event_log**](docs/EventLogApi.md#get_event_log) | **GET** /eventLogs/{event_log_id} | Get a log entry
356356
*EventLogApi* | [**get_event_logs**](docs/EventLogApi.md#get_event_logs) | **GET** /eventLogs | List log entries
357357
*ImportErrorApi* | [**get_import_error**](docs/ImportErrorApi.md#get_import_error) | **GET** /importErrors/{import_error_id} | Get an import error
@@ -402,6 +402,11 @@ Class | Method | HTTP request | Description
402402
- [ActionCollection](docs/ActionCollection.md)
403403
- [ActionCollectionAllOf](docs/ActionCollectionAllOf.md)
404404
- [ActionResource](docs/ActionResource.md)
405+
- [AssetCollection](docs/AssetCollection.md)
406+
- [AssetCollectionAllOf](docs/AssetCollectionAllOf.md)
407+
- [AssetEvent](docs/AssetEvent.md)
408+
- [AssetEventCollection](docs/AssetEventCollection.md)
409+
- [AssetEventCollectionAllOf](docs/AssetEventCollectionAllOf.md)
405410
- [BasicDAGRun](docs/BasicDAGRun.md)
406411
- [ClassReference](docs/ClassReference.md)
407412
- [ClearDagRun](docs/ClearDagRun.md)
@@ -426,17 +431,12 @@ Class | Method | HTTP request | Description
426431
- [DAGRun](docs/DAGRun.md)
427432
- [DAGRunCollection](docs/DAGRunCollection.md)
428433
- [DAGRunCollectionAllOf](docs/DAGRunCollectionAllOf.md)
429-
- [DagScheduleDatasetReference](docs/DagScheduleDatasetReference.md)
434+
- [DagScheduleAssetReference](docs/DagScheduleAssetReference.md)
430435
- [DagState](docs/DagState.md)
431436
- [DagWarning](docs/DagWarning.md)
432437
- [DagWarningCollection](docs/DagWarningCollection.md)
433438
- [DagWarningCollectionAllOf](docs/DagWarningCollectionAllOf.md)
434439
- [Dataset](docs/Dataset.md)
435-
- [DatasetCollection](docs/DatasetCollection.md)
436-
- [DatasetCollectionAllOf](docs/DatasetCollectionAllOf.md)
437-
- [DatasetEvent](docs/DatasetEvent.md)
438-
- [DatasetEventCollection](docs/DatasetEventCollection.md)
439-
- [DatasetEventCollectionAllOf](docs/DatasetEventCollectionAllOf.md)
440440
- [Error](docs/Error.md)
441441
- [EventLog](docs/EventLog.md)
442442
- [EventLogCollection](docs/EventLogCollection.md)
@@ -481,7 +481,7 @@ Class | Method | HTTP request | Description
481481
- [TaskInstanceCollectionAllOf](docs/TaskInstanceCollectionAllOf.md)
482482
- [TaskInstanceReference](docs/TaskInstanceReference.md)
483483
- [TaskInstanceReferenceCollection](docs/TaskInstanceReferenceCollection.md)
484-
- [TaskOutletDatasetReference](docs/TaskOutletDatasetReference.md)
484+
- [TaskOutletAssetReference](docs/TaskOutletAssetReference.md)
485485
- [TaskState](docs/TaskState.md)
486486
- [TimeDelta](docs/TimeDelta.md)
487487
- [Trigger](docs/Trigger.md)
@@ -534,11 +534,11 @@ that uses the API to run the tests. To do that, you need to:
534534

535535
```ini
536536
[api]
537-
auth_backend = airflow.api.auth.backend.session,airflow.api.auth.backend.basic_auth
537+
auth_backend = airflow.providers.fab.auth_manager.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
538538
```
539539

540540
You can also set it by env variable:
541-
`export AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.session,airflow.api.auth.backend.basic_auth`
541+
`export AIRFLOW__API__AUTH_BACKENDS=airflow.providers.fab.auth_manager.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth`
542542

543543
* configure your airflow webserver to load example dags
544544
In the `[core]` section of your `airflow.cfg` set:
@@ -555,11 +555,11 @@ You can also set it by env variable: `export AIRFLOW__CORE__LOAD_EXAMPLES=True`
555555
In the `[webserver]` section of your `airflow.cfg` set:
556556

557557
```ini
558-
[webserver]
558+
[api]
559559
expose_config = True
560560
```
561561

562-
You can also set it by env variable: `export AIRFLOW__WEBSERVER__EXPOSE_CONFIG=True`
562+
You can also set it by env variable: `export AIRFLOW__API__EXPOSE_CONFIG=True`
563563

564564
* Configure your host/ip/user/password in the `test_python_client.py` file
565565

0 commit comments

Comments
 (0)