fallbacks3 0.3.1__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/PKG-INFO +2 -2
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/fallbacks3/provider/provider.py +11 -3
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/fallbacks3/storage.py +6 -0
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/fallbacks3.egg-info/PKG-INFO +2 -2
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/pyproject.toml +2 -2
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/README.md +0 -0
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/fallbacks3/__init__.py +0 -0
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/fallbacks3/config.py +0 -0
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/fallbacks3/provider/__init__.py +0 -0
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/fallbacks3/provider/config_credentials.py +0 -0
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/fallbacks3/utils/__init__.py +0 -0
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/fallbacks3/utils/uri.py +0 -0
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/fallbacks3.egg-info/SOURCES.txt +0 -0
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/fallbacks3.egg-info/dependency_links.txt +0 -0
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/fallbacks3.egg-info/requires.txt +0 -0
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/fallbacks3.egg-info/top_level.txt +0 -0
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/setup.cfg +0 -0
- {fallbacks3-0.3.1 → fallbacks3-0.4.0}/tests/test_fallbacks3.py +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fallbacks3
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: S3-compatible storage library with automatic fallback support
|
|
5
5
|
Author-email: Mila de Oliveira <mila.oliveira@palver.com.br>
|
|
6
6
|
Project-URL: Homepage, https://github.com/palverdata/fallbacks3
|
|
7
7
|
Project-URL: Repository, https://github.com/palverdata/fallbacks3
|
|
8
8
|
Project-URL: Issues, https://github.com/palverdata/fallbacks3/issues
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
Requires-Dist: boto3>=1.26.0
|
|
12
12
|
Requires-Dist: pydantic-settings>=2.0.0
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
4
|
-
|
|
5
3
|
from boto3 import client
|
|
4
|
+
from boto3.s3.transfer import TransferConfig
|
|
6
5
|
from botocore.client import Config as BotoConfig
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
7
|
|
|
8
8
|
if TYPE_CHECKING:
|
|
9
9
|
from mypy_boto3_s3.client import S3Client
|
|
@@ -18,6 +18,7 @@ class S3Provider:
|
|
|
18
18
|
endpoint: str,
|
|
19
19
|
access_key_id: str,
|
|
20
20
|
secret_access_key: str,
|
|
21
|
+
transfer_config: TransferConfig | None = None,
|
|
21
22
|
):
|
|
22
23
|
"""Initialize S3 provider with credentials.
|
|
23
24
|
|
|
@@ -26,9 +27,12 @@ class S3Provider:
|
|
|
26
27
|
endpoint: S3 endpoint URL with scheme (e.g., 'https://ps3.palver.com')
|
|
27
28
|
access_key_id: Access key ID
|
|
28
29
|
secret_access_key: Secret access key
|
|
30
|
+
transfer_config: Optional boto3 TransferConfig for upload behaviour.
|
|
31
|
+
Defaults to boto3's built-in defaults when None.
|
|
29
32
|
"""
|
|
30
33
|
self.provider_scheme: str = provider_scheme
|
|
31
34
|
self.endpoint: str = endpoint
|
|
35
|
+
self.transfer_config: TransferConfig | None = transfer_config
|
|
32
36
|
self.client: S3Client = client(
|
|
33
37
|
"s3",
|
|
34
38
|
config=BotoConfig(signature_version="s3v4"),
|
|
@@ -49,7 +53,11 @@ class S3Provider:
|
|
|
49
53
|
Full URI of the uploaded file in format:
|
|
50
54
|
<provider_scheme>://<bucket>/<file_name>
|
|
51
55
|
"""
|
|
52
|
-
self.client.upload_file(
|
|
56
|
+
self.client.upload_file(
|
|
57
|
+
file_path, bucket, file_name, Config=self.transfer_config
|
|
58
|
+
) if self.transfer_config else self.client.upload_file(
|
|
59
|
+
file_path, bucket, file_name
|
|
60
|
+
)
|
|
53
61
|
return f"{self.provider_scheme}://{bucket}/{file_name}"
|
|
54
62
|
|
|
55
63
|
def download_file(self, file_name: str, local_path: str, bucket: str) -> str:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
|
|
2
3
|
from fallbacks3.config import config
|
|
3
4
|
from fallbacks3.provider import S3Provider
|
|
4
5
|
from fallbacks3.utils.uri import build_provider_credentials, parse_uri
|
|
@@ -12,6 +13,7 @@ class Storage:
|
|
|
12
13
|
self,
|
|
13
14
|
providers: str = config.providers,
|
|
14
15
|
fallback_provider: str = config.fallback_provider,
|
|
16
|
+
provider_configs: dict[str, dict] | None = None,
|
|
15
17
|
):
|
|
16
18
|
"""Initialize storage with multiple providers.
|
|
17
19
|
|
|
@@ -23,6 +25,9 @@ class Storage:
|
|
|
23
25
|
fallback_provider: Provider scheme to use for fallback (e.g., "r2").
|
|
24
26
|
Must be one of the providers in the providers string.
|
|
25
27
|
Defaults to FALLBACK_PROVIDER environment variable.
|
|
28
|
+
provider_configs: Optional per-provider kwargs keyed by provider scheme,
|
|
29
|
+
merged into the S3Provider constructor for the matching provider.
|
|
30
|
+
Example: {"mega": {"transfer_config": TransferConfig(...)}}
|
|
26
31
|
|
|
27
32
|
Raises:
|
|
28
33
|
ValueError: If fallback_provider not found in providers
|
|
@@ -39,6 +44,7 @@ class Storage:
|
|
|
39
44
|
endpoint=creds.endpoint,
|
|
40
45
|
access_key_id=creds.access_key,
|
|
41
46
|
secret_access_key=creds.secret_key,
|
|
47
|
+
**(provider_configs or {}).get(creds.provider_scheme, {}),
|
|
42
48
|
)
|
|
43
49
|
|
|
44
50
|
self.fallback_provider: str = fallback_provider
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fallbacks3
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: S3-compatible storage library with automatic fallback support
|
|
5
5
|
Author-email: Mila de Oliveira <mila.oliveira@palver.com.br>
|
|
6
6
|
Project-URL: Homepage, https://github.com/palverdata/fallbacks3
|
|
7
7
|
Project-URL: Repository, https://github.com/palverdata/fallbacks3
|
|
8
8
|
Project-URL: Issues, https://github.com/palverdata/fallbacks3/issues
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
Requires-Dist: boto3>=1.26.0
|
|
12
12
|
Requires-Dist: pydantic-settings>=2.0.0
|
|
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "fallbacks3"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "S3-compatible storage library with automatic fallback support"
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
11
|
authors = [
|
|
12
12
|
{name = "Mila de Oliveira", email = "mila.oliveira@palver.com.br"}
|
|
13
13
|
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|