beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Work logged] (BEAM-2264) Re-use credential instead of generating a new one one each GCS call
Date Fri, 23 Mar 2018 00:30:00 GMT

     [ https://issues.apache.org/jira/browse/BEAM-2264?focusedWorklogId=83403&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-83403
]

ASF GitHub Bot logged work on BEAM-2264:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 23/Mar/18 00:29
            Start Date: 23/Mar/18 00:29
    Worklog Time Spent: 10m 
      Work Description: aaltay closed pull request #4891: [BEAM-2264] Credentials were not
being reused between GCS calls
URL: https://github.com/apache/beam/pull/4891
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/sdks/python/apache_beam/io/gcp/gcsio.py b/sdks/python/apache_beam/io/gcp/gcsio.py
index f687686fd64..c7986cdb672 100644
--- a/sdks/python/apache_beam/io/gcp/gcsio.py
+++ b/sdks/python/apache_beam/io/gcp/gcsio.py
@@ -146,6 +146,8 @@ class GcsIOError(IOError, retry.PermanentException):
 class GcsIO(object):
   """Google Cloud Storage I/O client."""
 
+  local_state = threading.local()
+
   def __new__(cls, storage_client=None):
     if storage_client:
       # This path is only used for testing.
@@ -155,7 +157,7 @@ def __new__(cls, storage_client=None):
       # creating more than one storage client for each thread, since each
       # initialization requires the relatively expensive step of initializing
       # credentaials.
-      local_state = threading.local()
+      local_state = GcsIO.local_state
       if getattr(local_state, 'gcsio_instance', None) is None:
         credentials = auth.get_service_credentials()
         storage_client = storage.StorageV1(


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 83403)
    Time Spent: 50m  (was: 40m)

> Re-use credential instead of generating a new one one each GCS call
> -------------------------------------------------------------------
>
>                 Key: BEAM-2264
>                 URL: https://issues.apache.org/jira/browse/BEAM-2264
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-py-core
>            Reporter: Luke Cwik
>            Assignee: Ahmet Altay
>            Priority: Minor
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> We should cache the credential used within a Pipeline and re-use it instead of generating
a new one on each GCS call. When executing (against 2.0.0 RC2):
> {code}
> python -m apache_beam.examples.wordcount --input "gs://dataflow-samples/shakespeare/*"
--output local_counts
> {code}
> Note that we seemingly generate a new access token each time instead of when a refresh
is required.
> {code}
>   super(GcsIO, cls).__new__(cls, storage_client))
> INFO:root:Starting the size estimation of the input
> INFO:oauth2client.transport:Attempting refresh to obtain initial access_token
> INFO:oauth2client.client:Refreshing access_token
> INFO:root:Finished the size estimation of the input at 1 files. Estimation took 0.286200046539
seconds
> INFO:root:Running pipeline with DirectRunner.
> INFO:root:Starting the size estimation of the input
> INFO:oauth2client.transport:Attempting refresh to obtain initial access_token
> INFO:oauth2client.client:Refreshing access_token
> INFO:root:Finished the size estimation of the input at 43 files. Estimation took 0.205624818802
seconds
> INFO:oauth2client.transport:Attempting refresh to obtain initial access_token
> INFO:oauth2client.client:Refreshing access_token
> INFO:oauth2client.transport:Attempting refresh to obtain initial access_token
> INFO:oauth2client.client:Refreshing access_token
> INFO:oauth2client.transport:Attempting refresh to obtain initial access_token
> INFO:oauth2client.client:Refreshing access_token
> INFO:oauth2client.transport:Attempting refresh to obtain initial access_token
> INFO:oauth2client.client:Refreshing access_token
> INFO:oauth2client.transport:Attempting refresh to obtain initial access_token
> ... many more times ...
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message