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/04/06 17:40:27 UTC

[GitHub] [airflow] dstandish opened a new pull request #15232: S3Hook.load_file should accept Path object in addition to str

dstandish opened a new pull request #15232:
URL: https://github.com/apache/airflow/pull/15232


   When uploading files to s3 it's convenient to be able to use Path objects
   
   Since I'm not changing behavior I think it may be OK to not write additional test but let me know if you think it's warranted.


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



[GitHub] [airflow] uranusjr commented on a change in pull request #15232: S3Hook.load_file should accept Path object in addition to str

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



##########
File path: airflow/providers/amazon/aws/hooks/s3.py
##########
@@ -494,6 +495,7 @@ def load_file(
             uploaded to the S3 bucket.
         :type acl_policy: str
         """
+        filename = filename.as_posix() if isinstance(filename, Path) else filename

Review comment:
       What is the semantic meaning of `filename` here, a file on the local filesystem, or a path in the S3 bucket? If it’s the latter, this should be `Union[str, PurePosixPath]` instead, and just use `str()` for coercion.




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



[GitHub] [airflow] dstandish commented on a change in pull request #15232: S3Hook.load_file should accept Path object in addition to str

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



##########
File path: airflow/providers/amazon/aws/hooks/s3.py
##########
@@ -494,6 +495,7 @@ def load_file(
             uploaded to the S3 bucket.
         :type acl_policy: str
         """
+        filename = filename.as_posix() if isinstance(filename, Path) else filename

Review comment:
       thanks @uranusjr 
   
   > what is the semantic meaning of filename here, a file on the local filesystem, or a path in the S3 bucket? 
   
   it means path to local file.  `key` is the bucket "path"
   
   > If it’s the latter, this should be Union[str, PurePosixPath] instead, and just use str() for coercion. 
   
   i think you mean _former_ and i have updated accordingly.  thanks for the suggestion.




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



[GitHub] [airflow] uranusjr removed a comment on pull request #15232: S3Hook.load_file should accept Path object in addition to str

Posted by GitBox <gi...@apache.org>.
uranusjr removed a comment on pull request #15232:
URL: https://github.com/apache/airflow/pull/15232#issuecomment-815193220


   No, I meant the latter. `Path` is for actual paths in the local filesystem, and shouldn’t be used to represent a path on S3. That should use `PurePosixPath`, which is basically a wrapper to a list of path components that will be joined with `/` when stringified. Your current implementation is the opposite of what I had in mind; since `filename` here should point to a local file, it should use `Path`.


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



[GitHub] [airflow] dstandish commented on a change in pull request #15232: S3Hook.load_file should accept Path object in addition to str

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



##########
File path: airflow/providers/amazon/aws/hooks/s3.py
##########
@@ -494,6 +495,7 @@ def load_file(
             uploaded to the S3 bucket.
         :type acl_policy: str
         """
+        filename = filename.as_posix() if isinstance(filename, Path) else filename

Review comment:
       thanks @uranusjr 
   
   > what is the semantic meaning of filename here, a file on the local filesystem, or a path in the S3 bucket? 
   
   it means path to local file.  `key` is the bucket "path"
   
   > If it’s the latter, this should be Union[str, PurePosixPath] instead, and just use str() for coercion. 
   
   did you perhaps mean _former_?  i have updated assuming yes.




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



[GitHub] [airflow] dstandish commented on a change in pull request #15232: S3Hook.load_file should accept Path object in addition to str

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



##########
File path: airflow/providers/amazon/aws/hooks/s3.py
##########
@@ -494,6 +495,7 @@ def load_file(
             uploaded to the S3 bucket.
         :type acl_policy: str
         """
+        filename = filename.as_posix() if isinstance(filename, Path) else filename

Review comment:
       Wellp, that's how I had it in the first place
   
   I've switched it back to `Path` 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.

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



[GitHub] [airflow] uranusjr commented on pull request #15232: S3Hook.load_file should accept Path object in addition to str

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


   No, I meant the latter. `Path` is for actual paths in the local filesystem, and shouldn’t be used to represent a path on S3. That should use `PurePosixPath`, which is basically a wrapper to a list of path components that will be joined with `/` when stringified. Your current implementation is the opposite of what I had in mind; since `filename` here should point to a local file, it should use `Path`.


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



[GitHub] [airflow] github-actions[bot] commented on pull request #15232: S3Hook.load_file should accept Path object in addition to str

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


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

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



[GitHub] [airflow] dstandish merged pull request #15232: S3Hook.load_file should accept Path object in addition to str

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


   


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



[GitHub] [airflow] dstandish commented on a change in pull request #15232: S3Hook.load_file should accept Path object in addition to str

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



##########
File path: airflow/providers/amazon/aws/hooks/s3.py
##########
@@ -494,6 +495,7 @@ def load_file(
             uploaded to the S3 bucket.
         :type acl_policy: str
         """
+        filename = filename.as_posix() if isinstance(filename, Path) else filename

Review comment:
       thanks @uranusjr 
   
   > what is the semantic meaning of filename here, a file on the local filesystem, or a path in the S3 bucket? 
   
   it means path to local file.  `key` is the bucket "path"
   
   > If it’s the latter, this should be Union[str, PurePosixPath] instead, and just use str() for coercion. 
   
   did you perhaps mean former?




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



[GitHub] [airflow] dstandish commented on a change in pull request #15232: S3Hook.load_file should accept Path object in addition to str

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



##########
File path: airflow/providers/amazon/aws/hooks/s3.py
##########
@@ -494,6 +495,7 @@ def load_file(
             uploaded to the S3 bucket.
         :type acl_policy: str
         """
+        filename = filename.as_posix() if isinstance(filename, Path) else filename

Review comment:
       thanks @uranusjr 
   
   > what is the semantic meaning of filename here, a file on the local filesystem, or a path in the S3 bucket? 
   
   it means path to local file.  `key` is the bucket "path"
   
   > If it’s the latter, this should be Union[str, PurePosixPath] instead, and just use str() for coercion. 
   
   did you perhaps mean _former_?




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



[GitHub] [airflow] dstandish commented on a change in pull request #15232: S3Hook.load_file should accept Path object in addition to str

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



##########
File path: airflow/providers/amazon/aws/hooks/s3.py
##########
@@ -494,6 +495,7 @@ def load_file(
             uploaded to the S3 bucket.
         :type acl_policy: str
         """
+        filename = filename.as_posix() if isinstance(filename, Path) else filename

Review comment:
       OK sure that's how I had it in the first place
   
   I've switched it back to `Path` 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.

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



[GitHub] [airflow] dstandish commented on a change in pull request #15232: S3Hook.load_file should accept Path object in addition to str

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



##########
File path: airflow/providers/amazon/aws/hooks/s3.py
##########
@@ -494,6 +495,7 @@ def load_file(
             uploaded to the S3 bucket.
         :type acl_policy: str
         """
+        filename = filename.as_posix() if isinstance(filename, Path) else filename

Review comment:
       OK sure that's how I had it to begin with
   
   I've switched it back to `Path` 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.

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



[GitHub] [airflow] uranusjr commented on a change in pull request #15232: S3Hook.load_file should accept Path object in addition to str

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



##########
File path: airflow/providers/amazon/aws/hooks/s3.py
##########
@@ -494,6 +495,7 @@ def load_file(
             uploaded to the S3 bucket.
         :type acl_policy: str
         """
+        filename = filename.as_posix() if isinstance(filename, Path) else filename

Review comment:
       No, I meant the latter. `Path` is for actual paths in the local filesystem, and shouldn’t be used to represent a path on S3. That should use `PurePosixPath`, which is basically a wrapper to a list of path components that will be joined with `/` when stringified. Your current implementation is the opposite of what I had in mind; since `filename` here should point to a local file, it should use `Path`.




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



[GitHub] [airflow] dstandish commented on a change in pull request #15232: S3Hook.load_file should accept Path object in addition to str

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



##########
File path: airflow/providers/amazon/aws/hooks/s3.py
##########
@@ -494,6 +495,7 @@ def load_file(
             uploaded to the S3 bucket.
         :type acl_policy: str
         """
+        filename = filename.as_posix() if isinstance(filename, Path) else filename

Review comment:
       thanks @uranusjr 
   
   > what is the semantic meaning of filename here, a file on the local filesystem, or a path in the S3 bucket? 
   
   it means path to local file
   
   > If it’s the latter, this should be Union[str, PurePosixPath] instead, and just use str() for coercion. 
   
   did you perhaps mean former?




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