Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions airflow-core/tests/unit/always/test_project_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ class TestGoogleProviderProjectStructure(ExampleCoverageTest, AssetsCoverageTest
}

MISSING_EXAMPLES_FOR_CLASSES = {
"airflow.providers.google.cloud.operators.life_sciences.LifeSciencesRunPipelineOperator",
"airflow.providers.google.cloud.operators.dlp.CloudDLPRedactImageOperator",
"airflow.providers.google.cloud.transfers.cassandra_to_gcs.CassandraToGCSOperator",
"airflow.providers.google.cloud.transfers.adls_to_gcs.ADLSToGCSOperator",
Expand Down
36 changes: 10 additions & 26 deletions providers/google/docs/operators/cloud/life_sciences.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,14 @@ The `Google Cloud Life Sciences <https://cloud.google.com/life-sciences/>`__ is
series of compute engine containers on the Google Cloud. It is used to process, analyze and annotate genomics
and biomedical data at scale.

.. warning::
The Cloud Life Sciences will be discontinued on July 8, 2025. Please, use Google Cloud Batch instead.

Prerequisite Tasks
^^^^^^^^^^^^^^^^^^

.. include:: /operators/_partials/prerequisite_tasks.rst


Pipeline Configuration
^^^^^^^^^^^^^^^^^^^^^^
In order to run the pipeline, it is necessary to configure the request body.
Here is an example of the pipeline configuration with a single action.

.. exampleinclude:: /../../google/tests/system/google/cloud/life_sciences/example_life_sciences.py
:language: python
:dedent: 0
:start-after: [START howto_configure_simple_action_pipeline]
:end-before: [END howto_configure_simple_action_pipeline]

The pipeline can also be configured with multiple action.

.. exampleinclude:: /../../google/tests/system/google/cloud/life_sciences/example_life_sciences.py
:language: python
:dedent: 0
:start-after: [START howto_configure_multiple_action_pipeline]
:end-before: [END howto_configure_multiple_action_pipeline]

Read about the `request body parameters <https://cloud.google.com/life-sciences/docs/reference/rest/v2beta/projects.locations.pipelines/run?authuser=1#request-body/>`__
to understand all the fields you can include in the configuration

.. _howto/operator:LifeSciencesRunPipelineOperator:

Running a pipeline
Expand All @@ -59,11 +39,15 @@ Use the
:class:`~airflow.providers.google.cloud.operators.life_sciences.LifeSciencesRunPipelineOperator`
to execute pipelines.

.. exampleinclude:: /../../google/tests/system/google/cloud/life_sciences/example_life_sciences.py
This operator is deprecated and will be removed after July 08, 2025.
All the functionality and new features are available on the Google Cloud Batch platform. Please use
:class:`~airflow.providers.google.cloud.operators.CloudBatchSubmitJobOperator`

.. exampleinclude:: /../../google/tests/system/google/cloud/cloud_batch/example_cloud_batch.py
:language: python
:dedent: 0
:start-after: [START howto_run_pipeline]
:end-before: [END howto_run_pipeline]
:start-after: [START howto_operator_batch_job_creation]
:end-before: [END howto_operator_batch_job_creation]

Reference
^^^^^^^^^
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import pytest

from airflow.exceptions import AirflowException
from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.providers.google.cloud.hooks.life_sciences import LifeSciencesHook

from unit.google.cloud.utils.base_gcp_mock import (
Expand All @@ -51,11 +51,12 @@

class TestLifeSciencesHookWithPassedProjectId:
def setup_method(self):
with mock.patch(
"airflow.providers.google.common.hooks.base_google.GoogleBaseHook.__init__",
new=mock_base_gcp_hook_default_project_id,
):
self.hook = LifeSciencesHook(gcp_conn_id="test")
with pytest.warns(AirflowProviderDeprecationWarning):
with mock.patch(
"airflow.providers.google.common.hooks.base_google.GoogleBaseHook.__init__",
new=mock_base_gcp_hook_default_project_id,
):
self.hook = LifeSciencesHook(gcp_conn_id="test")

def test_location_path(self):
path = "projects/life-science-project-id/locations/test-location"
Expand Down Expand Up @@ -162,11 +163,12 @@ def test_error_operation(self, _, get_conn_mock, mock_project_id):

class TestLifeSciencesHookWithDefaultProjectIdFromConnection:
def setup_method(self):
with mock.patch(
"airflow.providers.google.common.hooks.base_google.GoogleBaseHook.__init__",
new=mock_base_gcp_hook_default_project_id,
):
self.hook = LifeSciencesHook(gcp_conn_id="test")
with pytest.warns(AirflowProviderDeprecationWarning):
with mock.patch(
"airflow.providers.google.common.hooks.base_google.GoogleBaseHook.__init__",
new=mock_base_gcp_hook_default_project_id,
):
self.hook = LifeSciencesHook(gcp_conn_id="test")

@mock.patch("airflow.providers.google.cloud.hooks.life_sciences.LifeSciencesHook._authorize")
@mock.patch("airflow.providers.google.cloud.hooks.life_sciences.build")
Expand Down Expand Up @@ -268,11 +270,12 @@ def test_error_operation(self, _, get_conn_mock, mock_project_id):

class TestLifeSciencesHookWithoutProjectId:
def setup_method(self):
with mock.patch(
"airflow.providers.google.common.hooks.base_google.GoogleBaseHook.__init__",
new=mock_base_gcp_hook_no_default_project_id,
):
self.hook = LifeSciencesHook(gcp_conn_id="test")
with pytest.warns(AirflowProviderDeprecationWarning):
with mock.patch(
"airflow.providers.google.common.hooks.base_google.GoogleBaseHook.__init__",
new=mock_base_gcp_hook_no_default_project_id,
):
self.hook = LifeSciencesHook(gcp_conn_id="test")

@mock.patch("airflow.providers.google.cloud.hooks.life_sciences.LifeSciencesHook._authorize")
@mock.patch("airflow.providers.google.cloud.hooks.life_sciences.build")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

from unittest import mock

import pytest

from airflow.exceptions import AirflowProviderDeprecationWarning
from airflow.providers.google.cloud.operators.life_sciences import LifeSciencesRunPipelineOperator

TEST_BODY = {"pipeline": {"actions": [{}], "resources": {}, "environment": {}, "timeout": "3.5s"}}
Expand All @@ -40,23 +43,25 @@ class TestLifeSciencesRunPipelineOperator:
def test_executes(self, mock_hook):
mock_instance = mock_hook.return_value
mock_instance.run_pipeline.return_value = TEST_OPERATION
operator = LifeSciencesRunPipelineOperator(
task_id="task-id", body=TEST_BODY, location=TEST_LOCATION, project_id=TEST_PROJECT_ID
)
context = mock.MagicMock()
result = operator.execute(context=context)
with pytest.warns(AirflowProviderDeprecationWarning):
operator = LifeSciencesRunPipelineOperator(
task_id="task-id", body=TEST_BODY, location=TEST_LOCATION, project_id=TEST_PROJECT_ID
)
context = mock.MagicMock()
result = operator.execute(context=context)

assert result == TEST_OPERATION

@mock.patch("airflow.providers.google.cloud.operators.life_sciences.LifeSciencesHook")
def test_executes_without_project_id(self, mock_hook):
mock_instance = mock_hook.return_value
mock_instance.run_pipeline.return_value = TEST_OPERATION
operator = LifeSciencesRunPipelineOperator(
task_id="task-id",
body=TEST_BODY,
location=TEST_LOCATION,
)
context = mock.MagicMock()
result = operator.execute(context=context)
with pytest.warns(AirflowProviderDeprecationWarning):
operator = LifeSciencesRunPipelineOperator(
task_id="task-id",
body=TEST_BODY,
location=TEST_LOCATION,
)
context = mock.MagicMock()
result = operator.execute(context=context)
assert result == TEST_OPERATION