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 2021/12/31 15:45:23 UTC

[GitHub] [airflow] subkanthi opened a new pull request #20610: Fix mypy apache beam operators

subkanthi opened a new pull request #20610:
URL: https://github.com/apache/airflow/pull/20610


   related: #19891 
   Fixes the following mypy errors.
   ```
   airflow/providers/apache/beam/operators/beam.py:255: error: Item "None" of "Optional[DataflowHook]" has no attribute "provide_authorized_gcloud"
                       with self.dataflow_hook.provide_authorized_gcloud():
                            ^
   airflow/providers/apache/beam/operators/beam.py:266: error: Item "None" of "Optional[DataflowHook]" has no attribute "wait_for_done"
                       self.dataflow_hook.wait_for_done(
                       ^
   airflow/providers/apache/beam/operators/beam.py:267: error: Argument "job_name" to "wait_for_done" of "DataflowHook" has incompatible type "Optional[str]"; expected
   "str"
                           job_name=dataflow_job_name,
                                    ^
   airflow/providers/apache/beam/operators/beam.py:268: error: Argument "location" to "wait_for_done" of "DataflowHook" has incompatible type "Optional[str]"; expected
   "str"
                           location=self.dataflow_config.location,
                                    ^
   airflow/providers/apache/beam/operators/beam.py:432: error: Item "None" of "Optional[DataflowHook]" has no attribute "is_job_dataflow_running"
                               self.dataflow_hook.is_job_dataflow_running(
                               ^
   airflow/providers/apache/beam/operators/beam.py:444: error: Item "None" of "Optional[DataflowHook]" has no attribute "is_job_dataflow_running"
                               is_running = self.dataflow_hook.is_job_dataflow_running(
                                            ^
   airflow/providers/apache/beam/operators/beam.py:450: error: Item "None" of "Optional[DataflowHook]" has no attribute "provide_authorized_gcloud"
                           with self.dataflow_hook.provide_authorized_gcloud():
                                ^
   airflow/providers/apache/beam/operators/beam.py:457: error: Item "None" of "Optional[DataflowHook]" has no attribute "wait_for_done"
                           self.dataflow_hook.wait_for_done(
                           ^
   airflow/providers/apache/beam/operators/beam.py:458: error: Argument "job_name" to "wait_for_done" of "DataflowHook" has incompatible type "Optional[str]"; expected
   "str"
                               job_name=dataflow_job_name,
                                        ^
   airflow/providers/apache/beam/operators/beam.py:459: error: Argument "location" to "wait_for_done" of "DataflowHook" has incompatible type "Optional[str]"; expected
   "str"
                               location=self.dataflow_config.location,
                                        ^
   airflow/providers/apache/beam/operators/beam.py:461: error: Argument "multiple_jobs" to "wait_for_done" of "DataflowHook" has incompatible type "Optional[bool]";
   expected "bool"
                               multiple_jobs=self.dataflow_config.multiple_jobs,
   ```
   <!--
   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 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 change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+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 [UPDATING.md](https://github.com/apache/airflow/blob/main/UPDATING.md).
   


-- 
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] subkanthi commented on a change in pull request #20610: Fix mypy apache beam operators

Posted by GitBox <gi...@apache.org>.
subkanthi commented on a change in pull request #20610:
URL: https://github.com/apache/airflow/pull/20610#discussion_r777044935



##########
File path: airflow/providers/apache/beam/operators/beam.py
##########
@@ -454,13 +455,22 @@ def execute(self, context: 'Context'):
                             job_class=self.job_class,
                             process_line_callback=process_line_callback,
                         )
-                    self.dataflow_hook.wait_for_done(
-                        job_name=dataflow_job_name,
-                        location=self.dataflow_config.location,
-                        job_id=self.dataflow_job_id,
-                        multiple_jobs=self.dataflow_config.multiple_jobs,
-                        project_id=self.dataflow_config.project_id,
-                    )
+                    if dataflow_job_name and self.dataflow_config.location:
+                        if self.dataflow_config.multiple_jobs:
+                            self.dataflow_hook.wait_for_done(
+                                job_name=dataflow_job_name,
+                                location=self.dataflow_config.location,
+                                job_id=self.dataflow_job_id,
+                                multiple_jobs=self.dataflow_config.multiple_jobs,

Review comment:
       looks like its still needed.
   
   ```
   airflow/providers/apache/beam/operators/beam.py:463: error: Argument "multiple_jobs" to "wait_for_done" of "DataflowHook" has incompatible type "Optional[bool]";
   expected "bool"
                                   multiple_jobs=self.dataflow_config.multiple_jobs,
   ```




-- 
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 #20610: Fix mypy apache beam operators

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


   


-- 
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 change in pull request #20610: Fix mypy apache beam operators

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #20610:
URL: https://github.com/apache/airflow/pull/20610#discussion_r777038719



##########
File path: airflow/providers/apache/beam/operators/beam.py
##########
@@ -454,13 +455,22 @@ def execute(self, context: 'Context'):
                             job_class=self.job_class,
                             process_line_callback=process_line_callback,
                         )
-                    self.dataflow_hook.wait_for_done(
-                        job_name=dataflow_job_name,
-                        location=self.dataflow_config.location,
-                        job_id=self.dataflow_job_id,
-                        multiple_jobs=self.dataflow_config.multiple_jobs,
-                        project_id=self.dataflow_config.project_id,
-                    )
+                    if dataflow_job_name and self.dataflow_config.location:
+                        if self.dataflow_config.multiple_jobs:
+                            self.dataflow_hook.wait_for_done(
+                                job_name=dataflow_job_name,
+                                location=self.dataflow_config.location,
+                                job_id=self.dataflow_job_id,
+                                multiple_jobs=self.dataflow_config.multiple_jobs,

Review comment:
       I think I already fixed that one in #20611 -> rebase after I merge and likely this one will not be needed.




-- 
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] subkanthi commented on pull request #20610: Fix mypy apache beam operators

Posted by GitBox <gi...@apache.org>.
subkanthi commented on pull request #20610:
URL: https://github.com/apache/airflow/pull/20610#issuecomment-1003450969


   > Some tests failing though :(
   
   Fixed now.


-- 
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 change in pull request #20610: Fix mypy apache beam operators

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #20610:
URL: https://github.com/apache/airflow/pull/20610#discussion_r777046069



##########
File path: airflow/providers/apache/beam/operators/beam.py
##########
@@ -454,13 +455,22 @@ def execute(self, context: 'Context'):
                             job_class=self.job_class,
                             process_line_callback=process_line_callback,
                         )
-                    self.dataflow_hook.wait_for_done(
-                        job_name=dataflow_job_name,
-                        location=self.dataflow_config.location,
-                        job_id=self.dataflow_job_id,
-                        multiple_jobs=self.dataflow_config.multiple_jobs,
-                        project_id=self.dataflow_config.project_id,
-                    )
+                    if dataflow_job_name and self.dataflow_config.location:
+                        if self.dataflow_config.multiple_jobs:
+                            self.dataflow_hook.wait_for_done(
+                                job_name=dataflow_job_name,
+                                location=self.dataflow_config.location,
+                                job_id=self.dataflow_job_id,
+                                multiple_jobs=self.dataflow_config.multiple_jobs,

Review comment:
       Ah right. That was another "wait".




-- 
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] github-actions[bot] commented on pull request #20610: Fix mypy apache beam operators

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #20610:
URL: https://github.com/apache/airflow/pull/20610#issuecomment-1003443452


   The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main or amend the last commit of the PR, and push it with --force-with-lease.


-- 
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 change in pull request #20610: Fix mypy apache beam operators

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #20610:
URL: https://github.com/apache/airflow/pull/20610#discussion_r777044067



##########
File path: airflow/providers/apache/beam/operators/beam.py
##########
@@ -454,13 +455,22 @@ def execute(self, context: 'Context'):
                             job_class=self.job_class,
                             process_line_callback=process_line_callback,
                         )
-                    self.dataflow_hook.wait_for_done(
-                        job_name=dataflow_job_name,
-                        location=self.dataflow_config.location,
-                        job_id=self.dataflow_job_id,
-                        multiple_jobs=self.dataflow_config.multiple_jobs,
-                        project_id=self.dataflow_config.project_id,
-                    )
+                    if dataflow_job_name and self.dataflow_config.location:
+                        if self.dataflow_config.multiple_jobs:
+                            self.dataflow_hook.wait_for_done(
+                                job_name=dataflow_job_name,
+                                location=self.dataflow_config.location,
+                                job_id=self.dataflow_job_id,
+                                multiple_jobs=self.dataflow_config.multiple_jobs,

Review comment:
       You might try to rebase now :)




-- 
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] subkanthi commented on a change in pull request #20610: Fix mypy apache beam operators

Posted by GitBox <gi...@apache.org>.
subkanthi commented on a change in pull request #20610:
URL: https://github.com/apache/airflow/pull/20610#discussion_r777025544



##########
File path: airflow/providers/apache/beam/operators/beam.py
##########
@@ -454,13 +455,22 @@ def execute(self, context: 'Context'):
                             job_class=self.job_class,
                             process_line_callback=process_line_callback,
                         )
-                    self.dataflow_hook.wait_for_done(
-                        job_name=dataflow_job_name,
-                        location=self.dataflow_config.location,
-                        job_id=self.dataflow_job_id,
-                        multiple_jobs=self.dataflow_config.multiple_jobs,
-                        project_id=self.dataflow_config.project_id,
-                    )
+                    if dataflow_job_name and self.dataflow_config.location:
+                        if self.dataflow_config.multiple_jobs:
+                            self.dataflow_hook.wait_for_done(
+                                job_name=dataflow_job_name,
+                                location=self.dataflow_config.location,
+                                job_id=self.dataflow_job_id,
+                                multiple_jobs=self.dataflow_config.multiple_jobs,

Review comment:
       maybe can be re-written better.




-- 
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] subkanthi commented on a change in pull request #20610: Fix mypy apache beam operators

Posted by GitBox <gi...@apache.org>.
subkanthi commented on a change in pull request #20610:
URL: https://github.com/apache/airflow/pull/20610#discussion_r777025387



##########
File path: airflow/providers/apache/beam/operators/beam.py
##########
@@ -263,12 +263,13 @@ def execute(self, context: 'Context'):
                         process_line_callback=process_line_callback,
                     )
 
-                self.dataflow_hook.wait_for_done(
-                    job_name=dataflow_job_name,
-                    location=self.dataflow_config.location,
-                    job_id=self.dataflow_job_id,
-                    multiple_jobs=False,
-                )
+                if dataflow_job_name and self.dataflow_config.location:
+                    self.dataflow_hook.wait_for_done(
+                        job_name=dataflow_job_name,
+                        location=self.dataflow_config.location,

Review comment:
       assumption is the job_name and self.dataflow_config.location are required parameters




-- 
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 change in pull request #20610: Fix mypy apache beam operators

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #20610:
URL: https://github.com/apache/airflow/pull/20610#discussion_r777046585



##########
File path: airflow/providers/apache/beam/operators/beam.py
##########
@@ -454,13 +455,22 @@ def execute(self, context: 'Context'):
                             job_class=self.job_class,
                             process_line_callback=process_line_callback,
                         )
-                    self.dataflow_hook.wait_for_done(
-                        job_name=dataflow_job_name,
-                        location=self.dataflow_config.location,
-                        job_id=self.dataflow_job_id,
-                        multiple_jobs=self.dataflow_config.multiple_jobs,
-                        project_id=self.dataflow_config.project_id,
-                    )
+                    if dataflow_job_name and self.dataflow_config.location:
+                        if self.dataflow_config.multiple_jobs:
+                            self.dataflow_hook.wait_for_done(
+                                job_name=dataflow_job_name,
+                                location=self.dataflow_config.location,
+                                job_id=self.dataflow_job_id,
+                                multiple_jobs=self.dataflow_config.multiple_jobs,

Review comment:
       Easy - default is False if not set.
   
   ```
   mutltiple_jobs = self.dataflow_config.mutliple_jobs if self.dataflow_config.multiple_jobs else False
   
   ....
    
           mutltiple_jobs=multiple_jobs,
   ```




-- 
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 pull request #20610: Fix mypy apache beam operators

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #20610:
URL: https://github.com/apache/airflow/pull/20610#issuecomment-1003443588


   Some tests failing though :(


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