Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize client usage #1173

Merged
merged 9 commits into from
Sep 23, 2024
Merged

Normalize client usage #1173

merged 9 commits into from
Sep 23, 2024

Conversation

vachillo
Copy link
Member

@vachillo vachillo commented Sep 13, 2024

Describe your changes

This normalizes the usage and naming of API clients in various drivers throughout the framework.

Today, any parameters set after init on any drivers that use a client are ignored because the client is typically initialized during driver initialization via an attrs Factory. Adding @lazy_property to the clients allow for making parameter modifications on the Driver before the client is used, namely in the global Defaults object. see #1174 for an example.

Issue ticket number and link

#1174

@vachillo vachillo marked this pull request as ready for review September 16, 2024 15:22
@vachillo vachillo force-pushed the lazy_client branch 5 times, most recently from 2858f4e to 6adac93 Compare September 18, 2024 19:41
Copy link
Member

@collindutter collindutter left a comment

Choose a reason for hiding this comment

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

Nice work, just a couple minor things

CHANGELOG.md Outdated
Comment on lines 10 to 26
- **BREAKING**: Renamed parameter `bedrock_client` on `AmazonBedrockCohereEmbeddingDriver` to `client`.
- **BREAKING**: Renamed parameter `bedrock_client` on `AmazonBedrockTitanEmbeddingDriver` to `client`.
- **BREAKING**: Renamed parameter `bedrock_client` on `AmazonBedrockImageGenerationDriver` to `client`.
- **BREAKING**: Renamed parameter `bedrock_client` on `AmazonBedrockImageQueryDriver` to `client`.
- **BREAKING**: Renamed parameter `bedrock_client` on `AmazonBedrockPromptDriver` to `client`.
- **BREAKING**: Renamed parameter `sagemaker_client` on `AmazonSageMakerJumpstartEmbeddingDriver` to `client`.
- **BREAKING**: Renamed parameter `sagemaker_client` on `AmazonSageMakerJumpstartPromptDriver` to `client`.
- **BREAKING**: Renamed parameter `sqs_client` on `AmazonSqsEventListenerDriver` to `client`.
- **BREAKING**: Renamed parameter `iotdata_client` on `AwsIotCoreEventListenerDriver` to `client`.
- **BREAKING**: Renamed parameter `s3_client` on `AmazonS3FileManagerDriver` to `client`.
- **BREAKING**: Renamed parameter `s3_client` on `AwsS3Tool` to `client`.
- **BREAKING**: Renamed parameter `pusher_client` on `PusherEventListenerDriver` to `client`.
- **BREAKING**: Renamed parameter `mq` on `MarqoVectorStoreDriver` to `client`.
- **BREAKING**: Renamed parameter `model_client` on `GooglePromptDriver` to `client`.
- **BREAKING**: Renamed parameter `model_client` on `GoogleTokenizer` to `client`.
- **BREAKING**: Renamed parameter `pipe` on `HuggingFacePipelinePromptDriver` to `text_generation_pipeline`.
- **BREAKING**: Renamed parameter `engine` on `PgVectorVectorStoreDriver` to `sqlalchemy_engine`.
Copy link
Member

Choose a reason for hiding this comment

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

Let's move this under a single BREAKING item with a nested list.

Comment on lines 39 to 41
_text_generation_pipeline: TextGenerationPipeline = field(
default=None, kw_only=True, alias="text_generation_pipeline", metadata={"serializable": False}
)
Copy link
Member

Choose a reason for hiding this comment

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

I know I'm contradicting a point I made offline, but what if we change this to support non-text generation pipelines in the future? Maybe it's better to name off the base class: Pipeline.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah went back and forth, will update

table_name: str = field(kw_only=True, metadata={"serializable": True})
_model: Any = field(default=Factory(lambda self: self.default_vector_model(), takes_self=True))
_sqlalchemy_engine: sqlalchemy.Engine = field(default=None, kw_only=True, metadata={"serializable": False})
Copy link
Member

Choose a reason for hiding this comment

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

I think this can stay as engine.

default=Factory(lambda self: self.session.client("bedrock-runtime"), takes_self=True),
kw_only=True,
)
_client: Any = field(default=None, kw_only=True, alias="client", metadata={"serializable": False})
Copy link
Member

Choose a reason for hiding this comment

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

Can we add types to all the Amazon Drivers or does that break tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

will give it a shot

collindutter
collindutter previously approved these changes Sep 23, 2024
@collindutter collindutter merged commit e94422f into dev Sep 23, 2024
15 checks passed
@collindutter collindutter deleted the lazy_client branch September 23, 2024 20:18
@vachillo
Copy link
Member Author

closes #1174

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