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 2020/02/05 00:04:23 UTC

[GitHub] [airflow] saguziel opened a new pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds

saguziel opened a new pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds
URL: https://github.com/apache/airflow/pull/7363
 
 
   ---
   Issue link: WILL BE INSERTED BY [boring-cyborg](https://github.com/kaxil/boring-cyborg)
   
   Make sure to mark the boxes below before creating PR: [x]
   
   - [x] Description above provides context of the change
   - [x] Commit message/PR title starts with `[AIRFLOW-NNNN]`. AIRFLOW-NNNN = JIRA ID<sup>*</sup>
   - [ ] Unit tests coverage for changes (not needed for documentation changes)
   - [x] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [x] Relevant documentation is updated including usage instructions.
   - [x] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   <sup>*</sup> For document-only changes commit message can start with `[AIRFLOW-XXXX]`.
   
   ---
   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/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] saguziel commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds

Posted by GitBox <gi...@apache.org>.
saguziel commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds
URL: https://github.com/apache/airflow/pull/7363#discussion_r385388599
 
 

 ##########
 File path: tests/providers/google/cloud/operators/test_dataproc.py
 ##########
 @@ -104,7 +104,7 @@
         "autoscaling_config": {"policy_uri": "autoscaling_policy"},
         "config_bucket": "storage_bucket",
         "initialization_actions": [
-            {"executable_file": "init_actions_uris", "execution_timeout": "600s"}
+            {"executable_file": "init_actions_uris", "execution_timeout": "600.0s"}
 
 Review comment:
   the python typing indicates float, but I think that is just within the airflow project.
   
   I will just cast it to int since that is guaranteed to not break anything

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] ashb commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds
URL: https://github.com/apache/airflow/pull/7363#discussion_r379119387
 
 

 ##########
 File path: tests/providers/google/cloud/operators/test_dataproc.py
 ##########
 @@ -104,7 +104,7 @@
         "autoscaling_config": {"policy_uri": "autoscaling_policy"},
         "config_bucket": "storage_bucket",
         "initialization_actions": [
-            {"executable_file": "init_actions_uris", "execution_timeout": "600s"}
+            {"executable_file": "init_actions_uris", "execution_timeout": "600.0s"}
 
 Review comment:
   This is my only question -- does DataProc accept this, or does it only accept whole-integer seconds here.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] ashb commented on issue #7363: [AIRFLOW-6730] Use total_seconds instead of seconds

Posted by GitBox <gi...@apache.org>.
ashb commented on issue #7363: [AIRFLOW-6730] Use total_seconds instead of seconds
URL: https://github.com/apache/airflow/pull/7363#issuecomment-582833432
 
 
   Ah - the "native" representation of a timedelta is (days, seconds) so it's only giving the wrong value when the delta is >= 1 day. So nothing is likely to break as a result of this, but using `d.total_seconds()` is correct (or `int(d.total_seconds())`) in some places.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] ashb commented on issue #7363: [AIRFLOW-6730] Use total_seconds instead of seconds

Posted by GitBox <gi...@apache.org>.
ashb commented on issue #7363: [AIRFLOW-6730] Use total_seconds instead of seconds
URL: https://github.com/apache/airflow/pull/7363#issuecomment-582528294
 
 
   :man_facepalming: Guess we've just been lucky and the default timeouts don't fire.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] ashb commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds
URL: https://github.com/apache/airflow/pull/7363#discussion_r375747056
 
 

 ##########
 File path: airflow/providers/google/cloud/operators/dataproc.py
 ##########
 @@ -618,16 +618,16 @@ def _graceful_decommission_timeout_object(self) -> Optional[Dict]:
         match = re.match(r"^(\d+)([smdh])$", self.graceful_decommission_timeout)
         if match:
             if match.group(2) == "s":
-                timeout = int(match.group(1))
+                timeout = float(match.group(1))
 
 Review comment:
   The regex is `\d+` so `int()` feels right here
   
   ```suggestion
                   timeout = int(match.group(1))
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] ashb commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds
URL: https://github.com/apache/airflow/pull/7363#discussion_r375748282
 
 

 ##########
 File path: airflow/providers/google/cloud/operators/postgres_to_gcs.py
 ##########
 @@ -94,7 +94,7 @@ def convert_type(self, value, schema_type):
             return datetime.timedelta(
                 hours=formated_time.tm_hour,
                 minutes=formated_time.tm_min,
-                seconds=formated_time.tm_sec).seconds
+                seconds=formated_time.tm_sec).total_seconds()
 
 Review comment:
   ```
   In [7]: timedelta(hours=12, minutes=30, seconds=30).seconds                                                                                                                          
   Out[7]: 45030
   
   In [8]: timedelta(hours=12, minutes=30, seconds=30).total_seconds()                                                                                                                  
   Out[8]: 45030.0
   ```
   
   (total_seconds returns a float, previously this was an int. I don't think that is intended.)

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] ashb commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds
URL: https://github.com/apache/airflow/pull/7363#discussion_r375409336
 
 

 ##########
 File path: airflow/providers/google/cloud/operators/postgres_to_gcs.py
 ##########
 @@ -94,7 +94,7 @@ def convert_type(self, value, schema_type):
             return datetime.timedelta(
                 hours=formated_time.tm_hour,
                 minutes=formated_time.tm_min,
-                seconds=formated_time.tm_sec).seconds
+                seconds=formated_time.tm_sec).total_seconds()
 
 Review comment:
   This one is I think wrong.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] nuclearpinguin commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds

Posted by GitBox <gi...@apache.org>.
nuclearpinguin commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds
URL: https://github.com/apache/airflow/pull/7363#discussion_r379452203
 
 

 ##########
 File path: tests/providers/google/cloud/operators/test_dataproc.py
 ##########
 @@ -104,7 +104,7 @@
         "autoscaling_config": {"policy_uri": "autoscaling_policy"},
         "config_bucket": "storage_bucket",
         "initialization_actions": [
-            {"executable_file": "init_actions_uris", "execution_timeout": "600s"}
+            {"executable_file": "init_actions_uris", "execution_timeout": "600.0s"}
 
 Review comment:
   Should be int:
   https://developers.google.com/protocol-buffers/docs/reference/google.protobuf?&_ga=2.173161123.14377043.1581598687-968688242.1573564810#duration

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] saguziel commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds

Posted by GitBox <gi...@apache.org>.
saguziel commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds
URL: https://github.com/apache/airflow/pull/7363#discussion_r376051577
 
 

 ##########
 File path: airflow/providers/google/cloud/operators/dataproc.py
 ##########
 @@ -618,16 +618,16 @@ def _graceful_decommission_timeout_object(self) -> Optional[Dict]:
         match = re.match(r"^(\d+)([smdh])$", self.graceful_decommission_timeout)
         if match:
             if match.group(2) == "s":
-                timeout = int(match.group(1))
+                timeout = float(match.group(1))
 
 Review comment:
   This one I think makes sense as float since it is only passed as a param to something that is a float  
   (to hooks/dataproc.py -> update_cluster which takes timeout as an Optional[float] )

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] saguziel merged pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds

Posted by GitBox <gi...@apache.org>.
saguziel merged pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds
URL: https://github.com/apache/airflow/pull/7363
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] kaxil commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds

Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #7363: [AIRFLOW-6730] Use total_seconds instead of seconds
URL: https://github.com/apache/airflow/pull/7363#discussion_r382868568
 
 

 ##########
 File path: tests/providers/google/cloud/operators/test_dataproc.py
 ##########
 @@ -104,7 +104,7 @@
         "autoscaling_config": {"policy_uri": "autoscaling_policy"},
         "config_bucket": "storage_bucket",
         "initialization_actions": [
-            {"executable_file": "init_actions_uris", "execution_timeout": "600s"}
+            {"executable_file": "init_actions_uris", "execution_timeout": "600.0s"}
 
 Review comment:
   https://developers.google.com/protocol-buffers/docs/proto3#json
   
   @saguziel WDYT?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] saguziel commented on issue #7363: [AIRFLOW-6730] Use total_seconds instead of seconds

Posted by GitBox <gi...@apache.org>.
saguziel commented on issue #7363: [AIRFLOW-6730] Use total_seconds instead of seconds
URL: https://github.com/apache/airflow/pull/7363#issuecomment-592269856
 
 
   This passed on my travis-ci so i will merge

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services