ob-metaflow-stubs 2.11.4.1__py2.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.
- metaflow-stubs/__init__.pyi +2753 -0
- metaflow-stubs/cards.pyi +266 -0
- metaflow-stubs/cli.pyi +137 -0
- metaflow-stubs/client/__init__.pyi +993 -0
- metaflow-stubs/client/core.pyi +1425 -0
- metaflow-stubs/client/filecache.pyi +87 -0
- metaflow-stubs/events.pyi +107 -0
- metaflow-stubs/exception.pyi +98 -0
- metaflow-stubs/flowspec.pyi +297 -0
- metaflow-stubs/generated_for.txt +1 -0
- metaflow-stubs/includefile.pyi +524 -0
- metaflow-stubs/metadata/metadata.pyi +377 -0
- metaflow-stubs/metadata/util.pyi +18 -0
- metaflow-stubs/metaflow_config.pyi +263 -0
- metaflow-stubs/metaflow_current.pyi +327 -0
- metaflow-stubs/mflog/mflog.pyi +22 -0
- metaflow-stubs/multicore_utils.pyi +62 -0
- metaflow-stubs/parameters.pyi +114 -0
- metaflow-stubs/plugins/__init__.pyi +209 -0
- metaflow-stubs/plugins/airflow/__init__.pyi +9 -0
- metaflow-stubs/plugins/airflow/airflow.pyi +179 -0
- metaflow-stubs/plugins/airflow/airflow_cli.pyi +90 -0
- metaflow-stubs/plugins/airflow/airflow_decorator.pyi +50 -0
- metaflow-stubs/plugins/airflow/airflow_utils.pyi +137 -0
- metaflow-stubs/plugins/airflow/exception.pyi +27 -0
- metaflow-stubs/plugins/airflow/sensors/__init__.pyi +26 -0
- metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +60 -0
- metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +54 -0
- metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +50 -0
- metaflow-stubs/plugins/argo/__init__.pyi +9 -0
- metaflow-stubs/plugins/argo/argo_client.pyi +77 -0
- metaflow-stubs/plugins/argo/argo_events.pyi +79 -0
- metaflow-stubs/plugins/argo/argo_workflows.pyi +604 -0
- metaflow-stubs/plugins/argo/argo_workflows_cli.pyi +180 -0
- metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +169 -0
- metaflow-stubs/plugins/aws/__init__.pyi +9 -0
- metaflow-stubs/plugins/aws/aws_client.pyi +22 -0
- metaflow-stubs/plugins/aws/aws_utils.pyi +93 -0
- metaflow-stubs/plugins/aws/batch/__init__.pyi +9 -0
- metaflow-stubs/plugins/aws/batch/batch.pyi +120 -0
- metaflow-stubs/plugins/aws/batch/batch_cli.pyi +42 -0
- metaflow-stubs/plugins/aws/batch/batch_client.pyi +159 -0
- metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +145 -0
- metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +9 -0
- metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +73 -0
- metaflow-stubs/plugins/aws/step_functions/__init__.pyi +9 -0
- metaflow-stubs/plugins/aws/step_functions/dynamo_db_client.pyi +22 -0
- metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +27 -0
- metaflow-stubs/plugins/aws/step_functions/production_token.pyi +18 -0
- metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +17 -0
- metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +220 -0
- metaflow-stubs/plugins/aws/step_functions/step_functions_cli.pyi +139 -0
- metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +36 -0
- metaflow-stubs/plugins/aws/step_functions/step_functions_decorator.pyi +49 -0
- metaflow-stubs/plugins/azure/__init__.pyi +9 -0
- metaflow-stubs/plugins/azure/azure_credential.pyi +28 -0
- metaflow-stubs/plugins/azure/azure_exceptions.pyi +28 -0
- metaflow-stubs/plugins/azure/azure_utils.pyi +76 -0
- metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +52 -0
- metaflow-stubs/plugins/azure/includefile_support.pyi +63 -0
- metaflow-stubs/plugins/cards/__init__.pyi +9 -0
- metaflow-stubs/plugins/cards/card_cli.pyi +557 -0
- metaflow-stubs/plugins/cards/card_client.pyi +178 -0
- metaflow-stubs/plugins/cards/card_creator.pyi +26 -0
- metaflow-stubs/plugins/cards/card_datastore.pyi +111 -0
- metaflow-stubs/plugins/cards/card_decorator.pyi +133 -0
- metaflow-stubs/plugins/cards/card_modules/__init__.pyi +67 -0
- metaflow-stubs/plugins/cards/card_modules/basic.pyi +263 -0
- metaflow-stubs/plugins/cards/card_modules/card.pyi +62 -0
- metaflow-stubs/plugins/cards/card_modules/chevron/__init__.pyi +78 -0
- metaflow-stubs/plugins/cards/card_modules/chevron/main.pyi +77 -0
- metaflow-stubs/plugins/cards/card_modules/chevron/metadata.pyi +11 -0
- metaflow-stubs/plugins/cards/card_modules/chevron/renderer.pyi +114 -0
- metaflow-stubs/plugins/cards/card_modules/chevron/tokenizer.pyi +75 -0
- metaflow-stubs/plugins/cards/card_modules/components.pyi +251 -0
- metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +45 -0
- metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +24 -0
- metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +155 -0
- metaflow-stubs/plugins/cards/card_resolver.pyi +60 -0
- metaflow-stubs/plugins/cards/component_serializer.pyi +227 -0
- metaflow-stubs/plugins/cards/exception.pyi +71 -0
- metaflow-stubs/plugins/catch_decorator.pyi +58 -0
- metaflow-stubs/plugins/datatools/__init__.pyi +339 -0
- metaflow-stubs/plugins/datatools/local.pyi +82 -0
- metaflow-stubs/plugins/datatools/s3/__init__.pyi +589 -0
- metaflow-stubs/plugins/datatools/s3/s3.pyi +875 -0
- metaflow-stubs/plugins/datatools/s3/s3tail.pyi +34 -0
- metaflow-stubs/plugins/datatools/s3/s3util.pyi +45 -0
- metaflow-stubs/plugins/debug_logger.pyi +25 -0
- metaflow-stubs/plugins/debug_monitor.pyi +25 -0
- metaflow-stubs/plugins/environment_decorator.pyi +17 -0
- metaflow-stubs/plugins/events_decorator.pyi +34 -0
- metaflow-stubs/plugins/frameworks/__init__.pyi +9 -0
- metaflow-stubs/plugins/frameworks/pytorch.pyi +42 -0
- metaflow-stubs/plugins/gcp/__init__.pyi +9 -0
- metaflow-stubs/plugins/gcp/gs_exceptions.pyi +22 -0
- metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +26 -0
- metaflow-stubs/plugins/gcp/gs_utils.pyi +38 -0
- metaflow-stubs/plugins/gcp/includefile_support.pyi +63 -0
- metaflow-stubs/plugins/kubernetes/__init__.pyi +9 -0
- metaflow-stubs/plugins/kubernetes/kubernetes.pyi +127 -0
- metaflow-stubs/plugins/kubernetes/kubernetes_cli.pyi +73 -0
- metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +62 -0
- metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +165 -0
- metaflow-stubs/plugins/kubernetes/kubernetes_job.pyi +100 -0
- metaflow-stubs/plugins/package_cli.pyi +9 -0
- metaflow-stubs/plugins/parallel_decorator.pyi +34 -0
- metaflow-stubs/plugins/project_decorator.pyi +36 -0
- metaflow-stubs/plugins/pypi/__init__.pyi +18 -0
- metaflow-stubs/plugins/pypi/conda_decorator.pyi +59 -0
- metaflow-stubs/plugins/pypi/conda_environment.pyi +86 -0
- metaflow-stubs/plugins/pypi/pypi_decorator.pyi +22 -0
- metaflow-stubs/plugins/pypi/pypi_environment.pyi +50 -0
- metaflow-stubs/plugins/pypi/utils.pyi +28 -0
- metaflow-stubs/plugins/resources_decorator.pyi +15 -0
- metaflow-stubs/plugins/retry_decorator.pyi +28 -0
- metaflow-stubs/plugins/secrets/__init__.pyi +21 -0
- metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +30 -0
- metaflow-stubs/plugins/secrets/secrets_decorator.pyi +75 -0
- metaflow-stubs/plugins/storage_executor.pyi +33 -0
- metaflow-stubs/plugins/tag_cli.pyi +370 -0
- metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +54 -0
- metaflow-stubs/plugins/timeout_decorator.pyi +39 -0
- metaflow-stubs/procpoll.pyi +51 -0
- metaflow-stubs/py.typed +0 -0
- metaflow-stubs/pylint_wrapper.pyi +31 -0
- metaflow-stubs/tagging_util.pyi +52 -0
- ob_metaflow_stubs-2.11.4.1.dist-info/METADATA +22 -0
- ob_metaflow_stubs-2.11.4.1.dist-info/RECORD +131 -0
- ob_metaflow_stubs-2.11.4.1.dist-info/WHEEL +6 -0
- ob_metaflow_stubs-2.11.4.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.11.4.1 #
|
4
|
+
# Generated on 2024-02-28T05:30:43.943063 #
|
5
|
+
##################################################################################
|
6
|
+
|
7
|
+
from __future__ import annotations
|
8
|
+
|
9
|
+
import typing
|
10
|
+
if typing.TYPE_CHECKING:
|
11
|
+
import metaflow.exception
|
12
|
+
|
13
|
+
class MetaflowException(Exception, metaclass=type):
|
14
|
+
def __init__(self, msg = "", lineno = None):
|
15
|
+
...
|
16
|
+
def __str__(self):
|
17
|
+
...
|
18
|
+
...
|
19
|
+
|
20
|
+
DATATOOLS_LOCALROOT: None
|
21
|
+
|
22
|
+
DATATOOLS_SUFFIX: str
|
23
|
+
|
24
|
+
class MetaflowLocalURLException(metaflow.exception.MetaflowException, metaclass=type):
|
25
|
+
...
|
26
|
+
|
27
|
+
class MetaflowLocalNotFound(metaflow.exception.MetaflowException, metaclass=type):
|
28
|
+
...
|
29
|
+
|
30
|
+
class LocalObject(object, metaclass=type):
|
31
|
+
def __init__(self, url, path):
|
32
|
+
...
|
33
|
+
@property
|
34
|
+
def exists(self):
|
35
|
+
"""
|
36
|
+
Does this key correspond to an actual file?
|
37
|
+
"""
|
38
|
+
...
|
39
|
+
@property
|
40
|
+
def url(self):
|
41
|
+
"""
|
42
|
+
Local location of the object; this is the path prefixed with local://
|
43
|
+
"""
|
44
|
+
...
|
45
|
+
@property
|
46
|
+
def path(self):
|
47
|
+
"""
|
48
|
+
Path to the local file
|
49
|
+
"""
|
50
|
+
...
|
51
|
+
@property
|
52
|
+
def size(self):
|
53
|
+
"""
|
54
|
+
Size of the local file (in bytes)
|
55
|
+
|
56
|
+
Returns None if the key does not correspond to an actual object
|
57
|
+
"""
|
58
|
+
...
|
59
|
+
...
|
60
|
+
|
61
|
+
class Local(object, metaclass=type):
|
62
|
+
@classmethod
|
63
|
+
def get_root_from_config(cls, echo, create_on_absent = True):
|
64
|
+
...
|
65
|
+
def __init__(self):
|
66
|
+
"""
|
67
|
+
Initialize a new context for Local file operations. This object is based used as
|
68
|
+
a context manager for a with statement.
|
69
|
+
"""
|
70
|
+
...
|
71
|
+
def __enter__(self):
|
72
|
+
...
|
73
|
+
def __exit__(self, *args):
|
74
|
+
...
|
75
|
+
def get(self, key = None, return_missing = False):
|
76
|
+
...
|
77
|
+
def put(self, key, obj, overwrite = True):
|
78
|
+
...
|
79
|
+
def info(self, key = None, return_missing = False):
|
80
|
+
...
|
81
|
+
...
|
82
|
+
|
@@ -0,0 +1,589 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.11.4.1 #
|
4
|
+
# Generated on 2024-02-28T05:30:43.991894 #
|
5
|
+
##################################################################################
|
6
|
+
|
7
|
+
from __future__ import annotations
|
8
|
+
|
9
|
+
import typing
|
10
|
+
if typing.TYPE_CHECKING:
|
11
|
+
import io
|
12
|
+
import metaflow.plugins.datatools.s3.s3
|
13
|
+
import metaflow.exception
|
14
|
+
|
15
|
+
class RangeInfo(tuple, metaclass=type):
|
16
|
+
@staticmethod
|
17
|
+
def __new__(_cls, total_size: int, request_offset: int = 0, request_length: int = -1):
|
18
|
+
"""
|
19
|
+
Create new instance of RangeInfo(total_size, request_offset, request_length)
|
20
|
+
"""
|
21
|
+
...
|
22
|
+
def __repr__(self):
|
23
|
+
"""
|
24
|
+
Return a nicely formatted representation string
|
25
|
+
"""
|
26
|
+
...
|
27
|
+
def __getnewargs__(self):
|
28
|
+
"""
|
29
|
+
Return self as a plain tuple. Used by copy and pickle.
|
30
|
+
"""
|
31
|
+
...
|
32
|
+
def __init__(self, total_size: int, request_offset: int, request_length: int):
|
33
|
+
...
|
34
|
+
...
|
35
|
+
|
36
|
+
class S3(object, metaclass=type):
|
37
|
+
@classmethod
|
38
|
+
def get_root_from_config(cls, echo, create_on_absent = True):
|
39
|
+
...
|
40
|
+
def __enter__(self) -> metaflow.plugins.datatools.s3.s3.S3:
|
41
|
+
...
|
42
|
+
def __exit__(self, *args):
|
43
|
+
...
|
44
|
+
def close(self):
|
45
|
+
"""
|
46
|
+
Delete all temporary files downloaded in this context.
|
47
|
+
"""
|
48
|
+
...
|
49
|
+
def list_paths(self, keys: typing.Optional[typing.Iterable[str]] = None) -> typing.List[metaflow.plugins.datatools.s3.s3.S3Object]:
|
50
|
+
"""
|
51
|
+
List the next level of paths in S3.
|
52
|
+
|
53
|
+
If multiple keys are specified, listings are done in parallel. The returned
|
54
|
+
S3Objects have `.exists == False` if the path refers to a prefix, not an
|
55
|
+
existing S3 object.
|
56
|
+
|
57
|
+
For instance, if the directory hierarchy is
|
58
|
+
```
|
59
|
+
a/0.txt
|
60
|
+
a/b/1.txt
|
61
|
+
a/c/2.txt
|
62
|
+
a/d/e/3.txt
|
63
|
+
f/4.txt
|
64
|
+
```
|
65
|
+
The `list_paths(['a', 'f'])` call returns
|
66
|
+
```
|
67
|
+
a/0.txt (exists == True)
|
68
|
+
a/b/ (exists == False)
|
69
|
+
a/c/ (exists == False)
|
70
|
+
a/d/ (exists == False)
|
71
|
+
f/4.txt (exists == True)
|
72
|
+
```
|
73
|
+
|
74
|
+
Parameters
|
75
|
+
----------
|
76
|
+
keys : Iterable[str], optional, default None
|
77
|
+
List of paths.
|
78
|
+
|
79
|
+
Returns
|
80
|
+
-------
|
81
|
+
List[S3Object]
|
82
|
+
S3Objects under the given paths, including prefixes (directories) that
|
83
|
+
do not correspond to leaf objects.
|
84
|
+
"""
|
85
|
+
...
|
86
|
+
def list_recursive(self, keys: typing.Optional[typing.Iterable[str]] = None) -> typing.List[metaflow.plugins.datatools.s3.s3.S3Object]:
|
87
|
+
"""
|
88
|
+
List all objects recursively under the given prefixes.
|
89
|
+
|
90
|
+
If multiple keys are specified, listings are done in parallel. All objects
|
91
|
+
returned have `.exists == True` as this call always returns leaf objects.
|
92
|
+
|
93
|
+
For instance, if the directory hierarchy is
|
94
|
+
```
|
95
|
+
a/0.txt
|
96
|
+
a/b/1.txt
|
97
|
+
a/c/2.txt
|
98
|
+
a/d/e/3.txt
|
99
|
+
f/4.txt
|
100
|
+
```
|
101
|
+
The `list_paths(['a', 'f'])` call returns
|
102
|
+
```
|
103
|
+
a/0.txt (exists == True)
|
104
|
+
a/b/1.txt (exists == True)
|
105
|
+
a/c/2.txt (exists == True)
|
106
|
+
a/d/e/3.txt (exists == True)
|
107
|
+
f/4.txt (exists == True)
|
108
|
+
```
|
109
|
+
|
110
|
+
Parameters
|
111
|
+
----------
|
112
|
+
keys : Iterable[str], optional, default None
|
113
|
+
List of paths.
|
114
|
+
|
115
|
+
Returns
|
116
|
+
-------
|
117
|
+
List[S3Object]
|
118
|
+
S3Objects under the given paths.
|
119
|
+
"""
|
120
|
+
...
|
121
|
+
def info(self, key: typing.Optional[str] = None, return_missing: bool = False) -> metaflow.plugins.datatools.s3.s3.S3Object:
|
122
|
+
"""
|
123
|
+
Get metadata about a single object in S3.
|
124
|
+
|
125
|
+
This call makes a single `HEAD` request to S3 which can be
|
126
|
+
much faster than downloading all data with `get`.
|
127
|
+
|
128
|
+
Parameters
|
129
|
+
----------
|
130
|
+
key : str, optional, default None
|
131
|
+
Object to query. It can be an S3 url or a path suffix.
|
132
|
+
return_missing : bool, default False
|
133
|
+
If set to True, do not raise an exception for a missing key but
|
134
|
+
return it as an `S3Object` with `.exists == False`.
|
135
|
+
|
136
|
+
Returns
|
137
|
+
-------
|
138
|
+
S3Object
|
139
|
+
An S3Object corresponding to the object requested. The object
|
140
|
+
will have `.downloaded == False`.
|
141
|
+
"""
|
142
|
+
...
|
143
|
+
def info_many(self, keys: typing.Iterable[str], return_missing: bool = False) -> typing.List[metaflow.plugins.datatools.s3.s3.S3Object]:
|
144
|
+
"""
|
145
|
+
Get metadata about many objects in S3 in parallel.
|
146
|
+
|
147
|
+
This call makes a single `HEAD` request to S3 which can be
|
148
|
+
much faster than downloading all data with `get`.
|
149
|
+
|
150
|
+
Parameters
|
151
|
+
----------
|
152
|
+
keys : Iterable[str]
|
153
|
+
Objects to query. Each key can be an S3 url or a path suffix.
|
154
|
+
return_missing : bool, default False
|
155
|
+
If set to True, do not raise an exception for a missing key but
|
156
|
+
return it as an `S3Object` with `.exists == False`.
|
157
|
+
|
158
|
+
Returns
|
159
|
+
-------
|
160
|
+
List[S3Object]
|
161
|
+
A list of S3Objects corresponding to the paths requested. The
|
162
|
+
objects will have `.downloaded == False`.
|
163
|
+
"""
|
164
|
+
...
|
165
|
+
def get(self, key: typing.Union[str, metaflow.plugins.datatools.s3.s3.S3GetObject, None] = None, return_missing: bool = False, return_info: bool = True) -> metaflow.plugins.datatools.s3.s3.S3Object:
|
166
|
+
"""
|
167
|
+
Get a single object from S3.
|
168
|
+
|
169
|
+
Parameters
|
170
|
+
----------
|
171
|
+
key : Union[str, S3GetObject], optional, default None
|
172
|
+
Object to download. It can be an S3 url, a path suffix, or
|
173
|
+
an S3GetObject that defines a range of data to download. If None, or
|
174
|
+
not provided, gets the S3 root.
|
175
|
+
return_missing : bool, default False
|
176
|
+
If set to True, do not raise an exception for a missing key but
|
177
|
+
return it as an `S3Object` with `.exists == False`.
|
178
|
+
return_info : bool, default True
|
179
|
+
If set to True, fetch the content-type and user metadata associated
|
180
|
+
with the object at no extra cost, included for symmetry with `get_many`
|
181
|
+
|
182
|
+
Returns
|
183
|
+
-------
|
184
|
+
S3Object
|
185
|
+
An S3Object corresponding to the object requested.
|
186
|
+
"""
|
187
|
+
...
|
188
|
+
def get_many(self, keys: typing.Iterable[typing.Union[str, metaflow.plugins.datatools.s3.s3.S3GetObject]], return_missing: bool = False, return_info: bool = True) -> typing.List[metaflow.plugins.datatools.s3.s3.S3Object]:
|
189
|
+
"""
|
190
|
+
Get many objects from S3 in parallel.
|
191
|
+
|
192
|
+
Parameters
|
193
|
+
----------
|
194
|
+
keys : Iterable[Union[str, S3GetObject]]
|
195
|
+
Objects to download. Each object can be an S3 url, a path suffix, or
|
196
|
+
an S3GetObject that defines a range of data to download.
|
197
|
+
return_missing : bool, default False
|
198
|
+
If set to True, do not raise an exception for a missing key but
|
199
|
+
return it as an `S3Object` with `.exists == False`.
|
200
|
+
return_info : bool, default True
|
201
|
+
If set to True, fetch the content-type and user metadata associated
|
202
|
+
with the object at no extra cost, included for symmetry with `get_many`.
|
203
|
+
|
204
|
+
Returns
|
205
|
+
-------
|
206
|
+
List[S3Object]
|
207
|
+
S3Objects corresponding to the objects requested.
|
208
|
+
"""
|
209
|
+
...
|
210
|
+
def get_recursive(self, keys: typing.Iterable[str], return_info: bool = False) -> typing.List[metaflow.plugins.datatools.s3.s3.S3Object]:
|
211
|
+
"""
|
212
|
+
Get many objects from S3 recursively in parallel.
|
213
|
+
|
214
|
+
Parameters
|
215
|
+
----------
|
216
|
+
keys : Iterable[str]
|
217
|
+
Prefixes to download recursively. Each prefix can be an S3 url or a path suffix
|
218
|
+
which define the root prefix under which all objects are downloaded.
|
219
|
+
return_info : bool, default False
|
220
|
+
If set to True, fetch the content-type and user metadata associated
|
221
|
+
with the object.
|
222
|
+
|
223
|
+
Returns
|
224
|
+
-------
|
225
|
+
List[S3Object]
|
226
|
+
S3Objects stored under the given prefixes.
|
227
|
+
"""
|
228
|
+
...
|
229
|
+
def get_all(self, return_info: bool = False) -> typing.List[metaflow.plugins.datatools.s3.s3.S3Object]:
|
230
|
+
"""
|
231
|
+
Get all objects under the prefix set in the `S3` constructor.
|
232
|
+
|
233
|
+
This method requires that the `S3` object is initialized either with `run` or
|
234
|
+
`s3root`.
|
235
|
+
|
236
|
+
Parameters
|
237
|
+
----------
|
238
|
+
return_info : bool, default False
|
239
|
+
If set to True, fetch the content-type and user metadata associated
|
240
|
+
with the object.
|
241
|
+
|
242
|
+
Returns
|
243
|
+
-------
|
244
|
+
Iterable[S3Object]
|
245
|
+
S3Objects stored under the main prefix.
|
246
|
+
"""
|
247
|
+
...
|
248
|
+
def put(self, key: typing.Union[str, metaflow.plugins.datatools.s3.s3.S3PutObject], obj: typing.Union[io.RawIOBase, io.BufferedIOBase, str, bytes], overwrite: bool = True, content_type: typing.Optional[str] = None, metadata: typing.Optional[typing.Dict[str, str]] = None) -> str:
|
249
|
+
"""
|
250
|
+
Upload a single object to S3.
|
251
|
+
|
252
|
+
Parameters
|
253
|
+
----------
|
254
|
+
key : Union[str, S3PutObject]
|
255
|
+
Object path. It can be an S3 url or a path suffix.
|
256
|
+
obj : PutValue
|
257
|
+
An object to store in S3. Strings are converted to UTF-8 encoding.
|
258
|
+
overwrite : bool, default True
|
259
|
+
Overwrite the object if it exists. If set to False, the operation
|
260
|
+
succeeds without uploading anything if the key already exists.
|
261
|
+
content_type : str, optional, default None
|
262
|
+
Optional MIME type for the object.
|
263
|
+
metadata : Dict[str, str], optional, default None
|
264
|
+
A JSON-encodable dictionary of additional headers to be stored
|
265
|
+
as metadata with the object.
|
266
|
+
|
267
|
+
Returns
|
268
|
+
-------
|
269
|
+
str
|
270
|
+
URL of the object stored.
|
271
|
+
"""
|
272
|
+
...
|
273
|
+
def put_many(self, key_objs: typing.List[typing.Union[typing.Tuple[str, typing.Union[io.RawIOBase, io.BufferedIOBase, str, bytes]], metaflow.plugins.datatools.s3.s3.S3PutObject]], overwrite: bool = True) -> typing.List[typing.Tuple[str, str]]:
|
274
|
+
"""
|
275
|
+
Upload many objects to S3.
|
276
|
+
|
277
|
+
Each object to be uploaded can be specified in two ways:
|
278
|
+
|
279
|
+
1. As a `(key, obj)` tuple where `key` is a string specifying
|
280
|
+
the path and `obj` is a string or a bytes object.
|
281
|
+
|
282
|
+
2. As a `S3PutObject` which contains additional metadata to be
|
283
|
+
stored with the object.
|
284
|
+
|
285
|
+
Parameters
|
286
|
+
----------
|
287
|
+
key_objs : List[Union[Tuple[str, PutValue], S3PutObject]]
|
288
|
+
List of key-object pairs to upload.
|
289
|
+
overwrite : bool, default True
|
290
|
+
Overwrite the object if it exists. If set to False, the operation
|
291
|
+
succeeds without uploading anything if the key already exists.
|
292
|
+
|
293
|
+
Returns
|
294
|
+
-------
|
295
|
+
List[Tuple[str, str]]
|
296
|
+
List of `(key, url)` pairs corresponding to the objects uploaded.
|
297
|
+
"""
|
298
|
+
...
|
299
|
+
def put_files(self, key_paths: typing.List[typing.Union[typing.Tuple[str, typing.Union[io.RawIOBase, io.BufferedIOBase, str, bytes]], metaflow.plugins.datatools.s3.s3.S3PutObject]], overwrite: bool = True) -> typing.List[typing.Tuple[str, str]]:
|
300
|
+
"""
|
301
|
+
Upload many local files to S3.
|
302
|
+
|
303
|
+
Each file to be uploaded can be specified in two ways:
|
304
|
+
|
305
|
+
1. As a `(key, path)` tuple where `key` is a string specifying
|
306
|
+
the S3 path and `path` is the path to a local file.
|
307
|
+
|
308
|
+
2. As a `S3PutObject` which contains additional metadata to be
|
309
|
+
stored with the file.
|
310
|
+
|
311
|
+
Parameters
|
312
|
+
----------
|
313
|
+
key_paths : List[Union[Tuple[str, PutValue], S3PutObject]]
|
314
|
+
List of files to upload.
|
315
|
+
overwrite : bool, default True
|
316
|
+
Overwrite the object if it exists. If set to False, the operation
|
317
|
+
succeeds without uploading anything if the key already exists.
|
318
|
+
|
319
|
+
Returns
|
320
|
+
-------
|
321
|
+
List[Tuple[str, str]]
|
322
|
+
List of `(key, url)` pairs corresponding to the files uploaded.
|
323
|
+
"""
|
324
|
+
...
|
325
|
+
...
|
326
|
+
|
327
|
+
class S3GetObject(tuple, metaclass=type):
|
328
|
+
@staticmethod
|
329
|
+
def __new__(_cls, key: str, offset: int, length: int):
|
330
|
+
"""
|
331
|
+
Create new instance of S3GetObject(key, offset, length)
|
332
|
+
"""
|
333
|
+
...
|
334
|
+
def __repr__(self):
|
335
|
+
"""
|
336
|
+
Return a nicely formatted representation string
|
337
|
+
"""
|
338
|
+
...
|
339
|
+
def __getnewargs__(self):
|
340
|
+
"""
|
341
|
+
Return self as a plain tuple. Used by copy and pickle.
|
342
|
+
"""
|
343
|
+
...
|
344
|
+
def __init__(self, key: str, offset: int, length: int):
|
345
|
+
...
|
346
|
+
...
|
347
|
+
|
348
|
+
class S3Object(object, metaclass=type):
|
349
|
+
def __init__(self, prefix: str, url: str, path: str, size: typing.Optional[int] = None, content_type: typing.Optional[str] = None, metadata: typing.Optional[typing.Dict[str, str]] = None, range_info: typing.Optional[metaflow.plugins.datatools.s3.s3.RangeInfo] = None, last_modified: typing.Optional[int] = None, encryption: typing.Optional[str] = None):
|
350
|
+
...
|
351
|
+
@property
|
352
|
+
def exists(self) -> bool:
|
353
|
+
"""
|
354
|
+
Does this key correspond to an object in S3?
|
355
|
+
|
356
|
+
Returns
|
357
|
+
-------
|
358
|
+
bool
|
359
|
+
True if this object points at an existing object (file) in S3.
|
360
|
+
"""
|
361
|
+
...
|
362
|
+
@property
|
363
|
+
def downloaded(self) -> bool:
|
364
|
+
"""
|
365
|
+
Has this object been downloaded?
|
366
|
+
|
367
|
+
If True, the contents can be accessed through `path`, `blob`,
|
368
|
+
and `text` properties.
|
369
|
+
|
370
|
+
Returns
|
371
|
+
-------
|
372
|
+
bool
|
373
|
+
True if the contents of this object have been downloaded.
|
374
|
+
"""
|
375
|
+
...
|
376
|
+
@property
|
377
|
+
def url(self) -> str:
|
378
|
+
"""
|
379
|
+
S3 location of the object
|
380
|
+
|
381
|
+
Returns
|
382
|
+
-------
|
383
|
+
str
|
384
|
+
The S3 location of this object.
|
385
|
+
"""
|
386
|
+
...
|
387
|
+
@property
|
388
|
+
def prefix(self) -> str:
|
389
|
+
"""
|
390
|
+
Prefix requested that matches this object.
|
391
|
+
|
392
|
+
Returns
|
393
|
+
-------
|
394
|
+
str
|
395
|
+
Requested prefix
|
396
|
+
"""
|
397
|
+
...
|
398
|
+
@property
|
399
|
+
def key(self) -> str:
|
400
|
+
"""
|
401
|
+
Key corresponds to the key given to the get call that produced
|
402
|
+
this object.
|
403
|
+
|
404
|
+
This may be a full S3 URL or a suffix based on what
|
405
|
+
was requested.
|
406
|
+
|
407
|
+
Returns
|
408
|
+
-------
|
409
|
+
str
|
410
|
+
Key requested.
|
411
|
+
"""
|
412
|
+
...
|
413
|
+
@property
|
414
|
+
def path(self) -> typing.Optional[str]:
|
415
|
+
"""
|
416
|
+
Path to a local temporary file corresponding to the object downloaded.
|
417
|
+
|
418
|
+
This file gets deleted automatically when a S3 scope exits.
|
419
|
+
Returns None if this S3Object has not been downloaded.
|
420
|
+
|
421
|
+
Returns
|
422
|
+
-------
|
423
|
+
str
|
424
|
+
Local path, if the object has been downloaded.
|
425
|
+
"""
|
426
|
+
...
|
427
|
+
@property
|
428
|
+
def blob(self) -> typing.Optional[bytes]:
|
429
|
+
"""
|
430
|
+
Contents of the object as a byte string or None if the
|
431
|
+
object hasn't been downloaded.
|
432
|
+
|
433
|
+
Returns
|
434
|
+
-------
|
435
|
+
bytes
|
436
|
+
Contents of the object as bytes.
|
437
|
+
"""
|
438
|
+
...
|
439
|
+
@property
|
440
|
+
def text(self) -> typing.Optional[str]:
|
441
|
+
"""
|
442
|
+
Contents of the object as a string or None if the
|
443
|
+
object hasn't been downloaded.
|
444
|
+
|
445
|
+
The object is assumed to contain UTF-8 encoded data.
|
446
|
+
|
447
|
+
Returns
|
448
|
+
-------
|
449
|
+
str
|
450
|
+
Contents of the object as text.
|
451
|
+
"""
|
452
|
+
...
|
453
|
+
@property
|
454
|
+
def size(self) -> typing.Optional[int]:
|
455
|
+
"""
|
456
|
+
Size of the object in bytes.
|
457
|
+
|
458
|
+
Returns None if the key does not correspond to an object in S3.
|
459
|
+
|
460
|
+
Returns
|
461
|
+
-------
|
462
|
+
int
|
463
|
+
Size of the object in bytes, if the object exists.
|
464
|
+
"""
|
465
|
+
...
|
466
|
+
@property
|
467
|
+
def has_info(self) -> bool:
|
468
|
+
"""
|
469
|
+
Returns true if this `S3Object` contains the content-type MIME header or
|
470
|
+
user-defined metadata.
|
471
|
+
|
472
|
+
If False, this means that `content_type`, `metadata`, `range_info` and
|
473
|
+
`last_modified` will return None.
|
474
|
+
|
475
|
+
Returns
|
476
|
+
-------
|
477
|
+
bool
|
478
|
+
True if additional metadata is available.
|
479
|
+
"""
|
480
|
+
...
|
481
|
+
@property
|
482
|
+
def metadata(self) -> typing.Optional[typing.Dict[str, str]]:
|
483
|
+
"""
|
484
|
+
Returns a dictionary of user-defined metadata, or None if no metadata
|
485
|
+
is defined.
|
486
|
+
|
487
|
+
Returns
|
488
|
+
-------
|
489
|
+
Dict
|
490
|
+
User-defined metadata.
|
491
|
+
"""
|
492
|
+
...
|
493
|
+
@property
|
494
|
+
def content_type(self) -> typing.Optional[str]:
|
495
|
+
"""
|
496
|
+
Returns the content-type of the S3 object or None if it is not defined.
|
497
|
+
|
498
|
+
Returns
|
499
|
+
-------
|
500
|
+
str
|
501
|
+
Content type or None if the content type is undefined.
|
502
|
+
"""
|
503
|
+
...
|
504
|
+
@property
|
505
|
+
def encryption(self) -> typing.Optional[str]:
|
506
|
+
"""
|
507
|
+
Returns the encryption type of the S3 object or None if it is not defined.
|
508
|
+
|
509
|
+
Returns
|
510
|
+
-------
|
511
|
+
str
|
512
|
+
Server-side-encryption type or None if parameter is not set.
|
513
|
+
"""
|
514
|
+
...
|
515
|
+
@property
|
516
|
+
def range_info(self) -> typing.Optional[metaflow.plugins.datatools.s3.s3.RangeInfo]:
|
517
|
+
"""
|
518
|
+
If the object corresponds to a partially downloaded object, returns
|
519
|
+
information of what was downloaded.
|
520
|
+
|
521
|
+
The returned object has the following fields:
|
522
|
+
- `total_size`: Size of the object in S3.
|
523
|
+
- `request_offset`: The starting offset.
|
524
|
+
- `request_length`: The number of bytes downloaded.
|
525
|
+
|
526
|
+
Returns
|
527
|
+
-------
|
528
|
+
namedtuple
|
529
|
+
An object containing information about the partial download. If
|
530
|
+
the `S3Object` doesn't correspond to a partially downloaded file,
|
531
|
+
returns None.
|
532
|
+
"""
|
533
|
+
...
|
534
|
+
@property
|
535
|
+
def last_modified(self) -> typing.Optional[int]:
|
536
|
+
"""
|
537
|
+
Returns the last modified unix timestamp of the object.
|
538
|
+
|
539
|
+
Returns
|
540
|
+
-------
|
541
|
+
int
|
542
|
+
Unix timestamp corresponding to the last modified time.
|
543
|
+
"""
|
544
|
+
...
|
545
|
+
def __str__(self):
|
546
|
+
...
|
547
|
+
def __repr__(self):
|
548
|
+
...
|
549
|
+
...
|
550
|
+
|
551
|
+
class S3PutObject(tuple, metaclass=type):
|
552
|
+
@staticmethod
|
553
|
+
def __new__(_cls, key: str, value: typing.Union[io.RawIOBase, io.BufferedIOBase, str, bytes, None] = None, path: typing.Optional[str] = None, content_type: typing.Optional[str] = None, encryption: typing.Optional[str] = None, metadata: typing.Optional[typing.Dict[str, str]] = None):
|
554
|
+
"""
|
555
|
+
Create new instance of S3PutObject(key, value, path, content_type, encryption, metadata)
|
556
|
+
"""
|
557
|
+
...
|
558
|
+
def __repr__(self):
|
559
|
+
"""
|
560
|
+
Return a nicely formatted representation string
|
561
|
+
"""
|
562
|
+
...
|
563
|
+
def __getnewargs__(self):
|
564
|
+
"""
|
565
|
+
Return self as a plain tuple. Used by copy and pickle.
|
566
|
+
"""
|
567
|
+
...
|
568
|
+
def __init__(self, key: str, value: typing.Union[io.RawIOBase, io.BufferedIOBase, str, bytes, None], path: typing.Optional[str], content_type: typing.Optional[str], encryption: typing.Optional[str], metadata: typing.Optional[typing.Dict[str, str]]):
|
569
|
+
...
|
570
|
+
...
|
571
|
+
|
572
|
+
class MetaflowS3InvalidObject(metaflow.exception.MetaflowException, metaclass=type):
|
573
|
+
...
|
574
|
+
|
575
|
+
class MetaflowS3URLException(metaflow.exception.MetaflowException, metaclass=type):
|
576
|
+
...
|
577
|
+
|
578
|
+
class MetaflowS3Exception(metaflow.exception.MetaflowException, metaclass=type):
|
579
|
+
...
|
580
|
+
|
581
|
+
class MetaflowS3NotFound(metaflow.exception.MetaflowException, metaclass=type):
|
582
|
+
...
|
583
|
+
|
584
|
+
class MetaflowS3AccessDenied(metaflow.exception.MetaflowException, metaclass=type):
|
585
|
+
...
|
586
|
+
|
587
|
+
class MetaflowS3InvalidRange(metaflow.exception.MetaflowException, metaclass=type):
|
588
|
+
...
|
589
|
+
|