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

Remove boto3 from types #741

Merged
merged 2 commits into from
Apr 11, 2024
Merged

Remove boto3 from types #741

merged 2 commits into from
Apr 11, 2024

Conversation

collindutter
Copy link
Member

@collindutter collindutter commented Apr 10, 2024

Fixes serialization crash when boto3 is not installed via extras. Side effect of this is that we cannot use boto3 type hints (boto.Session) in any serializable fields.

@collindutter collindutter requested a review from a team April 10, 2024 21:28
vachillo
vachillo previously approved these changes Apr 10, 2024
dylanholmes
dylanholmes previously approved these changes Apr 11, 2024

# These modules are required to avoid `NameError`s when resolving types.
from griptape.drivers import BaseConversationMemoryDriver, BasePromptDriver, BasePromptModelDriver
from griptape.structures import Structure
from griptape.utils import PromptStack
from griptape.tokenizers.base_tokenizer import BaseTokenizer
import boto3

boto3 = import_optional_dependency("boto3") if is_dependency_installed("boto3") else {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is ever needed in more than one place, then might be nice to have something like try_import_optional_dependency().

Btw, what happens if you default to None instead of {}?

Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly not totally sure, I think it was working fine with both. But I updated to a more appropriate value Any since that's an actual python type.

@collindutter collindutter merged commit fe53d86 into dev Apr 11, 2024
6 checks passed
@collindutter collindutter deleted the fix/event-drivers-2 branch April 11, 2024 20:36
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.

4 participants