metaflow-stubs 2.11.15__py2.py3-none-any.whl → 2.12.0__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 +606 -407
- metaflow-stubs/cards.pyi +4 -4
- metaflow-stubs/cli.pyi +42 -22
- metaflow-stubs/client/__init__.pyi +3 -3
- metaflow-stubs/client/core.pyi +7 -7
- metaflow-stubs/client/filecache.pyi +3 -3
- metaflow-stubs/clone_util.pyi +2 -2
- metaflow-stubs/events.pyi +2 -2
- metaflow-stubs/exception.pyi +2 -2
- metaflow-stubs/flowspec.pyi +3 -3
- metaflow-stubs/generated_for.txt +1 -1
- metaflow-stubs/includefile.pyi +4 -4
- metaflow-stubs/metadata/metadata.pyi +2 -2
- metaflow-stubs/metadata/util.pyi +2 -2
- metaflow-stubs/metaflow_config.pyi +14 -2
- metaflow-stubs/metaflow_current.pyi +5 -5
- metaflow-stubs/mflog/mflog.pyi +2 -2
- metaflow-stubs/multicore_utils.pyi +2 -2
- metaflow-stubs/parameters.pyi +3 -3
- metaflow-stubs/plugins/__init__.pyi +10 -2
- metaflow-stubs/plugins/airflow/__init__.pyi +2 -2
- metaflow-stubs/plugins/airflow/airflow.pyi +12 -4
- metaflow-stubs/plugins/airflow/airflow_cli.pyi +3 -3
- metaflow-stubs/plugins/airflow/airflow_decorator.pyi +2 -2
- metaflow-stubs/plugins/airflow/airflow_utils.pyi +2 -2
- metaflow-stubs/plugins/airflow/exception.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/__init__.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +3 -3
- metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +3 -3
- metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +3 -3
- metaflow-stubs/plugins/argo/__init__.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_client.pyi +4 -2
- metaflow-stubs/plugins/argo/argo_events.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_workflows.pyi +7 -3
- metaflow-stubs/plugins/argo/argo_workflows_cli.pyi +3 -3
- metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +3 -3
- metaflow-stubs/plugins/aws/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/aws_client.pyi +2 -2
- metaflow-stubs/plugins/aws/aws_utils.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/batch.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/batch_cli.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/batch_client.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +2 -2
- metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +3 -3
- metaflow-stubs/plugins/aws/step_functions/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/dynamo_db_client.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/production_token.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions_cli.pyi +3 -3
- metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions_decorator.pyi +2 -2
- metaflow-stubs/plugins/azure/__init__.pyi +5 -2
- metaflow-stubs/plugins/azure/azure_credential.pyi +28 -0
- metaflow-stubs/plugins/azure/azure_exceptions.pyi +2 -2
- metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +58 -0
- metaflow-stubs/plugins/azure/azure_utils.pyi +5 -5
- metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +5 -5
- metaflow-stubs/plugins/azure/includefile_support.pyi +2 -2
- metaflow-stubs/plugins/cards/__init__.pyi +2 -2
- metaflow-stubs/plugins/cards/card_cli.pyi +4 -4
- metaflow-stubs/plugins/cards/card_client.pyi +3 -3
- metaflow-stubs/plugins/cards/card_creator.pyi +2 -2
- metaflow-stubs/plugins/cards/card_datastore.pyi +2 -2
- metaflow-stubs/plugins/cards/card_decorator.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/__init__.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/basic.pyi +3 -3
- metaflow-stubs/plugins/cards/card_modules/card.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/chevron/__init__.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/chevron/main.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/chevron/metadata.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/chevron/renderer.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/chevron/tokenizer.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/components.pyi +4 -4
- metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +3 -3
- metaflow-stubs/plugins/cards/card_resolver.pyi +2 -2
- metaflow-stubs/plugins/cards/component_serializer.pyi +5 -5
- metaflow-stubs/plugins/cards/exception.pyi +2 -2
- metaflow-stubs/plugins/catch_decorator.pyi +3 -3
- metaflow-stubs/plugins/datatools/__init__.pyi +3 -3
- metaflow-stubs/plugins/datatools/local.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/__init__.pyi +3 -3
- metaflow-stubs/plugins/datatools/s3/s3.pyi +8 -5
- metaflow-stubs/plugins/datatools/s3/s3tail.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/s3util.pyi +2 -2
- metaflow-stubs/plugins/debug_logger.pyi +2 -2
- metaflow-stubs/plugins/debug_monitor.pyi +2 -2
- metaflow-stubs/plugins/environment_decorator.pyi +2 -2
- metaflow-stubs/plugins/events_decorator.pyi +2 -2
- metaflow-stubs/plugins/frameworks/__init__.pyi +2 -2
- metaflow-stubs/plugins/frameworks/pytorch.pyi +3 -3
- metaflow-stubs/plugins/gcp/__init__.pyi +5 -2
- metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +73 -0
- metaflow-stubs/plugins/gcp/gs_exceptions.pyi +2 -2
- metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +16 -2
- metaflow-stubs/plugins/gcp/gs_utils.pyi +2 -2
- metaflow-stubs/plugins/gcp/includefile_support.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/__init__.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes.pyi +15 -3
- metaflow-stubs/plugins/kubernetes/kubernetes_cli.pyi +16 -5
- metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +13 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +21 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_job.pyi +15 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +127 -0
- metaflow-stubs/plugins/logs_cli.pyi +3 -3
- metaflow-stubs/plugins/package_cli.pyi +2 -2
- metaflow-stubs/plugins/parallel_decorator.pyi +2 -2
- metaflow-stubs/plugins/project_decorator.pyi +2 -2
- metaflow-stubs/plugins/pypi/__init__.pyi +2 -2
- metaflow-stubs/plugins/pypi/conda_decorator.pyi +2 -2
- metaflow-stubs/plugins/pypi/conda_environment.pyi +3 -3
- metaflow-stubs/plugins/pypi/pypi_decorator.pyi +2 -2
- metaflow-stubs/plugins/pypi/pypi_environment.pyi +3 -3
- metaflow-stubs/plugins/pypi/utils.pyi +2 -2
- metaflow-stubs/plugins/resources_decorator.pyi +2 -2
- metaflow-stubs/plugins/retry_decorator.pyi +2 -2
- metaflow-stubs/plugins/secrets/__init__.pyi +2 -2
- metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +2 -2
- metaflow-stubs/plugins/secrets/secrets_decorator.pyi +2 -2
- metaflow-stubs/plugins/storage_executor.pyi +2 -2
- metaflow-stubs/plugins/tag_cli.pyi +4 -4
- metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +3 -3
- metaflow-stubs/plugins/timeout_decorator.pyi +5 -3
- metaflow-stubs/procpoll.pyi +2 -2
- metaflow-stubs/pylint_wrapper.pyi +2 -2
- metaflow-stubs/runner/__init__.pyi +9 -0
- metaflow-stubs/runner/metaflow_runner.pyi +696 -0
- metaflow-stubs/runner/nbrun.pyi +224 -0
- metaflow-stubs/runner/subprocess_manager.pyi +221 -0
- metaflow-stubs/tagging_util.pyi +2 -2
- metaflow-stubs/tuple_util.pyi +14 -0
- metaflow-stubs/version.pyi +2 -2
- {metaflow_stubs-2.11.15.dist-info → metaflow_stubs-2.12.0.dist-info}/METADATA +2 -2
- metaflow_stubs-2.12.0.dist-info/RECORD +142 -0
- metaflow_stubs-2.11.15.dist-info/RECORD +0 -133
- {metaflow_stubs-2.11.15.dist-info → metaflow_stubs-2.12.0.dist-info}/WHEEL +0 -0
- {metaflow_stubs-2.11.15.dist-info → metaflow_stubs-2.12.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,696 @@
|
|
1
|
+
##################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.12.0 #
|
4
|
+
# Generated on 2024-05-28T09:55:27.185045 #
|
5
|
+
##################################################################################
|
6
|
+
|
7
|
+
from __future__ import annotations
|
8
|
+
|
9
|
+
import typing
|
10
|
+
if typing.TYPE_CHECKING:
|
11
|
+
import metaflow.runner.subprocess_manager
|
12
|
+
import datetime
|
13
|
+
import metaflow.client.core
|
14
|
+
import metaflow.events
|
15
|
+
import metaflow.runner.metaflow_runner
|
16
|
+
|
17
|
+
class Run(metaflow.client.core.MetaflowObject, metaclass=type):
|
18
|
+
def steps(self, *tags: str) -> typing.Iterator[metaflow.client.core.Step]:
|
19
|
+
"""
|
20
|
+
[Legacy function - do not use]
|
21
|
+
|
22
|
+
Returns an iterator over all `Step` objects in the step. This is an alias
|
23
|
+
to iterating the object itself, i.e.
|
24
|
+
```
|
25
|
+
list(Run(...)) == list(Run(...).steps())
|
26
|
+
```
|
27
|
+
|
28
|
+
Parameters
|
29
|
+
----------
|
30
|
+
tags : str
|
31
|
+
No op (legacy functionality)
|
32
|
+
|
33
|
+
Yields
|
34
|
+
------
|
35
|
+
Step
|
36
|
+
`Step` objects in this run.
|
37
|
+
"""
|
38
|
+
...
|
39
|
+
@property
|
40
|
+
def code(self) -> typing.Optional[metaflow.client.core.MetaflowCode]:
|
41
|
+
"""
|
42
|
+
Returns the MetaflowCode object for this run, if present.
|
43
|
+
Code is packed if atleast one `Step` runs remotely, else None is returned.
|
44
|
+
|
45
|
+
Returns
|
46
|
+
-------
|
47
|
+
MetaflowCode, optional
|
48
|
+
Code package for this run
|
49
|
+
"""
|
50
|
+
...
|
51
|
+
@property
|
52
|
+
def data(self) -> typing.Optional[metaflow.client.core.MetaflowData]:
|
53
|
+
"""
|
54
|
+
Returns a container of data artifacts produced by this run.
|
55
|
+
|
56
|
+
You can access data produced by this run as follows:
|
57
|
+
```
|
58
|
+
print(run.data.my_var)
|
59
|
+
```
|
60
|
+
This is a shorthand for `run['end'].task.data`. If the 'end' step has not yet
|
61
|
+
executed, returns None.
|
62
|
+
|
63
|
+
Returns
|
64
|
+
-------
|
65
|
+
MetaflowData, optional
|
66
|
+
Container of all artifacts produced by this task
|
67
|
+
"""
|
68
|
+
...
|
69
|
+
@property
|
70
|
+
def successful(self) -> bool:
|
71
|
+
"""
|
72
|
+
Indicates whether or not the run completed successfully.
|
73
|
+
|
74
|
+
A run is successful if its 'end' step is successful.
|
75
|
+
|
76
|
+
Returns
|
77
|
+
-------
|
78
|
+
bool
|
79
|
+
True if the run completed successfully and False otherwise
|
80
|
+
"""
|
81
|
+
...
|
82
|
+
@property
|
83
|
+
def finished(self) -> bool:
|
84
|
+
"""
|
85
|
+
Indicates whether or not the run completed.
|
86
|
+
|
87
|
+
A run completed if its 'end' step completed.
|
88
|
+
|
89
|
+
Returns
|
90
|
+
-------
|
91
|
+
bool
|
92
|
+
True if the run completed and False otherwise
|
93
|
+
"""
|
94
|
+
...
|
95
|
+
@property
|
96
|
+
def finished_at(self) -> typing.Optional[datetime.datetime]:
|
97
|
+
"""
|
98
|
+
Returns the datetime object of when the run finished (successfully or not).
|
99
|
+
|
100
|
+
The completion time of a run is the same as the completion time of its 'end' step.
|
101
|
+
If the 'end' step has not completed, returns None.
|
102
|
+
|
103
|
+
Returns
|
104
|
+
-------
|
105
|
+
datetime, optional
|
106
|
+
Datetime of when the run finished
|
107
|
+
"""
|
108
|
+
...
|
109
|
+
@property
|
110
|
+
def end_task(self) -> typing.Optional[metaflow.client.core.Task]:
|
111
|
+
"""
|
112
|
+
Returns the Task corresponding to the 'end' step.
|
113
|
+
|
114
|
+
This returns None if the end step does not yet exist.
|
115
|
+
|
116
|
+
Returns
|
117
|
+
-------
|
118
|
+
Task, optional
|
119
|
+
The 'end' task
|
120
|
+
"""
|
121
|
+
...
|
122
|
+
def add_tag(self, tag: str):
|
123
|
+
"""
|
124
|
+
Add a tag to this `Run`.
|
125
|
+
|
126
|
+
Note that if the tag is already a system tag, it is not added as a user tag,
|
127
|
+
and no error is thrown.
|
128
|
+
|
129
|
+
Parameters
|
130
|
+
----------
|
131
|
+
tag : str
|
132
|
+
Tag to add.
|
133
|
+
"""
|
134
|
+
...
|
135
|
+
def add_tags(self, tags: typing.Iterable[str]):
|
136
|
+
"""
|
137
|
+
Add one or more tags to this `Run`.
|
138
|
+
|
139
|
+
Note that if any tag is already a system tag, it is not added as a user tag
|
140
|
+
and no error is thrown.
|
141
|
+
|
142
|
+
Parameters
|
143
|
+
----------
|
144
|
+
tags : Iterable[str]
|
145
|
+
Tags to add.
|
146
|
+
"""
|
147
|
+
...
|
148
|
+
def remove_tag(self, tag: str):
|
149
|
+
"""
|
150
|
+
Remove one tag from this `Run`.
|
151
|
+
|
152
|
+
Removing a system tag is an error. Removing a non-existent
|
153
|
+
user tag is a no-op.
|
154
|
+
|
155
|
+
Parameters
|
156
|
+
----------
|
157
|
+
tag : str
|
158
|
+
Tag to remove.
|
159
|
+
"""
|
160
|
+
...
|
161
|
+
def remove_tags(self, tags: typing.Iterable[str]):
|
162
|
+
"""
|
163
|
+
Remove one or more tags to this `Run`.
|
164
|
+
|
165
|
+
Removing a system tag will result in an error. Removing a non-existent
|
166
|
+
user tag is a no-op.
|
167
|
+
|
168
|
+
Parameters
|
169
|
+
----------
|
170
|
+
tags : Iterable[str]
|
171
|
+
Tags to remove.
|
172
|
+
"""
|
173
|
+
...
|
174
|
+
def replace_tag(self, tag_to_remove: str, tag_to_add: str):
|
175
|
+
"""
|
176
|
+
Remove a tag and add a tag atomically. Removal is done first.
|
177
|
+
The rules for `Run.add_tag` and `Run.remove_tag` also apply here.
|
178
|
+
|
179
|
+
Parameters
|
180
|
+
----------
|
181
|
+
tag_to_remove : str
|
182
|
+
Tag to remove.
|
183
|
+
tag_to_add : str
|
184
|
+
Tag to add.
|
185
|
+
"""
|
186
|
+
...
|
187
|
+
def replace_tags(self, tags_to_remove: typing.Iterable[str], tags_to_add: typing.Iterable[str]):
|
188
|
+
"""
|
189
|
+
Remove and add tags atomically; the removal is done first.
|
190
|
+
The rules for `Run.add_tag` and `Run.remove_tag` also apply here.
|
191
|
+
|
192
|
+
Parameters
|
193
|
+
----------
|
194
|
+
tags_to_remove : Iterable[str]
|
195
|
+
Tags to remove.
|
196
|
+
tags_to_add : Iterable[str]
|
197
|
+
Tags to add.
|
198
|
+
"""
|
199
|
+
...
|
200
|
+
def __iter__(self) -> typing.Iterator[metaflow.client.core.Step]:
|
201
|
+
"""
|
202
|
+
Iterate over all children Step of this Run
|
203
|
+
|
204
|
+
Yields
|
205
|
+
------
|
206
|
+
Step
|
207
|
+
A Step in this Run
|
208
|
+
"""
|
209
|
+
...
|
210
|
+
def __getitem__(self, name: str) -> metaflow.client.core.Step:
|
211
|
+
"""
|
212
|
+
Returns the Step object with the step name 'name'
|
213
|
+
|
214
|
+
Parameters
|
215
|
+
----------
|
216
|
+
name : str
|
217
|
+
Step name
|
218
|
+
|
219
|
+
Returns
|
220
|
+
-------
|
221
|
+
Step
|
222
|
+
Step for this step name in this Run
|
223
|
+
|
224
|
+
Raises
|
225
|
+
------
|
226
|
+
KeyError
|
227
|
+
If the name does not identify a valid Step object
|
228
|
+
"""
|
229
|
+
...
|
230
|
+
def __getstate__(self):
|
231
|
+
...
|
232
|
+
def __setstate__(self, state):
|
233
|
+
...
|
234
|
+
@property
|
235
|
+
def trigger(self) -> typing.Optional[metaflow.events.Trigger]:
|
236
|
+
"""
|
237
|
+
Returns a container of events that triggered this run.
|
238
|
+
|
239
|
+
This returns None if the run was not triggered by any events.
|
240
|
+
|
241
|
+
Returns
|
242
|
+
-------
|
243
|
+
Trigger, optional
|
244
|
+
Container of triggering events
|
245
|
+
"""
|
246
|
+
...
|
247
|
+
...
|
248
|
+
|
249
|
+
def metadata(ms: str) -> str:
|
250
|
+
"""
|
251
|
+
Switch Metadata provider.
|
252
|
+
|
253
|
+
This call has a global effect. Selecting the local metadata will,
|
254
|
+
for example, not allow access to information stored in remote
|
255
|
+
metadata providers.
|
256
|
+
|
257
|
+
Note that you don't typically have to call this function directly. Usually
|
258
|
+
the metadata provider is set through the Metaflow configuration file. If you
|
259
|
+
need to switch between multiple providers, you can use the `METAFLOW_PROFILE`
|
260
|
+
environment variable to switch between configurations.
|
261
|
+
|
262
|
+
Parameters
|
263
|
+
----------
|
264
|
+
ms : str
|
265
|
+
Can be a path (selects local metadata), a URL starting with http (selects
|
266
|
+
the service metadata) or an explicit specification <metadata_type>@<info>; as an
|
267
|
+
example, you can specify local@<path> or service@<url>.
|
268
|
+
|
269
|
+
Returns
|
270
|
+
-------
|
271
|
+
str
|
272
|
+
The description of the metadata selected (equivalent to the result of
|
273
|
+
get_metadata()).
|
274
|
+
"""
|
275
|
+
...
|
276
|
+
|
277
|
+
class CommandManager(object, metaclass=type):
|
278
|
+
def __init__(self, command: typing.List[str], env: typing.Optional[typing.Dict[str, str]] = None, cwd: typing.Optional[str] = None):
|
279
|
+
"""
|
280
|
+
Create a new CommandManager object.
|
281
|
+
This does not run the process itself but sets it up.
|
282
|
+
|
283
|
+
Parameters
|
284
|
+
----------
|
285
|
+
command : List[str]
|
286
|
+
The command to run in List form.
|
287
|
+
env : Optional[Dict[str, str]], default None
|
288
|
+
Environment variables to set for the subprocess; if not specified,
|
289
|
+
the current enviornment variables are used.
|
290
|
+
cwd : Optional[str], default None
|
291
|
+
The directory to run the subprocess in; if not specified, the current
|
292
|
+
directory is used.
|
293
|
+
"""
|
294
|
+
...
|
295
|
+
def __aenter__(self) -> metaflow.runner.subprocess_manager.CommandManager:
|
296
|
+
...
|
297
|
+
def __aexit__(self, exc_type, exc_value, traceback):
|
298
|
+
...
|
299
|
+
def wait(self, timeout: typing.Optional[float] = None, stream: typing.Optional[str] = None):
|
300
|
+
"""
|
301
|
+
Wait for the subprocess to finish, optionally with a timeout
|
302
|
+
and optionally streaming its output.
|
303
|
+
|
304
|
+
You can only call `wait` if `async_run` has already been called.
|
305
|
+
|
306
|
+
Parameters
|
307
|
+
----------
|
308
|
+
timeout : Optional[float], default None
|
309
|
+
The maximum time to wait for the subprocess to finish.
|
310
|
+
If the timeout is reached, the subprocess is killed.
|
311
|
+
stream : Optional[str], default None
|
312
|
+
If specified, the specified stream is printed to stdout. `stream` can
|
313
|
+
be one of `stdout` or `stderr`.
|
314
|
+
"""
|
315
|
+
...
|
316
|
+
def run(self, show_output: bool = False):
|
317
|
+
"""
|
318
|
+
Run the subprocess synchronously. This can only be called once.
|
319
|
+
|
320
|
+
This also waits on the process implicitly.
|
321
|
+
|
322
|
+
Parameters
|
323
|
+
----------
|
324
|
+
show_output : bool, default False
|
325
|
+
Suppress the 'stdout' and 'stderr' to the console by default.
|
326
|
+
They can be accessed later by reading the files present in:
|
327
|
+
- self.log_files["stdout"]
|
328
|
+
- self.log_files["stderr"]
|
329
|
+
"""
|
330
|
+
...
|
331
|
+
def async_run(self):
|
332
|
+
"""
|
333
|
+
Run the subprocess asynchronously. This can only be called once.
|
334
|
+
|
335
|
+
Once this is called, you can then wait on the process (using `wait`), stream
|
336
|
+
logs (using `stream_logs`) or kill it (using `kill`).
|
337
|
+
"""
|
338
|
+
...
|
339
|
+
def stream_log(self, stream: str, position: typing.Optional[int] = None, timeout_per_line: typing.Optional[float] = None, log_write_delay: float = 0.01) -> typing.Iterator[typing.Tuple[int, str]]:
|
340
|
+
"""
|
341
|
+
Stream logs from the subprocess line by line.
|
342
|
+
|
343
|
+
Parameters
|
344
|
+
----------
|
345
|
+
stream : str
|
346
|
+
The stream to stream logs from. Can be one of "stdout" or "stderr".
|
347
|
+
position : Optional[int], default None
|
348
|
+
The position in the log file to start streaming from. If None, it starts
|
349
|
+
from the beginning of the log file. This allows resuming streaming from
|
350
|
+
a previously known position
|
351
|
+
timeout_per_line : Optional[float], default None
|
352
|
+
The time to wait for a line to be read from the log file. If None, it
|
353
|
+
waits indefinitely. If the timeout is reached, a LogReadTimeoutError
|
354
|
+
is raised. Note that this timeout is *per line* and not cumulative so this
|
355
|
+
function may take significantly more time than `timeout_per_line`
|
356
|
+
log_write_delay : float, default 0.01
|
357
|
+
Improves the probability of getting whole lines. This setting is for
|
358
|
+
advanced use cases.
|
359
|
+
|
360
|
+
Yields
|
361
|
+
------
|
362
|
+
Tuple[int, str]
|
363
|
+
A tuple containing the position in the log file and the line read. The
|
364
|
+
position returned can be used to feed into another `stream_logs` call
|
365
|
+
for example.
|
366
|
+
"""
|
367
|
+
...
|
368
|
+
def emit_logs(self, stream: str = "stdout", custom_logger: typing.Callable[..., None] = print):
|
369
|
+
"""
|
370
|
+
Helper function that can easily emit all the logs for a given stream.
|
371
|
+
|
372
|
+
This function will only terminate when all the log has been printed.
|
373
|
+
|
374
|
+
Parameters
|
375
|
+
----------
|
376
|
+
stream : str, default "stdout"
|
377
|
+
The stream to emit logs for. Can be one of "stdout" or "stderr".
|
378
|
+
custom_logger : Callable[..., None], default print
|
379
|
+
A custom logger function that takes in a string and "emits" it. By default,
|
380
|
+
the log is printed to stdout.
|
381
|
+
"""
|
382
|
+
...
|
383
|
+
def cleanup(self):
|
384
|
+
"""
|
385
|
+
Clean up log files for a running subprocesses.
|
386
|
+
"""
|
387
|
+
...
|
388
|
+
def kill(self, termination_timeout: float = 1):
|
389
|
+
"""
|
390
|
+
Kill the subprocess and its descendants.
|
391
|
+
|
392
|
+
Parameters
|
393
|
+
----------
|
394
|
+
termination_timeout : float, default 1
|
395
|
+
The time to wait after sending a SIGTERM to the process and its descendants
|
396
|
+
before sending a SIGKILL.
|
397
|
+
"""
|
398
|
+
...
|
399
|
+
...
|
400
|
+
|
401
|
+
class SubprocessManager(object, metaclass=type):
|
402
|
+
def __init__(self):
|
403
|
+
...
|
404
|
+
def __aenter__(self) -> metaflow.runner.subprocess_manager.SubprocessManager:
|
405
|
+
...
|
406
|
+
def __aexit__(self, exc_type, exc_value, traceback):
|
407
|
+
...
|
408
|
+
def run_command(self, command: typing.List[str], env: typing.Optional[typing.Dict[str, str]] = None, cwd: typing.Optional[str] = None, show_output: bool = False) -> int:
|
409
|
+
"""
|
410
|
+
Run a command synchronously and return its process ID.
|
411
|
+
|
412
|
+
Parameters
|
413
|
+
----------
|
414
|
+
command : List[str]
|
415
|
+
The command to run in List form.
|
416
|
+
env : Optional[Dict[str, str]], default None
|
417
|
+
Environment variables to set for the subprocess; if not specified,
|
418
|
+
the current enviornment variables are used.
|
419
|
+
cwd : Optional[str], default None
|
420
|
+
The directory to run the subprocess in; if not specified, the current
|
421
|
+
directory is used.
|
422
|
+
show_output : bool, default False
|
423
|
+
Suppress the 'stdout' and 'stderr' to the console by default.
|
424
|
+
They can be accessed later by reading the files present in the
|
425
|
+
CommandManager object:
|
426
|
+
- command_obj.log_files["stdout"]
|
427
|
+
- command_obj.log_files["stderr"]
|
428
|
+
Returns
|
429
|
+
-------
|
430
|
+
int
|
431
|
+
The process ID of the subprocess.
|
432
|
+
"""
|
433
|
+
...
|
434
|
+
def async_run_command(self, command: typing.List[str], env: typing.Optional[typing.Dict[str, str]] = None, cwd: typing.Optional[str] = None) -> int:
|
435
|
+
"""
|
436
|
+
Run a command asynchronously and return its process ID.
|
437
|
+
|
438
|
+
Parameters
|
439
|
+
----------
|
440
|
+
command : List[str]
|
441
|
+
The command to run in List form.
|
442
|
+
env : Optional[Dict[str, str]], default None
|
443
|
+
Environment variables to set for the subprocess; if not specified,
|
444
|
+
the current enviornment variables are used.
|
445
|
+
cwd : Optional[str], default None
|
446
|
+
The directory to run the subprocess in; if not specified, the current
|
447
|
+
directory is used.
|
448
|
+
|
449
|
+
Returns
|
450
|
+
-------
|
451
|
+
int
|
452
|
+
The process ID of the subprocess.
|
453
|
+
"""
|
454
|
+
...
|
455
|
+
def get(self, pid: int) -> typing.Optional["CommandManager"]:
|
456
|
+
"""
|
457
|
+
Get one of the CommandManager managed by this SubprocessManager.
|
458
|
+
|
459
|
+
Parameters
|
460
|
+
----------
|
461
|
+
pid : int
|
462
|
+
The process ID of the subprocess (returned by run_command or async_run_command).
|
463
|
+
|
464
|
+
Returns
|
465
|
+
-------
|
466
|
+
Optional[CommandManager]
|
467
|
+
The CommandManager object for the given process ID, or None if not found.
|
468
|
+
"""
|
469
|
+
...
|
470
|
+
def cleanup(self):
|
471
|
+
"""
|
472
|
+
Clean up log files for all running subprocesses.
|
473
|
+
"""
|
474
|
+
...
|
475
|
+
...
|
476
|
+
|
477
|
+
def clear_and_set_os_environ(env: typing.Dict):
|
478
|
+
...
|
479
|
+
|
480
|
+
def read_from_file_when_ready(file_path: str, timeout: float = 5):
|
481
|
+
...
|
482
|
+
|
483
|
+
class ExecutingRun(object, metaclass=type):
|
484
|
+
def __init__(self, runner: Runner, command_obj: metaflow.runner.subprocess_manager.CommandManager, run_obj: metaflow.client.core.Run):
|
485
|
+
"""
|
486
|
+
Create a new ExecutingRun -- this should not be done by the user directly but
|
487
|
+
instead user Runner.run()
|
488
|
+
|
489
|
+
Parameters
|
490
|
+
----------
|
491
|
+
runner : Runner
|
492
|
+
Parent runner for this run.
|
493
|
+
command_obj : CommandManager
|
494
|
+
CommandManager containing the subprocess executing this run.
|
495
|
+
run_obj : Run
|
496
|
+
Run object corresponding to this run.
|
497
|
+
"""
|
498
|
+
...
|
499
|
+
def __enter__(self) -> ExecutingRun:
|
500
|
+
...
|
501
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
502
|
+
...
|
503
|
+
def wait(self, timeout: typing.Optional[float] = None, stream: typing.Optional[str] = None) -> ExecutingRun:
|
504
|
+
"""
|
505
|
+
Wait for this run to finish, optionally with a timeout
|
506
|
+
and optionally streaming its output.
|
507
|
+
|
508
|
+
Note that this method is asynchronous and needs to be `await`ed.
|
509
|
+
|
510
|
+
Parameters
|
511
|
+
----------
|
512
|
+
timeout : Optional[float], default None
|
513
|
+
The maximum time to wait for the run to finish.
|
514
|
+
If the timeout is reached, the run is terminated
|
515
|
+
stream : Optional[str], default None
|
516
|
+
If specified, the specified stream is printed to stdout. `stream` can
|
517
|
+
be one of `stdout` or `stderr`.
|
518
|
+
|
519
|
+
Returns
|
520
|
+
-------
|
521
|
+
ExecutingRun
|
522
|
+
This object, allowing you to chain calls.
|
523
|
+
"""
|
524
|
+
...
|
525
|
+
@property
|
526
|
+
def returncode(self) -> typing.Optional[int]:
|
527
|
+
"""
|
528
|
+
Gets the return code of the underlying subprocess. A non-zero
|
529
|
+
code indicates a failure, `None` a currently executing run.
|
530
|
+
|
531
|
+
Returns
|
532
|
+
-------
|
533
|
+
Optional[int]
|
534
|
+
The return code of the underlying subprocess.
|
535
|
+
"""
|
536
|
+
...
|
537
|
+
@property
|
538
|
+
def status(self) -> str:
|
539
|
+
"""
|
540
|
+
Returns the status of the underlying subprocess that is responsible
|
541
|
+
for executing the run.
|
542
|
+
|
543
|
+
The return value is one of the following strings:
|
544
|
+
- `running` indicates a currently executing run.
|
545
|
+
- `failed` indicates a failed run.
|
546
|
+
- `successful` a successful run.
|
547
|
+
|
548
|
+
Returns
|
549
|
+
-------
|
550
|
+
str
|
551
|
+
The current status of the run.
|
552
|
+
"""
|
553
|
+
...
|
554
|
+
@property
|
555
|
+
def stdout(self) -> str:
|
556
|
+
"""
|
557
|
+
Returns the current stdout of the run. If the run is finished, this will
|
558
|
+
contain the entire stdout output. Otherwise, it will contain the
|
559
|
+
stdout up until this point.
|
560
|
+
|
561
|
+
Returns
|
562
|
+
-------
|
563
|
+
str
|
564
|
+
The current snapshot of stdout.
|
565
|
+
"""
|
566
|
+
...
|
567
|
+
@property
|
568
|
+
def stderr(self) -> str:
|
569
|
+
"""
|
570
|
+
Returns the current stderr of the run. If the run is finished, this will
|
571
|
+
contain the entire stderr output. Otherwise, it will contain the
|
572
|
+
stderr up until this point.
|
573
|
+
|
574
|
+
Returns
|
575
|
+
-------
|
576
|
+
str
|
577
|
+
The current snapshot of stderr.
|
578
|
+
"""
|
579
|
+
...
|
580
|
+
def stream_log(self, stream: str, position: typing.Optional[int] = None) -> typing.Iterator[typing.Tuple[int, str]]:
|
581
|
+
"""
|
582
|
+
Asynchronous iterator to stream logs from the subprocess line by line.
|
583
|
+
|
584
|
+
Note that this method is asynchronous and needs to be `await`ed.
|
585
|
+
|
586
|
+
Parameters
|
587
|
+
----------
|
588
|
+
stream : str
|
589
|
+
The stream to stream logs from. Can be one of `stdout` or `stderr`.
|
590
|
+
position : Optional[int], default None
|
591
|
+
The position in the log file to start streaming from. If None, it starts
|
592
|
+
from the beginning of the log file. This allows resuming streaming from
|
593
|
+
a previously known position
|
594
|
+
|
595
|
+
Yields
|
596
|
+
------
|
597
|
+
Tuple[int, str]
|
598
|
+
A tuple containing the position in the log file and the line read. The
|
599
|
+
position returned can be used to feed into another `stream_logs` call
|
600
|
+
for example.
|
601
|
+
"""
|
602
|
+
...
|
603
|
+
...
|
604
|
+
|
605
|
+
class Runner(object, metaclass=type):
|
606
|
+
def __init__(self, flow_file: str, show_output: bool = True, profile: typing.Optional[str] = None, env: typing.Optional[typing.Dict] = None, cwd: typing.Optional[str] = None, **kwargs):
|
607
|
+
...
|
608
|
+
def __enter__(self) -> Runner:
|
609
|
+
...
|
610
|
+
def __aenter__(self) -> Runner:
|
611
|
+
...
|
612
|
+
def _Runner__get_executing_run(self, tfp_runner_attribute, command_obj):
|
613
|
+
...
|
614
|
+
def run(self, **kwargs) -> ExecutingRun:
|
615
|
+
"""
|
616
|
+
Blocking execution of the run. This method will wait until
|
617
|
+
the run has completed execution.
|
618
|
+
|
619
|
+
Parameters
|
620
|
+
----------
|
621
|
+
**kwargs : Any
|
622
|
+
Additional arguments that you would pass to `python myflow.py` after
|
623
|
+
the `run` command, in particular, any parameters accepted by the flow.
|
624
|
+
|
625
|
+
Returns
|
626
|
+
-------
|
627
|
+
ExecutingRun
|
628
|
+
ExecutingRun containing the results of the run.
|
629
|
+
"""
|
630
|
+
...
|
631
|
+
def resume(self, **kwargs):
|
632
|
+
"""
|
633
|
+
Blocking resume execution of the run.
|
634
|
+
This method will wait until the resumed run has completed execution.
|
635
|
+
|
636
|
+
Parameters
|
637
|
+
----------
|
638
|
+
**kwargs : Any
|
639
|
+
Additional arguments that you would pass to `python ./myflow.py` after
|
640
|
+
the `resume` command.
|
641
|
+
|
642
|
+
Returns
|
643
|
+
-------
|
644
|
+
ExecutingRun
|
645
|
+
ExecutingRun containing the results of the resumed run.
|
646
|
+
"""
|
647
|
+
...
|
648
|
+
def async_run(self, **kwargs) -> ExecutingRun:
|
649
|
+
"""
|
650
|
+
Non-blocking execution of the run. This method will return as soon as the
|
651
|
+
run has launched.
|
652
|
+
|
653
|
+
Note that this method is asynchronous and needs to be `await`ed.
|
654
|
+
|
655
|
+
Parameters
|
656
|
+
----------
|
657
|
+
**kwargs : Any
|
658
|
+
Additional arguments that you would pass to `python myflow.py` after
|
659
|
+
the `run` command, in particular, any parameters accepted by the flow.
|
660
|
+
|
661
|
+
Returns
|
662
|
+
-------
|
663
|
+
ExecutingRun
|
664
|
+
ExecutingRun representing the run that was started.
|
665
|
+
"""
|
666
|
+
...
|
667
|
+
def async_resume(self, **kwargs):
|
668
|
+
"""
|
669
|
+
Non-blocking resume execution of the run.
|
670
|
+
This method will return as soon as the resume has launched.
|
671
|
+
|
672
|
+
Note that this method is asynchronous and needs to be `await`ed.
|
673
|
+
|
674
|
+
Parameters
|
675
|
+
----------
|
676
|
+
**kwargs : Any
|
677
|
+
Additional arguments that you would pass to `python myflow.py` after
|
678
|
+
the `resume` command.
|
679
|
+
|
680
|
+
Returns
|
681
|
+
-------
|
682
|
+
ExecutingRun
|
683
|
+
ExecutingRun representing the resumed run that was started.
|
684
|
+
"""
|
685
|
+
...
|
686
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
687
|
+
...
|
688
|
+
def __aexit__(self, exc_type, exc_value, traceback):
|
689
|
+
...
|
690
|
+
def cleanup(self):
|
691
|
+
"""
|
692
|
+
Delete any temporary files created during execution.
|
693
|
+
"""
|
694
|
+
...
|
695
|
+
...
|
696
|
+
|