Skip to content

Conversation

@mliu-cloudera
Copy link
Collaborator

In the spirit of moving operations from app startup to app runtime (though this will have a negligible impact on startup time).

Also helps lay groundwork for #307.

Comment on lines -63 to 67
self.bucket_prefix = settings.document_bucket_prefix
self._s3_client: S3Client | None = None

@property
@functools.cached_property
def s3_client(self) -> S3Client:
"""Lazy initialization of S3 client."""
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out functools.cached_property is precisely the thing for "lazily initialize an instance attribute"!

This also helps avoid conflating self.s3_client and self._s3_client since conventionally, both could be used inside a class's methods.

Comment on lines 60 to 62
def __init__(self, bucket_name: str = settings.document_bucket):
self.bucket_name = bucket_name
def __init__(self):
super().__init__()
self.bucket_name = settings.document_bucket
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving bucket_name out of the initializer params since we never use it.

Base automatically changed from liu/params to main August 27, 2025 18:09
@mliu-cloudera mliu-cloudera merged commit 1b91b85 into main Aug 27, 2025
3 checks passed
@mliu-cloudera mliu-cloudera deleted the liu/chm branch August 27, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants