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/19 10:43:25 UTC

[GitHub] [airflow] baolsen commented on issue #7441: [AIRFLOW-6822] AWS hooks should cache boto3 client

baolsen commented on issue #7441: [AIRFLOW-6822] AWS hooks should cache boto3 client
URL: https://github.com/apache/airflow/pull/7441#issuecomment-588156126
 
 
   > To duplicate my comments from the Jira issue. I feel we could do this nicer with a lot less duplication:
   > 
   > In AwsHook:
   > 
   > ```
   > from cached_property import cached_property
   > 
   >     @cached_property
   >     def conn(self):
   >         return self.get_client_type(self.client_type, region=self.region_name)
   > 
   >     def get_conn(self):
   >         # Compat shim
   >         return self.conn
   > ```
   > 
   > And then in each subclass we only need to define:
   > 
   > ```
   > class S3Hook(AwsHook):
   >     client_type = "S3"
   > ```
   > 
   > for instance.
   > 
   > The lambda hook would need a custom property as it takes an extra arg, but the others wouldn't.
   
   Makes sense. I had some trouble caching the get_client_type method due to the parameters for region etc, but your approach looks like it avoids that issue by wrapping it nicely. Thanks

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