Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Cloud storage improvements, closes #821

davidmezzetti350087ee1d54
diff --git a/docs/embeddings/configuration/cloud.md b/docs/embeddings/configuration/cloud.md
index 2eb7347b..3e4c6a5b 100644
--- a/docs/embeddings/configuration/cloud.md
+++ b/docs/embeddings/configuration/cloud.md
@@ -11,7 +11,7 @@ provider: string
Cloud provider. Can be one of the following:
-- Cloud object storage. Set to one of these [providers](https://libcloud.readthedocs.io/en/stable/storage/supported_providers.html).
+- Cloud object storage. Set to one of these [providers](https://libcloud.readthedocs.io/en/stable/storage/supported_providers.html). Use the text shown in the `Provider Constant` column as lower case.
- Hugging Face Hub. Set to `huggingface-hub`.
@@ -44,6 +44,18 @@ secret: string
Provider-specific access secret. Can also be set via `ACCESS_SECRET` environment variable. Ensure the configuration file is secured if added to the file. When using implicit authentication, this option is not required.
+### prefix
+```yaml
+prefix: string
+```
+
+Optional object prefix. Object storage doesn't have the concept of a directory but a prefix is similar. For example, a prefix could be `base/dir`. This helps with organizing data in an object storage bucket.
+
+More can be found at the following links.
+
+- [Organizing objects using prefixes](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-prefixes.html)
+- [libcloud container method documentation](https://libcloud.readthedocs.io/en/stable/storage/api.html#libcloud.storage.base.StorageDriver.iterate_container_objects)
+
### host
```yaml
host: string
diff --git a/src/python/txtai/cloud/storage.py b/src/python/txtai/cloud/storage.py
index d4b399a1..e3108741 100644
--- a/src/python/txtai/cloud/storage.py
+++ b/src/python/txtai/cloud/storage.py
@@ -34,7 +34,7 @@ class ObjectStorage(Cloud):
True if this is an object storage provider
"""
- return LIBCLOUD and provider and provider in DRIVERS
+ return LIBCLOUD and provider and provider.lower() in [x.lower() for x in DRIVERS]
def __init__(self, config):
super().__init__(config)
@@ -67,6 +67,12 @@ class ObjectStorage(Cloud):
# Download archive file
if self.isarchive(path):
obj = self.client.get_object(self.config["container"], self.objectname(path))
+
+ # Create local directory, if necessary
+ directory = os.path.dirname(path)
+ if directory:
+ os.makedirs(directory, exist_ok=True)
+
obj.download(path, overwrite_existing=True)
# Download files in container. Optionally filter with a provided prefix.