-
Notifications
You must be signed in to change notification settings - Fork 152
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
Add LocalFileManagerDriver #738
Conversation
a4f6f0f
to
77fef0e
Compare
Reverted to draft to make some changes I realized I needed+wanted to make while testing:
|
77fef0e
to
7446687
Compare
from typing import Optional | ||
from attr import Factory, define, field | ||
from griptape.artifacts import BaseArtifact, ErrorArtifact, TextArtifact, InfoArtifact, ListArtifact | ||
import griptape.loaders as loaders |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import alias is used to resolve a circular dependency between the drivers and loaders illustrated by the error shown below. Would be nice to have a more elegant solution, but I haven't found one yet.
_________________________________________________________ ERROR collecting tests/unit/loaders/test_blob_loader.py __________________________________________________________
ImportError while importing test module '/Users/dylan/Documents/griptape/tests/unit/loaders/test_blob_loader.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py:90: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/unit/loaders/test_blob_loader.py:2: in <module>
from griptape.loaders.blob_loader import BlobLoader
griptape/loaders/__init__.py:2: in <module>
from .base_text_loader import BaseTextLoader
griptape/loaders/base_text_loader.py:11: in <module>
from griptape.drivers import BaseEmbeddingDriver
griptape/drivers/__init__.py:96: in <module>
from .file_manager.base_file_manager_driver import BaseFileManagerDriver
griptape/drivers/file_manager/base_file_manager_driver.py:6: in <module>
from griptape.loaders import BaseLoader, BlobLoader, CsvLoader, ImageLoader, PdfLoader, TextLoader
E ImportError: cannot import name 'BlobLoader' from partially initialized module 'griptape.loaders' (most likely due to a circular import) (/Users/dylan/Documents/griptape/griptape/loaders/__init__.py)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The griptape.drivers
module is becoming quite large and causing more and more circular dependency issues as we integrate Drivers in different parts of the framework. I guess if this works it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Changes:
BaseFileManagerDriver
LocalFileManagerDriver
FileManager
.FileManager.file_manager_driver
BaseLoader.encoding
field. This allows theLocalFileManagerDriver
to save files with the same encoding as is used for loading them. This is possible without modifyingBaseLoader
, but not doing so would be more fragile and awkward.BlobLoader