multi-storage-client 0.12.1__py3-none-any.whl
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.
- multi_storage_client-0.12.1.dist-info/LICENSE +202 -0
- multi_storage_client-0.12.1.dist-info/METADATA +286 -0
- multi_storage_client-0.12.1.dist-info/RECORD +39 -0
- multi_storage_client-0.12.1.dist-info/WHEEL +4 -0
- multi_storage_client-0.12.1.dist-info/entry_points.txt +6 -0
- multistorageclient/__init__.py +72 -0
- multistorageclient/cache.py +332 -0
- multistorageclient/client.py +301 -0
- multistorageclient/commands/__init__.py +14 -0
- multistorageclient/commands/msc_benchmark.py +185 -0
- multistorageclient/config.py +402 -0
- multistorageclient/contrib/__init__.py +14 -0
- multistorageclient/contrib/async_fs.py +343 -0
- multistorageclient/contrib/numpy.py +88 -0
- multistorageclient/contrib/os/__init__.py +24 -0
- multistorageclient/contrib/os/path.py +84 -0
- multistorageclient/contrib/pickle.py +82 -0
- multistorageclient/contrib/torch.py +44 -0
- multistorageclient/contrib/xarray.py +43 -0
- multistorageclient/contrib/zarr.py +99 -0
- multistorageclient/file.py +603 -0
- multistorageclient/generators/__init__.py +21 -0
- multistorageclient/generators/manifest_metadata.py +83 -0
- multistorageclient/instrumentation/__init__.py +155 -0
- multistorageclient/instrumentation/utils.py +424 -0
- multistorageclient/providers/__init__.py +55 -0
- multistorageclient/providers/ais.py +288 -0
- multistorageclient/providers/azure.py +302 -0
- multistorageclient/providers/base.py +136 -0
- multistorageclient/providers/gcs.py +262 -0
- multistorageclient/providers/manifest_metadata.py +351 -0
- multistorageclient/providers/oci.py +351 -0
- multistorageclient/providers/posix_file.py +233 -0
- multistorageclient/providers/s3.py +454 -0
- multistorageclient/retry.py +53 -0
- multistorageclient/schema.py +161 -0
- multistorageclient/shortcuts.py +169 -0
- multistorageclient/types.py +415 -0
- multistorageclient/utils.py +157 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: multi-storage-client
|
|
3
|
+
Version: 0.12.1
|
|
4
|
+
Summary: Storage client implementation for accessing different object stores.
|
|
5
|
+
Home-page: https://github.com/NVIDIA/multi-storage-client
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Author: NVIDIA Multi-Storage Client Team
|
|
8
|
+
Author-email: nv-multi-storage-client@nvidia.com
|
|
9
|
+
Requires-Python: >=3.8.1,<4.0.0
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Provides-Extra: aistore
|
|
18
|
+
Provides-Extra: azure-storage-blob
|
|
19
|
+
Provides-Extra: boto3
|
|
20
|
+
Provides-Extra: fsspec
|
|
21
|
+
Provides-Extra: google-cloud-storage
|
|
22
|
+
Provides-Extra: oci
|
|
23
|
+
Provides-Extra: torch
|
|
24
|
+
Provides-Extra: xarray
|
|
25
|
+
Provides-Extra: zarr
|
|
26
|
+
Requires-Dist: aistore (>=1.8.1) ; extra == "aistore"
|
|
27
|
+
Requires-Dist: azure-storage-blob (>=12.0.0) ; extra == "azure-storage-blob"
|
|
28
|
+
Requires-Dist: boto3 (>=1.28.17) ; extra == "boto3"
|
|
29
|
+
Requires-Dist: datasketches (>=5.1.0,<6.0.0)
|
|
30
|
+
Requires-Dist: filelock (>=3.14.0,<4.0.0)
|
|
31
|
+
Requires-Dist: fsspec (>=2022.8.2) ; extra == "fsspec"
|
|
32
|
+
Requires-Dist: google-cloud-storage (>=2.10.0) ; extra == "google-cloud-storage"
|
|
33
|
+
Requires-Dist: jsonschema (>=4,<5)
|
|
34
|
+
Requires-Dist: numpy (<1.25.0) ; python_version >= "3.8" and python_version < "3.9"
|
|
35
|
+
Requires-Dist: numpy (>=1.24.0) ; python_version >= "3.9" and python_version < "4.0"
|
|
36
|
+
Requires-Dist: oci (>=2.117.0) ; extra == "oci"
|
|
37
|
+
Requires-Dist: opentelemetry-api (>=1.24.0,<2.0.0)
|
|
38
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http (>=1.24.0,<2.0.0)
|
|
39
|
+
Requires-Dist: opentelemetry-sdk (>=1.24.0,<2.0.0)
|
|
40
|
+
Requires-Dist: python-dateutil (>=2.7.0,<3.0.0)
|
|
41
|
+
Requires-Dist: pyyaml (>=6,<7)
|
|
42
|
+
Requires-Dist: torch (>=2.0.0,<3.0.0) ; extra == "torch"
|
|
43
|
+
Requires-Dist: xarray (<=2023.1.0) ; (python_version < "3.9") and (extra == "xarray")
|
|
44
|
+
Requires-Dist: xarray (>=2023.10.0) ; (python_version >= "3.9" and python_version < "4.0") and (extra == "xarray")
|
|
45
|
+
Requires-Dist: zarr (>=2.15.0) ; extra == "zarr"
|
|
46
|
+
Project-URL: Repository, https://github.com/NVIDIA/multi-storage-client
|
|
47
|
+
Description-Content-Type: text/markdown
|
|
48
|
+
|
|
49
|
+
# Multi-Storage Client
|
|
50
|
+
|
|
51
|
+
`multi-storage-client` is a Python package designed to provide seamless access to multiple object stores, including AWS S3, Google Cloud Storage, Oracle Cloud Infrastructure, and Azure. Its simple API allows for easy interaction with various storage services, making file operations like reading and writing efficient and straightforward.
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
You can install multi-storage-client using one of following methods:
|
|
56
|
+
|
|
57
|
+
**1. Clone the repository and install:**
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
git clone https://gitlab-master.nvidia.com/nsv-data-platform/multi-storage-client.git
|
|
61
|
+
cd multi-storage-client
|
|
62
|
+
pip install .
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**2. Install using pip directly from NVIDIA’s repository:**
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
pip install --extra-index-url https://urm.nvidia.com/artifactory/api/pypi/sw-ngc-data-platform-pypi/simple multi-storage-client
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**3. Install object storage SDKs:**
|
|
72
|
+
|
|
73
|
+
You need to install object storage SDKs for the `multi-storage-client` to access the objects.
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
# S3
|
|
77
|
+
pip install "multi-storage-client[boto3]"
|
|
78
|
+
|
|
79
|
+
# Google Cloud Storage
|
|
80
|
+
pip install "multi-storage-client[google-cloud-storage]"
|
|
81
|
+
|
|
82
|
+
# OCI Object Storage
|
|
83
|
+
pip install "multi-storage-client[oci]"
|
|
84
|
+
|
|
85
|
+
# Azure Blob Store
|
|
86
|
+
pip install "multi-storage-client[azure-storage-blob]"
|
|
87
|
+
|
|
88
|
+
# AIStore
|
|
89
|
+
pip install "multi-storage-client[aistore]"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Usage
|
|
93
|
+
|
|
94
|
+
`multi-storage-client` simplifies access to object storage services through an intuitive API, allowing you to read, write, and list files with ease.
|
|
95
|
+
|
|
96
|
+
### Quick Start
|
|
97
|
+
|
|
98
|
+
First, create a configuration file to define your storage providers. The default configuration file is located at `~/.msc_config.yaml`, but you can specify a different path using the `MSC_CONFIG` environment variable.
|
|
99
|
+
|
|
100
|
+
```yaml
|
|
101
|
+
profiles:
|
|
102
|
+
default:
|
|
103
|
+
storage_provider:
|
|
104
|
+
type: file
|
|
105
|
+
options:
|
|
106
|
+
base_path: /
|
|
107
|
+
swift-pdx:
|
|
108
|
+
storage_provider:
|
|
109
|
+
type: s3
|
|
110
|
+
options:
|
|
111
|
+
region_name: us-east-1
|
|
112
|
+
endpoint_url: https://pdx.s8k.io
|
|
113
|
+
base_path: my-bucket
|
|
114
|
+
credentials_provider:
|
|
115
|
+
type: S3Credentials
|
|
116
|
+
options:
|
|
117
|
+
access_key: ${S3_ACCESS_KEY}
|
|
118
|
+
secret_key: ${S3_SECRET_KEY}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Once your configuration is in place, you can access files using simple methods:
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
import multistorageclient as msc
|
|
125
|
+
|
|
126
|
+
# Open file
|
|
127
|
+
# Note: The full path of this file is `my-bucket/dataset/webdataset.tar` on PDX.
|
|
128
|
+
# Here, `my-bucket` is defined in the `base_path` of the configuration JSON file,
|
|
129
|
+
# and `dataset/webdataset.tar` is the relative path within the bucket.
|
|
130
|
+
with msc.open('msc://swift-pdx/dataset/webdataset.tar', 'rb') as fp:
|
|
131
|
+
fp.read()
|
|
132
|
+
|
|
133
|
+
# The open function can also take a POSIX path, which uses the `default` profile.
|
|
134
|
+
with msc.open('/usr/local/bin/python3') as fp:
|
|
135
|
+
fp.read()
|
|
136
|
+
|
|
137
|
+
# List files
|
|
138
|
+
files = msc.glob('msc://swift-pdx/dataset/**/*.tar')
|
|
139
|
+
# files = ['msc://swift-pdx/dataset/webdataset.tar']
|
|
140
|
+
|
|
141
|
+
# Open Zarr dataset
|
|
142
|
+
zarr_group = msc.zarr.open_consolidated('msc://swift-pdx/my_zarr_datasets.zarr')
|
|
143
|
+
# zarr_group = <zarr.hierarchy.Group '/'>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The custom URL format is `msc://{profile}/{path}`, where `path` can refer to a local file path or an object store location in the form of `{prefix}/{key}`.
|
|
147
|
+
|
|
148
|
+
## Developer Guide
|
|
149
|
+
|
|
150
|
+
Common recipes are provided as Just recipes. To list them, run:
|
|
151
|
+
|
|
152
|
+
```shell
|
|
153
|
+
just
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Building the Package
|
|
157
|
+
|
|
158
|
+
To do a full release build (runs static analysis + unit tests), run:
|
|
159
|
+
|
|
160
|
+
```shell
|
|
161
|
+
just build
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
If you want to use a specific Python binary such as Python 3.9, run:
|
|
165
|
+
|
|
166
|
+
```shell
|
|
167
|
+
just python-binary=python3.9 build
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Running Tests
|
|
171
|
+
|
|
172
|
+
The project includes both unit and integration tests. Here’s how to run them:
|
|
173
|
+
|
|
174
|
+
#### Unit Tests
|
|
175
|
+
|
|
176
|
+
Unit tests verify the functionality of individual components:
|
|
177
|
+
|
|
178
|
+
```shell
|
|
179
|
+
poetry run pytest tests/unit/
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### Integration Tests
|
|
183
|
+
|
|
184
|
+
Integration tests verify interactions between components and external services:
|
|
185
|
+
|
|
186
|
+
```shell
|
|
187
|
+
just start-storage-systems
|
|
188
|
+
|
|
189
|
+
just run-integration-tests
|
|
190
|
+
|
|
191
|
+
just stop-storage-systems
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
If you want to use a specific Python binary such as Python 3.9, run:
|
|
195
|
+
|
|
196
|
+
```shell
|
|
197
|
+
just python-binary=python3.9 run-integration-tests
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Configuration Schema
|
|
201
|
+
|
|
202
|
+
The basic schema for configuring `multi-storage-client` includes settings for the storage provider and credentials provider. Each profile defines how the client will connect to a specific storage service, such as AWS S3, Google Cloud Storage (GCS), Oracle Cloud Infrastructure (OCI), and Azure.
|
|
203
|
+
|
|
204
|
+
```yaml
|
|
205
|
+
# The profiles section in the configuration file is used to define different storage configurations, allowing you to manage connections to multiple storage systems with ease.
|
|
206
|
+
profiles:
|
|
207
|
+
# Define a profile named 'swift-pdx' for accessing a specific object storage.
|
|
208
|
+
swift-pdx:
|
|
209
|
+
storage_provider:
|
|
210
|
+
# Specify the type of storage provider. Supported types: s3, gcs, oci, azure, file.
|
|
211
|
+
type: s3
|
|
212
|
+
# Options for configuring the S3-compatible storage provider.
|
|
213
|
+
options:
|
|
214
|
+
region_name: us-east-1
|
|
215
|
+
endpoint_url: https://pdx.s8k.io
|
|
216
|
+
base_path: mybucket
|
|
217
|
+
|
|
218
|
+
# Define the credentials provider used for authentication with the storage service.
|
|
219
|
+
# If not specified, the default configuration of the SDK will be used.
|
|
220
|
+
credentials_provider:
|
|
221
|
+
type: S3Credentials
|
|
222
|
+
options:
|
|
223
|
+
access_key: *****
|
|
224
|
+
secret_key: *****
|
|
225
|
+
|
|
226
|
+
# Configure the local cache for storing files for repeated access.
|
|
227
|
+
cache:
|
|
228
|
+
location: /path/to/cache
|
|
229
|
+
size_mb: 50000
|
|
230
|
+
|
|
231
|
+
# Configure OpenTelemetry integration for publishing metrics and traces.
|
|
232
|
+
opentelemetry:
|
|
233
|
+
metrics:
|
|
234
|
+
exporter:
|
|
235
|
+
type: otlp
|
|
236
|
+
options:
|
|
237
|
+
endpoint: http://0.0.0.0:4318/v1/metrics
|
|
238
|
+
traces:
|
|
239
|
+
exporter:
|
|
240
|
+
type: otlp
|
|
241
|
+
options:
|
|
242
|
+
endpoint: http://0.0.0.0:4318/v1/traces
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Create Extensions
|
|
246
|
+
|
|
247
|
+
#### Credentials Provider
|
|
248
|
+
|
|
249
|
+
A `CredentialsProvider` dynamically supplies credentials for storage access. For example, when using temporary credentials, you can register a custom provider:
|
|
250
|
+
|
|
251
|
+
```yaml
|
|
252
|
+
profiles:
|
|
253
|
+
s3-iad:
|
|
254
|
+
storage_provider:
|
|
255
|
+
type: s3
|
|
256
|
+
credentials_provider:
|
|
257
|
+
type: mymodule.metadata.MyMetadataProvider
|
|
258
|
+
options: {}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
#### Metadata Provider
|
|
262
|
+
|
|
263
|
+
A `MetadataProvider` is necessary when metadata is stored separately. This can be useful for optimizing list operations or when metadata needs to be fetched from an external source.
|
|
264
|
+
|
|
265
|
+
```yaml
|
|
266
|
+
profiles:
|
|
267
|
+
s3-iad:
|
|
268
|
+
storage_provider:
|
|
269
|
+
type: s3
|
|
270
|
+
metadata_provider:
|
|
271
|
+
type: mymodule.metadata.MyMetadataProvider
|
|
272
|
+
options: {}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### Provider Bundle
|
|
276
|
+
|
|
277
|
+
When both metadata and credentials are managed by the same backend service, a `ProviderBundle` can be used to streamline the configuration.
|
|
278
|
+
|
|
279
|
+
```yaml
|
|
280
|
+
profiles:
|
|
281
|
+
s3-iad:
|
|
282
|
+
provider_bundle:
|
|
283
|
+
type: mymodule.metadata.MyProviderBundle
|
|
284
|
+
options: {}
|
|
285
|
+
```
|
|
286
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
multistorageclient/__init__.py,sha256=ivlmZgCfqf6kPmw0_RdUDTJyRGYFGVyfnrgQL7tp9oY,2130
|
|
2
|
+
multistorageclient/cache.py,sha256=Kbu52_gIUEqJXdYdl1fvwI-cWZgIzItvfHLraOf0YPM,11820
|
|
3
|
+
multistorageclient/client.py,sha256=YNt_heAJQz9Qzn2whMCNxLfjjFloIY5nhMmGxcbfgZs,12442
|
|
4
|
+
multistorageclient/commands/__init__.py,sha256=3QMzksa2HTcOPG6-2RTwrhBfDYG6S4d4WfamF9D-2tY,679
|
|
5
|
+
multistorageclient/commands/msc_benchmark.py,sha256=1pcZkqxkvSBlybhxz7CvkoowXX1oH-oCCK6_-BNBFeQ,7307
|
|
6
|
+
multistorageclient/config.py,sha256=In0MwomRajshmgLT5V6dlHOtTKhye9TpWKJEe5BVmcY,17755
|
|
7
|
+
multistorageclient/contrib/__init__.py,sha256=3QMzksa2HTcOPG6-2RTwrhBfDYG6S4d4WfamF9D-2tY,679
|
|
8
|
+
multistorageclient/contrib/async_fs.py,sha256=d-egUN0QI_FIaGrSpsWJQY8s3wpzvabvaZ74lyCaMaw,13270
|
|
9
|
+
multistorageclient/contrib/numpy.py,sha256=8DIRZUmPcddSt7nifovv42zqs2jvdpYvn2mibt3GjM4,3087
|
|
10
|
+
multistorageclient/contrib/os/__init__.py,sha256=Zzq-VXgbOoGnalobCl-WWzDh7IeteArD6FwAuTFlpIk,933
|
|
11
|
+
multistorageclient/contrib/os/path.py,sha256=Vk9Gs3osrKufVgjvJPf1yaG3ykhJmWWJYvu9WhMZQuI,2909
|
|
12
|
+
multistorageclient/contrib/pickle.py,sha256=GPl9ZICCxGFP-qXVceQLTeq4tZi_TslROeVDrM3qMog,3534
|
|
13
|
+
multistorageclient/contrib/torch.py,sha256=UCwODgt5ubuAJqOyLOYa-MievkDKk5EyT57gDiCrz-E,1475
|
|
14
|
+
multistorageclient/contrib/xarray.py,sha256=5rTPTnc-poVYjEM7uLPajFY3cyb1FCJ2TyboJxiQe-w,1815
|
|
15
|
+
multistorageclient/contrib/zarr.py,sha256=nRncjAX-p8-JR4QGJIz0UHL_Ucj1TfaEvYE2tRPYqx0,3811
|
|
16
|
+
multistorageclient/file.py,sha256=xErlMgnenWxcOzBnlIoLGt_nlq7eQrvZipoa_sGOQS0,20651
|
|
17
|
+
multistorageclient/generators/__init__.py,sha256=YyNHGhTtHbbW3aNXskywa8T9iJIXfZdM0lfa819ERZk,785
|
|
18
|
+
multistorageclient/generators/manifest_metadata.py,sha256=iBT_jKsjyH1B1LajtcpNId60RrTJx7btrxSj0E63mXg,3785
|
|
19
|
+
multistorageclient/instrumentation/__init__.py,sha256=L4WLrrDBN3DRLrUEfadka0I2CI97EBeMCIWHhc44F9I,6406
|
|
20
|
+
multistorageclient/instrumentation/utils.py,sha256=9HFoNi4TwDdu2E79RS43UwDCO26tuw5gx9ZE4J5UEbw,16803
|
|
21
|
+
multistorageclient/providers/__init__.py,sha256=vHBa5Lt5qdFUkqzrzi0tk3kD6fGoAUfNjttUyqTi8ns,1587
|
|
22
|
+
multistorageclient/providers/ais.py,sha256=mOZD5j7OcJaXKy-U5QnIbH_z_z6kmdSCnbOOW5l5XEU,12162
|
|
23
|
+
multistorageclient/providers/azure.py,sha256=oqw_G8HU-E1cJxec1v83cc2ndGLHrtHNoFlvWwzyzik,13236
|
|
24
|
+
multistorageclient/providers/base.py,sha256=Yux-g6NgzPSJEENYZiJztYhfjXvBYRMt08PwIIPo3js,5223
|
|
25
|
+
multistorageclient/providers/gcs.py,sha256=uXODHK5E1ManuGNBTFDTU0YgwLKU9CG4YzcstM64bzY,11189
|
|
26
|
+
multistorageclient/providers/manifest_metadata.py,sha256=GDiGHeHNHhOYU8W2jKihYVPJ3lcL2ggo8IIWXXh1HpE,13932
|
|
27
|
+
multistorageclient/providers/oci.py,sha256=PdEUwUVR06_7EGkbWiKqk9oi9VXrTwvtMW3z51WzNVs,15125
|
|
28
|
+
multistorageclient/providers/posix_file.py,sha256=74G6HDu74vP32S2PC0SakQC6G6Bj83XvYxzITpDVwx0,10036
|
|
29
|
+
multistorageclient/providers/s3.py,sha256=7R3JhJmKjr_BHD5mYbwPVkUe-JNeaWdBBposMaoXc0A,18909
|
|
30
|
+
multistorageclient/retry.py,sha256=Ahno5XtvRRp2Igtyyi3RqJgaQeFkf9jhBhq8_2YR9_Y,2081
|
|
31
|
+
multistorageclient/schema.py,sha256=5qdwzC8-BHASiqXBicHnMCXAKv8pOza4vPCjYaL7sBw,4819
|
|
32
|
+
multistorageclient/shortcuts.py,sha256=LHS6-zAa88sQhszXcRq1q6cFGliTuwiM_BmvfyjerBY,6930
|
|
33
|
+
multistorageclient/types.py,sha256=iAZxtFflvYsaRBdMxhcw6S6SR2Um4kXYpdfo300-qIY,13653
|
|
34
|
+
multistorageclient/utils.py,sha256=OldlNnrg5j-8UromWq1Rm3M6RxYqktAlvvthYaV9b88,5475
|
|
35
|
+
multi_storage_client-0.12.1.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
36
|
+
multi_storage_client-0.12.1.dist-info/METADATA,sha256=n63RdNg9zv0YdLQyvGSWvdsH6AXYCBGxG73Fu7dxqGE,8944
|
|
37
|
+
multi_storage_client-0.12.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
38
|
+
multi_storage_client-0.12.1.dist-info/entry_points.txt,sha256=P7ZTGt6lizkqAlAMysk0Fn_TylTF8yUHvOO6qhCUoVo,157
|
|
39
|
+
multi_storage_client-0.12.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
from types import ModuleType
|
|
17
|
+
|
|
18
|
+
from .cache import CacheConfig
|
|
19
|
+
from .client import StorageClient, StorageClientConfig
|
|
20
|
+
from .shortcuts import (
|
|
21
|
+
download_file,
|
|
22
|
+
glob,
|
|
23
|
+
is_empty,
|
|
24
|
+
open,
|
|
25
|
+
resolve_storage_client,
|
|
26
|
+
upload_file,
|
|
27
|
+
is_file,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
# Classes
|
|
32
|
+
"StorageClient",
|
|
33
|
+
"StorageClientConfig",
|
|
34
|
+
"CacheConfig",
|
|
35
|
+
|
|
36
|
+
# Shortcuts
|
|
37
|
+
"resolve_storage_client",
|
|
38
|
+
"open",
|
|
39
|
+
"glob",
|
|
40
|
+
"upload_file",
|
|
41
|
+
"download_file",
|
|
42
|
+
"is_empty",
|
|
43
|
+
"is_file",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
import importlib.util
|
|
47
|
+
import sys
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def lazy_import(name: str) -> ModuleType:
|
|
51
|
+
spec = importlib.util.find_spec(name)
|
|
52
|
+
if spec is None:
|
|
53
|
+
raise ImportError(f"Module {name} not found")
|
|
54
|
+
if spec.loader is None:
|
|
55
|
+
raise ImportError(f"Loader for module {name} not found")
|
|
56
|
+
loader = importlib.util.LazyLoader(spec.loader)
|
|
57
|
+
spec.loader = loader
|
|
58
|
+
module = importlib.util.module_from_spec(spec)
|
|
59
|
+
sys.modules[name] = module
|
|
60
|
+
loader.exec_module(module)
|
|
61
|
+
return module
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# lazy import for optional dependencies
|
|
65
|
+
# full path is needed, relative imports doesn't work here
|
|
66
|
+
numpy = lazy_import(f'{__package__}.contrib.numpy')
|
|
67
|
+
pickle = lazy_import(f'{__package__}.contrib.pickle')
|
|
68
|
+
os = lazy_import(f'{__package__}.contrib.os')
|
|
69
|
+
zarr = lazy_import(f'{__package__}.contrib.zarr')
|
|
70
|
+
async_fs = lazy_import(f'{__package__}.contrib.async_fs')
|
|
71
|
+
xr = lazy_import(f'{__package__}.contrib.xarray')
|
|
72
|
+
torch = lazy_import(f'{__package__}.contrib.torch')
|