-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce ground work for
ExecutionMode.AIRFLOW_ASYNC
(#1224)
This PR is the groundwork for the implementation of `ExecutionMode.AIRFLOW_ASYNC` (#1120), which - once all other epic tasks are completed - will enable asynchronous execution of dbt resources using Apache Airflow’s deferrable operators. As part of this work, this PR introduces a new option to the enum `ExecutionMode` : `AIRFLOW_ASYNC`. When this execution mode is used, Cosmos now creates a setup task that will pre-compile the dbt project SQL and make it available to the remaining dbt tasks. This PR, however, does not yet leverage Airflow's deferrable operators. If users use `ExecutionMode.AIRFLOW_ASYNC` they will actually be running `ExecutionMode.LOCAL` operators with this change. The PR (#1230) has a first experimental version of using deferrable operators for task execution. ## Setup task as the ground work for a new Execution Mode: `ExecutionMode.AIRFLOW_ASYNC`: - Adds a new operator, `DbtCompileAirflowAsyncOperator`, as a root task(analogous to a setup task) in the DAG, running the dbt compile command and uploading the compiled SQL files to a remote storage location for subsequent tasks that fetch these compiled SQL files from the remote storage and run them asynchronously using Airflow's deferrable operators. ## Airflow Configurations: - `remote_target_path`: Introduces a configurable path to store dbt-generated files remotely, supporting any storage scheme that works with Airflow’s Object Store (e.g., S3, GCS, Azure Blob). - `remote_target_path_conn_id`: Allows specifying a custom connection ID for the remote target path, defaulting to the scheme’s associated Airflow connection if not set. ## Example DAG for CI Testing: Introduces an example DAG (`simple_dag_async.py`) demonstrating how to use the new execution mode(The execution like mentioned earlier would still run like Execution Mode LOCAL operators at the moment with this PR alone) This DAG is integrated into the CI pipeline to run integration tests and aims at verifying the functionality of the `ExecutionMode.AIRFLOW_ASYNC` as and when implementation gets added starting with the experimental implementation in #1230 . ## Unit & Integration Tests: - Adds comprehensive unit and integration tests to ensure correct behavior. - Tests include validation for successful uploads, error handling for misconfigured remote paths, and scenarios where `remote_target_path` are not set. ## Documentation: - Adds detailed documentation explaining how to configure and set the `ExecutionMode.AIRFLOW_ASYNC`. ## Scope & Limitations of the feature being introduced: 1. This feature is meant to be released as Experimental and is also marked so in the documentation. 2. Currently, it has been scoped for only dbt models to be executed asynchronously (being worked upon in PR #1230), while other resource types would be run synchronously. 3. `BigQuery` will be the only supported target database for this execution mode ((being worked upon in PR #1230). Thus, this PR enhances Cosmos by providing the ground work for more efficient execution of long-running dbt resources ## Additional Notes: - This feature is planned to be introduced in Cosmos v1.7.0. related: #1134
- Loading branch information
1 parent
741c2eb
commit 879b1a3
Showing
15 changed files
with
575 additions
and
6 deletions.
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,67 @@ | ||
from cosmos.operators.local import ( | ||
DbtBuildLocalOperator, | ||
DbtCompileLocalOperator, | ||
DbtDocsAzureStorageLocalOperator, | ||
DbtDocsGCSLocalOperator, | ||
DbtDocsLocalOperator, | ||
DbtDocsS3LocalOperator, | ||
DbtLSLocalOperator, | ||
DbtRunLocalOperator, | ||
DbtRunOperationLocalOperator, | ||
DbtSeedLocalOperator, | ||
DbtSnapshotLocalOperator, | ||
DbtSourceLocalOperator, | ||
DbtTestLocalOperator, | ||
) | ||
|
||
|
||
class DbtBuildAirflowAsyncOperator(DbtBuildLocalOperator): | ||
pass | ||
|
||
|
||
class DbtLSAirflowAsyncOperator(DbtLSLocalOperator): | ||
pass | ||
|
||
|
||
class DbtSeedAirflowAsyncOperator(DbtSeedLocalOperator): | ||
pass | ||
|
||
|
||
class DbtSnapshotAirflowAsyncOperator(DbtSnapshotLocalOperator): | ||
pass | ||
|
||
|
||
class DbtSourceAirflowAsyncOperator(DbtSourceLocalOperator): | ||
pass | ||
|
||
|
||
class DbtRunAirflowAsyncOperator(DbtRunLocalOperator): | ||
pass | ||
|
||
|
||
class DbtTestAirflowAsyncOperator(DbtTestLocalOperator): | ||
pass | ||
|
||
|
||
class DbtRunOperationAirflowAsyncOperator(DbtRunOperationLocalOperator): | ||
pass | ||
|
||
|
||
class DbtDocsAirflowAsyncOperator(DbtDocsLocalOperator): | ||
pass | ||
|
||
|
||
class DbtDocsS3AirflowAsyncOperator(DbtDocsS3LocalOperator): | ||
pass | ||
|
||
|
||
class DbtDocsAzureStorageAirflowAsyncOperator(DbtDocsAzureStorageLocalOperator): | ||
pass | ||
|
||
|
||
class DbtDocsGCSAirflowAsyncOperator(DbtDocsGCSLocalOperator): | ||
pass | ||
|
||
|
||
class DbtCompileAirflowAsyncOperator(DbtCompileLocalOperator): | ||
pass |
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
Oops, something went wrong.