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/07/28 10:49:32 UTC

[GitHub] [airflow] eskarimov opened a new pull request #17284: Add support of `path` parameter for GCloud Storage Transfer Service operators

eskarimov opened a new pull request #17284:
URL: https://github.com/apache/airflow/pull/17284


   ### **Issue:**
   Currently Google Cloud Transfer Service operators `CloudDataTransferServiceGCSToGCSOperator` and `CloudDataTransferServiceS3ToGCSOperator` don't provide functionality to specify destination path, i.e. prefix for transferred objects, hence all the objects should simply land into the root of the bucket.  
   
   ### **Solution:**
   [The Storage Transfer Service allows to specify prefix for transferred objects](https://cloud.google.com/storage-transfer/docs/reference/rest/v1/TransferSpec#GcsData), the PR adds this functionality with a new input parameter for operators above.
   
   By default it'd be `None`, so transferred objects will still land into the root of a bucket.
   
   Ideally I'd like to use just a single input parameter for specifying destination location, similar as it's done for [`S3ToGCSOperator`](https://github.com/apache/airflow/blob/main/airflow/providers/google/cloud/transfers/s3_to_gcs.py), parsing GCS URL, but it'd break backward compatibility for already existing pipelines. Hence, adding a new input parameter seems a more reasonable solution.
   
   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 #17284: Add support of `path` parameter for GCloud Storage Transfer Service operators

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



##########
File path: airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py
##########
@@ -1026,6 +1048,16 @@ def __init__(
         self.delete_job_after_completion = delete_job_after_completion
         self._validate_inputs()
 
+        if self.destination_path and not self.destination_path.endswith('/'):

Review comment:
       This check seems to be the same as the gcs_path(if Im not wrong), does it make sense to move it to a function?




-- 
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] eskarimov commented on pull request #17284: Add support of `path` parameter for GCloud Storage Transfer Service operators

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


   Sorry, will re-open the PR, my mistake


-- 
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] eskarimov closed pull request #17284: Add support of `path` parameter for GCloud Storage Transfer Service operators

Posted by GitBox <gi...@apache.org>.
eskarimov closed pull request #17284:
URL: https://github.com/apache/airflow/pull/17284


   


-- 
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] eskarimov commented on a change in pull request #17284: Add support of `path` parameter for GCloud Storage Transfer Service operators

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



##########
File path: airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py
##########
@@ -861,6 +867,10 @@ def __init__(
     def _validate_inputs(self) -> None:
         if self.delete_job_after_completion and not self.wait:
             raise AirflowException("If 'delete_job_after_completion' is True, then 'wait' must also be True.")
+        if self.gcs_path and not self.gcs_path.endswith("/"):
+            raise AirflowException(
+                "The destination Google Cloud Storage path must end with a slash '/' or be empty."
+            )

Review comment:
       Thank you, makes sense!
   I've checked if any similar function already exists and found the one in the `GCSHook` class [here](https://github.com/apache/airflow/blob/0f97b92c1ad15bd6d0a90c8dee8287886641d7d9/airflow/providers/google/cloud/hooks/gcs.py#L1140)
   To avoid repetitive code I've extracted class function into a standalone one in order to import it here.
   Please let me know your thoughts.




-- 
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] eskarimov commented on a change in pull request #17284: Add support of `path` parameter for GCloud Storage Transfer Service operators

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



##########
File path: airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py
##########
@@ -1026,6 +1048,16 @@ def __init__(
         self.delete_job_after_completion = delete_job_after_completion
         self._validate_inputs()
 
+        if self.destination_path and not self.destination_path.endswith('/'):

Review comment:
       Actually I missed the function `_validate_inputs` under each operator class somehow, it's the right place for this check, moved it there




-- 
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] uranusjr commented on a change in pull request #17284: Add support of `path` parameter for GCloud Storage Transfer Service operators

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



##########
File path: airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py
##########
@@ -861,6 +867,10 @@ def __init__(
     def _validate_inputs(self) -> None:
         if self.delete_job_after_completion and not self.wait:
             raise AirflowException("If 'delete_job_after_completion' is True, then 'wait' must also be True.")
+        if self.gcs_path and not self.gcs_path.endswith("/"):
+            raise AirflowException(
+                "The destination Google Cloud Storage path must end with a slash '/' or be empty."
+            )

Review comment:
       I know nothing about GCS, but if the path must ends with `/`, can we automatically append it instead of failing 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.

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

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



[GitHub] [airflow] boring-cyborg[bot] commented on pull request #17284: Add support of `path` parameter for GCloud Storage Transfer Service operators

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on pull request #17284:
URL: https://github.com/apache/airflow/pull/17284#issuecomment-888211924


   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (flake8, mypy and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/main/STATIC_CODE_CHECKS.rst#prerequisites-for-pre-commit-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/docs/apache-airflow/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/BREEZE.rst) for testing locally, itโ€™s a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#coding-style-and-best-practices).
   Apache Airflow is a community-driven project and together we are making it better ๐Ÿš€.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


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