Skip to content

Commit

Permalink
Resolve DbtCloudJobRunAsyncSensor deprecation in system tests (apache…
Browse files Browse the repository at this point in the history
…#39525)

* Resolve DbtCloudJobRunAsyncSensor deprecation in system tests

Related: apache#39485

The DbtCloudJobRunAsyncSensor is deprecated in favor of using DbtCloudJobRunSensor with `deferrable=True` set. Removing this sensor from the dbt Cloud system test and updating documentation accordingly.

* Remove dbt Cloud system test from deprecation ignores
  • Loading branch information
josh-fell authored and RodrigoGanancia committed May 10, 2024
1 parent c75bfb0 commit 8de6c72
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
20 changes: 4 additions & 16 deletions docs/apache-airflow-providers-dbt-cloud/operators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,15 @@ the ``account_id`` for the task is referenced within the ``default_args`` of the
:start-after: [START howto_operator_dbt_cloud_run_job_sensor]
:end-before: [END howto_operator_dbt_cloud_run_job_sensor]

Also you can use deferrable mode in this sensor if you would like to free up the worker slots while the sensor is running.
Also, you can poll for status of the job run asynchronously using ``deferrable`` mode. In this mode, worker
slots are freed up while the sensor is running.

.. exampleinclude:: /../../tests/system/providers/dbt/cloud/example_dbt_cloud.py
:language: python
:dedent: 4
:start-after: [START howto_operator_dbt_cloud_run_job_sensor_defered]
:end-before: [END howto_operator_dbt_cloud_run_job_sensor_defered]
:start-after: [START howto_operator_dbt_cloud_run_job_sensor_deferred]
:end-before: [END howto_operator_dbt_cloud_run_job_sensor_deferred]

.. _howto/operator:DbtCloudJobRunAsyncSensor:

Poll for status of a dbt Cloud Job run asynchronously
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. note::
:class:`~airflow.providers.dbt.cloud.sensors.dbt.DbtCloudJobRunAsyncSensor` is deprecated and will be removed in a future release. Please use :class:`~airflow.providers.dbt.cloud.sensors.dbt.DbtCloudJobRunSensor` and use the deferrable mode in that operator.

.. exampleinclude:: /../../tests/system/providers/dbt/cloud/example_dbt_cloud.py
:language: python
:dedent: 4
:start-after: [START howto_operator_dbt_cloud_run_job_async_sensor]
:end-before: [END howto_operator_dbt_cloud_run_job_async_sensor]

.. _howto/operator:DbtCloudGetJobRunArtifactOperator:

Expand Down
1 change: 0 additions & 1 deletion tests/always/test_example_dags.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"tests/system/providers/amazon/aws/example_eks_with_nodegroups.py",
"tests/system/providers/amazon/aws/example_emr.py",
"tests/system/providers/amazon/aws/example_emr_notebook_execution.py",
"tests/system/providers/dbt/cloud/example_dbt_cloud.py",
"tests/system/providers/google/cloud/azure/example_azure_fileshare_to_gcs.py",
"tests/system/providers/google/cloud/bigquery/example_bigquery_operations.py",
"tests/system/providers/google/cloud/bigquery/example_bigquery_sensors.py",
Expand Down
17 changes: 6 additions & 11 deletions tests/system/providers/dbt/cloud/example_dbt_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DbtCloudListJobsOperator,
DbtCloudRunJobOperator,
)
from airflow.providers.dbt.cloud.sensors.dbt import DbtCloudJobRunAsyncSensor, DbtCloudJobRunSensor
from airflow.providers.dbt.cloud.sensors.dbt import DbtCloudJobRunSensor
from airflow.utils.edgemodifier import Label
from tests.system.utils import get_test_env_id

Expand Down Expand Up @@ -72,17 +72,11 @@
)
# [END howto_operator_dbt_cloud_run_job_sensor]

# [START howto_operator_dbt_cloud_run_job_sensor_defered]
job_run_sensor_defered = DbtCloudJobRunSensor(
task_id="job_run_sensor_defered", run_id=trigger_job_run2.output, timeout=20, deferrable=True
# [START howto_operator_dbt_cloud_run_job_sensor_deferred]
job_run_sensor_deferred = DbtCloudJobRunSensor(
task_id="job_run_sensor_deferred", run_id=trigger_job_run2.output, timeout=20, deferrable=True
)
# [END howto_operator_dbt_cloud_run_job_sensor_defered]

# [START howto_operator_dbt_cloud_run_job_async_sensor]
job_run_async_sensor = DbtCloudJobRunAsyncSensor(
task_id="job_run_async_sensor", run_id=trigger_job_run2.output, timeout=20
)
# [END howto_operator_dbt_cloud_run_job_async_sensor]
# [END howto_operator_dbt_cloud_run_job_sensor_deferred]

# [START howto_operator_dbt_cloud_list_jobs]
list_dbt_jobs = DbtCloudListJobsOperator(task_id="list_dbt_jobs", account_id=106277, project_id=160645)
Expand All @@ -95,6 +89,7 @@
# Task dependency created via `XComArgs`:
# trigger_job_run1 >> get_run_results_artifact
# trigger_job_run2 >> job_run_sensor
# trigger_job_run2 >> job_run_sensor_deferred

from tests.system.utils.watcher import watcher

Expand Down

0 comments on commit 8de6c72

Please sign in to comment.