You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/10/24 09:22:50 UTC

[GitHub] [airflow] bkossakowska opened a new pull request, #27227: Migration of System Tests: Cloud Composer (AIP-47)

bkossakowska opened a new pull request, #27227:
URL: https://github.com/apache/airflow/pull/27227

   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   Migration of System Tests: Cloud Composer (AIP-47) 
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk merged pull request #27227: Migration of System Tests: Cloud Composer (AIP-47)

Posted by GitBox <gi...@apache.org>.
potiuk merged PR #27227:
URL: https://github.com/apache/airflow/pull/27227


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] o-nikolas commented on a diff in pull request #27227: Migration of System Tests: Cloud Composer (AIP-47)

Posted by GitBox <gi...@apache.org>.
o-nikolas commented on code in PR #27227:
URL: https://github.com/apache/airflow/pull/27227#discussion_r1005199854


##########
airflow/providers/google/cloud/sensors/cloud_composer.py:
##########
@@ -0,0 +1,99 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""This module contains a Cloud Composer sensor."""
+
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Any, Sequence
+
+from airflow.exceptions import AirflowException
+from airflow.providers.google.cloud.triggers.cloud_composer import CloudComposerExecutionTrigger
+from airflow.sensors.base import BaseSensorOperator
+
+if TYPE_CHECKING:
+    from airflow.utils.context import Context
+
+
+class CloudComposerEnvironmentSensor(BaseSensorOperator):

Review Comment:
   I would have expected to see this new Sensor in one of the system tests?



##########
tests/system/providers/google/cloud/composer/example_cloud_composer.py:
##########
@@ -115,48 +121,14 @@
 
     chain(image_versions, create_env, list_envs, get_env, update_env, delete_env)

Review Comment:
   You'll need to add a `TriggerRule.ALL_DONE` to the delete_env cleanup task (outside of the howto block though to keep the docs clean).



##########
tests/system/providers/google/cloud/composer/example_cloud_composer_deferrable.py:
##########
@@ -0,0 +1,115 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import os
+from datetime import datetime
+
+from airflow import models
+from airflow.models.baseoperator import chain
+from airflow.providers.google.cloud.operators.cloud_composer import (
+    CloudComposerCreateEnvironmentOperator,
+    CloudComposerDeleteEnvironmentOperator,
+    CloudComposerUpdateEnvironmentOperator,
+)
+from airflow.utils.trigger_rule import TriggerRule
+
+ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
+PROJECT_ID = os.environ.get("SYSTEM_TESTS_GCP_PROJECT")
+
+DAG_ID = "example_composer_deferrable"
+
+REGION = "us-central1"
+
+ENVIRONMENT_ID = f"test-{DAG_ID}-{ENV_ID}"
+# [START howto_operator_composer_simple_environment]
+ENVIRONMENT = {
+    "config": {
+        "software_config": {"image_version": "composer-2.0.28-airflow-2.2.5"},
+    }
+}
+# [END howto_operator_composer_simple_environment]
+
+# [START howto_operator_composer_update_environment]
+UPDATED_ENVIRONMENT = {
+    "labels": {
+        "label2": "testing",
+    }
+}
+UPDATE_MASK = {"paths": ["labels.label2"]}
+# [END howto_operator_composer_update_environment]
+
+
+with models.DAG(
+    DAG_ID,
+    schedule="@once",
+    start_date=datetime(2021, 1, 1),
+    catchup=False,
+    tags=["example", "composer"],
+) as dag:
+    # [START howto_operator_create_composer_environment_deferrable_mode]
+    defer_create_env = CloudComposerCreateEnvironmentOperator(
+        task_id="defer_create_env",
+        project_id=PROJECT_ID,
+        region=REGION,
+        environment_id=ENVIRONMENT_ID,
+        environment=ENVIRONMENT,
+        deferrable=True,
+    )
+    # [END howto_operator_create_composer_environment_deferrable_mode]
+
+    # [START howto_operator_update_composer_environment_deferrable_mode]
+    defer_update_env = CloudComposerUpdateEnvironmentOperator(
+        task_id="defer_update_env",
+        project_id=PROJECT_ID,
+        region=REGION,
+        environment_id=ENVIRONMENT_ID,
+        update_mask=UPDATE_MASK,
+        environment=UPDATED_ENVIRONMENT,
+        deferrable=True,
+    )
+    # [END howto_operator_update_composer_environment_deferrable_mode]
+
+    # [START howto_operator_delete_composer_environment_deferrable_mode]
+    defer_delete_env = CloudComposerDeleteEnvironmentOperator(
+        task_id="defer_delete_env",
+        project_id=PROJECT_ID,
+        region=REGION,
+        environment_id=ENVIRONMENT_ID,
+        deferrable=True,
+        trigger_rule=TriggerRule.ALL_DONE,

Review Comment:
   So far we've been adding these outside of the howto block to keep the docs clean.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org