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:
[email protected]


With regards,
Apache Git Services

Reply via email to