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 2023/01/03 11:41:54 UTC

[GitHub] [airflow] VladaZakharova opened a new pull request, #28690: Add deferrable mode to DataFusionStartPipelineOperator

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

   <!--
   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/
   -->
   
   ---
   **^ 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] VladaZakharova commented on a diff in pull request #28690: Add deferrable mode to DataFusionStartPipelineOperator

Posted by GitBox <gi...@apache.org>.
VladaZakharova commented on code in PR #28690:
URL: https://github.com/apache/airflow/pull/28690#discussion_r1060517264


##########
airflow/providers/google/cloud/hooks/datafusion.py:
##########
@@ -91,7 +97,7 @@ def wait_for_pipeline_state(
         namespace: str = "default",
         success_states: list[str] | None = None,
         failure_states: list[str] | None = None,
-        timeout: int = 5 * 60,
+        timeout: int = 7 * 60,

Review Comment:
   I faced some problem with waiting for the pipeline state and thought that increasing the timeout will solve the problem.  I will reduce the timeout as it was :)



-- 
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 commented on a diff in pull request #28690: Add deferrable mode to DataFusionStartPipelineOperator

Posted by GitBox <gi...@apache.org>.
potiuk commented on code in PR #28690:
URL: https://github.com/apache/airflow/pull/28690#discussion_r1071943582


##########
airflow/providers/google/cloud/hooks/datafusion.py:
##########
@@ -91,7 +97,7 @@ def wait_for_pipeline_state(
         namespace: str = "default",
         success_states: list[str] | None = None,
         failure_states: list[str] | None = None,
-        timeout: int = 5 * 60,
+        timeout: int = 7 * 60,

Review Comment:
   Approved pending this one. Can you fix + rebase @VladaZakharova 



##########
airflow/providers/google/cloud/hooks/datafusion.py:
##########
@@ -91,7 +97,7 @@ def wait_for_pipeline_state(
         namespace: str = "default",
         success_states: list[str] | None = None,
         failure_states: list[str] | None = None,
-        timeout: int = 5 * 60,
+        timeout: int = 7 * 60,

Review Comment:
   Approved pending this one. Can you please fix + rebase @VladaZakharova  ?



-- 
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] bhirsz commented on a diff in pull request #28690: Add deferrable mode to DataFusionStartPipelineOperator

Posted by GitBox <gi...@apache.org>.
bhirsz commented on code in PR #28690:
URL: https://github.com/apache/airflow/pull/28690#discussion_r1060512947


##########
airflow/providers/google/cloud/hooks/datafusion.py:
##########
@@ -154,7 +160,10 @@ def _cdap_request(
 
     @staticmethod
     def _check_response_status_and_data(response, message: str) -> None:
-        if response.status != 200:
+        print("data: ", response.data)

Review Comment:
   Should print be there? Or rather logging method if we intend to log something.



-- 
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] bhirsz commented on a diff in pull request #28690: Add deferrable mode to DataFusionStartPipelineOperator

Posted by GitBox <gi...@apache.org>.
bhirsz commented on code in PR #28690:
URL: https://github.com/apache/airflow/pull/28690#discussion_r1060512576


##########
airflow/providers/google/cloud/hooks/datafusion.py:
##########
@@ -91,7 +97,7 @@ def wait_for_pipeline_state(
         namespace: str = "default",
         success_states: list[str] | None = None,
         failure_states: list[str] | None = None,
-        timeout: int = 5 * 60,
+        timeout: int = 7 * 60,

Review Comment:
   Any reason why it's now 7 minutes and not 5?



-- 
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 #28690: Add deferrable mode to DataFusionStartPipelineOperator

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #28690:
URL: https://github.com/apache/airflow/pull/28690


-- 
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] VladaZakharova closed pull request #28690: Add deferrable mode to DataFusionStartPipelineOperator

Posted by GitBox <gi...@apache.org>.
VladaZakharova closed pull request #28690: Add deferrable mode to DataFusionStartPipelineOperator
URL: https://github.com/apache/airflow/pull/28690


-- 
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] bhirsz commented on a diff in pull request #28690: Add deferrable mode to DataFusionStartPipelineOperator

Posted by GitBox <gi...@apache.org>.
bhirsz commented on code in PR #28690:
URL: https://github.com/apache/airflow/pull/28690#discussion_r1060513415


##########
airflow/providers/google/cloud/hooks/datafusion.py:
##########
@@ -465,7 +474,98 @@ def stop_pipeline(self, pipeline_name: str, instance_url: str, namespace: str =
             "DataPipelineWorkflow",
             "stop",
         )
+        self.log.info("before stp pipe")

Review Comment:
   Is that the intended logging message? Or leftover from debugging.



-- 
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] MrGeorgeOwl commented on a diff in pull request #28690: Add deferrable mode to DataFusionStartPipelineOperator

Posted by GitBox <gi...@apache.org>.
MrGeorgeOwl commented on code in PR #28690:
URL: https://github.com/apache/airflow/pull/28690#discussion_r1060690144


##########
airflow/providers/google/cloud/hooks/datafusion.py:
##########
@@ -469,3 +477,93 @@ def stop_pipeline(self, pipeline_name: str, instance_url: str, namespace: str =
         self._check_response_status_and_data(
             response, f"Stopping a pipeline failed with code {response.status}"
         )
+
+
+class DataFusionAsyncHook(GoogleBaseAsyncHook):
+    """Class to get async hook for Datafusion Async"""
+
+    sync_hook_class = DataFusionHook
+    scopes = ["https://www.googleapis.com/auth/cloud-platform"]
+
+    @staticmethod
+    def _base_url(instance_url: str, namespace: str) -> str:
+        return os.path.join(instance_url, "v3", "namespaces", quote(namespace), "apps")
+
+    async def _get_link(self, url: str, session):
+        async with Token(scopes=self.scopes) as token:
+            session_aio = AioSession(session)
+            headers = {
+                "Authorization": f"Bearer {await token.get()}",
+            }
+            try:
+                pipeline = await session_aio.get(url=url, headers=headers)
+            except AirflowException:
+                pass  # Because the pipeline may not be visible in system yet
+
+        return pipeline
+
+    async def get_pipeline(
+        self,
+        instance_url: str,
+        namespace: str,
+        pipeline_name: str,
+        pipeline_id: str,
+        session,
+    ):
+        base_url_link = self._base_url(instance_url, namespace)
+        url = os.path.join(

Review Comment:
   Same here, check comment about `urljoin`



##########
airflow/providers/google/cloud/hooks/datafusion.py:
##########
@@ -469,3 +477,93 @@ def stop_pipeline(self, pipeline_name: str, instance_url: str, namespace: str =
         self._check_response_status_and_data(
             response, f"Stopping a pipeline failed with code {response.status}"
         )
+
+
+class DataFusionAsyncHook(GoogleBaseAsyncHook):
+    """Class to get async hook for Datafusion Async"""
+
+    sync_hook_class = DataFusionHook
+    scopes = ["https://www.googleapis.com/auth/cloud-platform"]
+
+    @staticmethod
+    def _base_url(instance_url: str, namespace: str) -> str:
+        return os.path.join(instance_url, "v3", "namespaces", quote(namespace), "apps")

Review Comment:
   It is better to use `urllib.parse.urljoin` function instead of os.path.join. Because the second one is used for file path construction



##########
airflow/providers/google/cloud/links/datafusion.py:
##########
@@ -0,0 +1,131 @@
+#
+# 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 Google Compute Engine links."""
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, ClassVar
+
+from airflow.models import BaseOperatorLink, XCom
+
+if TYPE_CHECKING:
+    from airflow.models import BaseOperator
+    from airflow.models.taskinstance import TaskInstanceKey
+    from airflow.utils.context import Context
+
+
+BASE_LINK = "https://console.cloud.google.com/data-fusion"
+DATAFUSION_INSTANCE_LINK = BASE_LINK + "/locations/{region}/instances/{instance_name}?project={project_id}"
+DATAFUSION_PIPELINES_LINK = "{uri}/cdap/ns/default/pipelines"
+DATAFUSION_PIPELINE_LINK = "{uri}/pipelines/ns/default/view/{pipeline_name}"
+
+
+class BaseGoogleLink(BaseOperatorLink):
+    """
+    Override the base logic to prevent adding 'https://console.cloud.google.com'
+    in front of every link where uri is used
+    """
+
+    name: ClassVar[str]
+    key: ClassVar[str]
+    format_str: ClassVar[str]
+
+    def get_link(
+        self,
+        operator: BaseOperator,
+        *,
+        ti_key: TaskInstanceKey,
+    ) -> str:
+        conf = XCom.get_value(key=self.key, ti_key=ti_key)
+        if not conf:
+            return ""
+        if self.format_str.startswith("http"):
+            print("here")

Review Comment:
   Forget to remove `print` statement



-- 
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] VladaZakharova commented on a diff in pull request #28690: Add deferrable mode to DataFusionStartPipelineOperator

Posted by GitBox <gi...@apache.org>.
VladaZakharova commented on code in PR #28690:
URL: https://github.com/apache/airflow/pull/28690#discussion_r1071980126


##########
airflow/providers/google/cloud/hooks/datafusion.py:
##########
@@ -91,7 +97,7 @@ def wait_for_pipeline_state(
         namespace: str = "default",
         success_states: list[str] | None = None,
         failure_states: list[str] | None = None,
-        timeout: int = 5 * 60,
+        timeout: int = 7 * 60,

Review Comment:
   @potiuk Thank you for the approve!
   I have update the file



-- 
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] VladaZakharova commented on a diff in pull request #28690: Add deferrable mode to DataFusionStartPipelineOperator

Posted by GitBox <gi...@apache.org>.
VladaZakharova commented on code in PR #28690:
URL: https://github.com/apache/airflow/pull/28690#discussion_r1060518529


##########
airflow/providers/google/cloud/hooks/datafusion.py:
##########
@@ -465,7 +474,98 @@ def stop_pipeline(self, pipeline_name: str, instance_url: str, namespace: str =
             "DataPipelineWorkflow",
             "stop",
         )
+        self.log.info("before stp pipe")

Review Comment:
   Debugging :D



-- 
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] VladaZakharova commented on a diff in pull request #28690: Add deferrable mode to DataFusionStartPipelineOperator

Posted by GitBox <gi...@apache.org>.
VladaZakharova commented on code in PR #28690:
URL: https://github.com/apache/airflow/pull/28690#discussion_r1060719919


##########
airflow/providers/google/cloud/hooks/datafusion.py:
##########
@@ -469,3 +477,93 @@ def stop_pipeline(self, pipeline_name: str, instance_url: str, namespace: str =
         self._check_response_status_and_data(
             response, f"Stopping a pipeline failed with code {response.status}"
         )
+
+
+class DataFusionAsyncHook(GoogleBaseAsyncHook):
+    """Class to get async hook for Datafusion Async"""
+
+    sync_hook_class = DataFusionHook
+    scopes = ["https://www.googleapis.com/auth/cloud-platform"]
+
+    @staticmethod
+    def _base_url(instance_url: str, namespace: str) -> str:
+        return os.path.join(instance_url, "v3", "namespaces", quote(namespace), "apps")

Review Comment:
   good suggestion, thank you :)



-- 
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