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/03/25 13:10:52 UTC

[GitHub] [airflow] turbaszek opened a new pull request #7866: Add download/upload operators for GCS and Google Sheets

turbaszek opened a new pull request #7866: Add download/upload operators for GCS and Google Sheets
URL: https://github.com/apache/airflow/pull/7866
 
 
   ---
   Issue link: WILL BE INSERTED BY [boring-cyborg](https://github.com/kaxil/boring-cyborg)
   Depends on #7853 
   
   Make sure to mark the boxes below before creating PR: [x]
   
   - [x] Description above provides context of the change
   - [ ] 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).
   
   ---
   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] turbaszek commented on a change in pull request #7866: Add download/upload operators for GCS and Google Sheets

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #7866: Add download/upload operators for GCS and Google Sheets
URL: https://github.com/apache/airflow/pull/7866#discussion_r397886357
 
 

 ##########
 File path: airflow/providers/google/suite/operators/sheets.py
 ##########
 @@ -0,0 +1,215 @@
+# 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.
+
+import csv
+from tempfile import NamedTemporaryFile
+from typing import Any, Dict, List, Optional
+
+from airflow.models import BaseOperator
+from airflow.providers.google.cloud.hooks.gcs import GCSHook
+from airflow.providers.google.suite.hooks.sheets import GSheetsHook
 
 Review comment:
   I can refactor it, the hook already exists

----------------------------------------------------------------
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] michalslowikowski00 commented on a change in pull request #7866: Add download/upload operators for GCS and Google Sheets

Posted by GitBox <gi...@apache.org>.
michalslowikowski00 commented on a change in pull request #7866: Add download/upload operators for GCS and Google Sheets
URL: https://github.com/apache/airflow/pull/7866#discussion_r397850924
 
 

 ##########
 File path: airflow/providers/google/suite/operators/sheets.py
 ##########
 @@ -0,0 +1,215 @@
+# 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.
+
+import csv
+from tempfile import NamedTemporaryFile
+from typing import Any, Dict, List, Optional
+
+from airflow.models import BaseOperator
+from airflow.providers.google.cloud.hooks.gcs import GCSHook
+from airflow.providers.google.suite.hooks.sheets import GSheetsHook
 
 Review comment:
   Wdyt about more explicit name like `GoogleSheetsHook`. 

----------------------------------------------------------------
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] michalslowikowski00 commented on a change in pull request #7866: Add download/upload operators for GCS and Google Sheets

Posted by GitBox <gi...@apache.org>.
michalslowikowski00 commented on a change in pull request #7866: Add download/upload operators for GCS and Google Sheets
URL: https://github.com/apache/airflow/pull/7866#discussion_r397847971
 
 

 ##########
 File path: airflow/providers/google/suite/hooks/sheets.py
 ##########
 @@ -375,3 +375,60 @@ def batch_clear(self, spreadsheet_id: str, ranges: List) -> Dict:
         ).execute(num_retries=self.num_retries)
 
         return response
+
+    def get_sheet_titles(self, spreadsheet_id: str, sheet_filter: Optional[List[str]] = None):
+        """
+        Retrieves the sheet titles from a spreadsheet matching the given id and sheet filter.
+
+        :param spreadsheet_id: The spreadsheet id.
 
 Review comment:
   Why there are no :type param: here and within others methods?

----------------------------------------------------------------
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] turbaszek commented on a change in pull request #7866: Add download/upload operators for GCS and Google Sheets

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #7866: Add download/upload operators for GCS and Google Sheets
URL: https://github.com/apache/airflow/pull/7866#discussion_r399300943
 
 

 ##########
 File path: airflow/providers/google/suite/operators/sheets.py
 ##########
 @@ -0,0 +1,215 @@
+# 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.
+
+import csv
+from tempfile import NamedTemporaryFile
+from typing import Any, Dict, List, Optional
+
+from airflow.models import BaseOperator
+from airflow.providers.google.cloud.hooks.gcs import GCSHook
+from airflow.providers.google.suite.hooks.sheets import GSheetsHook
 
 Review comment:
   We can do it in next PR

----------------------------------------------------------------
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] michalslowikowski00 commented on a change in pull request #7866: Add download/upload operators for GCS and Google Sheets

Posted by GitBox <gi...@apache.org>.
michalslowikowski00 commented on a change in pull request #7866: Add download/upload operators for GCS and Google Sheets
URL: https://github.com/apache/airflow/pull/7866#discussion_r397846194
 
 

 ##########
 File path: airflow/providers/google/suite/hooks/sheets.py
 ##########
 @@ -375,3 +375,60 @@ def batch_clear(self, spreadsheet_id: str, ranges: List) -> Dict:
         ).execute(num_retries=self.num_retries)
 
         return response
+
+    def get_sheet_titles(self, spreadsheet_id: str, sheet_filter: Optional[List[str]] = None):
+        """
+        Retrieves the sheet titles from a spreadsheet matching the given id and sheet filter.
+
+        :param spreadsheet_id: The spreadsheet id.
+        :param sheet_filter: List of sheet title to retrieve from sheet.
+        :return: An list of sheet titles from the specified sheet that match
+            the sheet filter.
+        """
+        response = (
+            self.get_conn()  # pylint: disable=no-member
+            .spreadsheets()
+            .get(spreadsheetId=spreadsheet_id)
+            .execute(num_retries=self.num_retries)
+        )
+
+        if sheet_filter:
+            titles = [
+                sh['properties']['title'] for sh in response['sheets']
+                if sh['properties']['title'] in sheet_filter
+            ]
+        else:
+            titles = [sh['properties']['title'] for sh in response['sheets']]
+        return titles
+
+    def get_spreadsheet(self, spreadsheet_id: str):
+        """
+        Retrieves spreadsheet matching the given id.
+
+        :param spreadsheet_id: The spreadsheet id.
+        :return: An spreadsheet that matches the sheet filter.
+        """
+        response = (
+            self.get_conn()  # pylint: disable=no-member
+            .spreadsheets()
+            .get(spreadsheetId=spreadsheet_id)
+            .execute(num_retries=self.num_retries)
+        )
+        return response
+
+    def create_spreadsheet(self, spreadsheet: Dict[str, Any]) -> Dict[str, Any]:
+        """
+        Creates a spreadsheet, returning the newly created spreadsheet.
+
+        :param spreadsheet: an instance of Spreadsheet
 
 Review comment:
   Above methods docstrings have `:return:`.  

----------------------------------------------------------------
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] michalslowikowski00 commented on issue #7866: Add download/upload operators for GCS and Google Sheets

Posted by GitBox <gi...@apache.org>.
michalslowikowski00 commented on issue #7866: Add download/upload operators for GCS and Google Sheets
URL: https://github.com/apache/airflow/pull/7866#issuecomment-605033459
 
 
   🚀 
   

----------------------------------------------------------------
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] turbaszek commented on a change in pull request #7866: Add download/upload operators for GCS and Google Sheets

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #7866: Add download/upload operators for GCS and Google Sheets
URL: https://github.com/apache/airflow/pull/7866#discussion_r397895750
 
 

 ##########
 File path: airflow/providers/google/suite/hooks/sheets.py
 ##########
 @@ -375,3 +375,60 @@ def batch_clear(self, spreadsheet_id: str, ranges: List) -> Dict:
         ).execute(num_retries=self.num_retries)
 
         return response
+
+    def get_sheet_titles(self, spreadsheet_id: str, sheet_filter: Optional[List[str]] = None):
+        """
+        Retrieves the sheet titles from a spreadsheet matching the given id and sheet filter.
+
+        :param spreadsheet_id: The spreadsheet id.
 
 Review comment:
   We have type annotations, however, I think I should add them for docs sake - @mik-laj ?

----------------------------------------------------------------
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] potiuk commented on issue #7866: Add download/upload operators for GCS and Google Sheets

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #7866: Add download/upload operators for GCS and Google Sheets
URL: https://github.com/apache/airflow/pull/7866#issuecomment-605060365
 
 
   Go!

----------------------------------------------------------------
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] turbaszek merged pull request #7866: Add download/upload operators for GCS and Google Sheets

Posted by GitBox <gi...@apache.org>.
turbaszek merged pull request #7866: Add download/upload operators for GCS and Google Sheets
URL: https://github.com/apache/airflow/pull/7866
 
 
   

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