wmill 1.510.0__py3-none-any.whl → 1.511.0__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.
Potentially problematic release.
This version of wmill might be problematic. Click here for more details.
wmill/client.py
CHANGED
|
@@ -120,22 +120,58 @@ class Windmill:
|
|
|
120
120
|
args: dict = None,
|
|
121
121
|
scheduled_in_secs: int = None,
|
|
122
122
|
) -> str:
|
|
123
|
-
"""Create a script job and return its job id.
|
|
123
|
+
"""Create a script job and return its job id.
|
|
124
|
+
|
|
125
|
+
.. deprecated:: Use run_script_by_path_async or run_script_by_hash_async instead.
|
|
126
|
+
"""
|
|
127
|
+
logging.warning(
|
|
128
|
+
"run_script_async is deprecated. Use run_script_by_path_async or run_script_by_hash_async instead.",
|
|
129
|
+
)
|
|
124
130
|
assert not (path and hash_), "path and hash_ are mutually exclusive"
|
|
131
|
+
return self._run_script_async_internal(path=path, hash_=hash_, args=args, scheduled_in_secs=scheduled_in_secs)
|
|
132
|
+
|
|
133
|
+
def _run_script_async_internal(
|
|
134
|
+
self,
|
|
135
|
+
path: str = None,
|
|
136
|
+
hash_: str = None,
|
|
137
|
+
args: dict = None,
|
|
138
|
+
scheduled_in_secs: int = None,
|
|
139
|
+
) -> str:
|
|
140
|
+
"""Internal helper for running scripts asynchronously."""
|
|
125
141
|
args = args or {}
|
|
126
142
|
params = {"scheduled_in_secs": scheduled_in_secs} if scheduled_in_secs else {}
|
|
127
143
|
if os.environ.get("WM_JOB_ID"):
|
|
128
144
|
params["parent_job"] = os.environ.get("WM_JOB_ID")
|
|
129
145
|
if os.environ.get("WM_ROOT_FLOW_JOB_ID"):
|
|
130
146
|
params["root_job"] = os.environ.get("WM_ROOT_FLOW_JOB_ID")
|
|
147
|
+
|
|
131
148
|
if path:
|
|
132
149
|
endpoint = f"/w/{self.workspace}/jobs/run/p/{path}"
|
|
133
150
|
elif hash_:
|
|
134
151
|
endpoint = f"/w/{self.workspace}/jobs/run/h/{hash_}"
|
|
135
152
|
else:
|
|
136
153
|
raise Exception("path or hash_ must be provided")
|
|
154
|
+
|
|
137
155
|
return self.post(endpoint, json=args, params=params).text
|
|
138
156
|
|
|
157
|
+
def run_script_by_path_async(
|
|
158
|
+
self,
|
|
159
|
+
path: str,
|
|
160
|
+
args: dict = None,
|
|
161
|
+
scheduled_in_secs: int = None,
|
|
162
|
+
) -> str:
|
|
163
|
+
"""Create a script job by path and return its job id."""
|
|
164
|
+
return self._run_script_async_internal(path=path, args=args, scheduled_in_secs=scheduled_in_secs)
|
|
165
|
+
|
|
166
|
+
def run_script_by_hash_async(
|
|
167
|
+
self,
|
|
168
|
+
hash_: str,
|
|
169
|
+
args: dict = None,
|
|
170
|
+
scheduled_in_secs: int = None,
|
|
171
|
+
) -> str:
|
|
172
|
+
"""Create a script job by hash and return its job id."""
|
|
173
|
+
return self._run_script_async_internal(hash_=hash_, args=args, scheduled_in_secs=scheduled_in_secs)
|
|
174
|
+
|
|
139
175
|
def run_flow_async(
|
|
140
176
|
self,
|
|
141
177
|
path: str,
|
|
@@ -170,20 +206,76 @@ class Windmill:
|
|
|
170
206
|
cleanup: bool = True,
|
|
171
207
|
assert_result_is_not_none: bool = False,
|
|
172
208
|
) -> Any:
|
|
173
|
-
"""Run script synchronously and return its result.
|
|
209
|
+
"""Run script synchronously and return its result.
|
|
210
|
+
|
|
211
|
+
.. deprecated:: Use run_script_by_path or run_script_by_hash instead.
|
|
212
|
+
"""
|
|
213
|
+
logging.warning(
|
|
214
|
+
"run_script is deprecated. Use run_script_by_path or run_script_by_hash instead.",
|
|
215
|
+
)
|
|
216
|
+
assert not (path and hash_), "path and hash_ are mutually exclusive"
|
|
217
|
+
return self._run_script_internal(
|
|
218
|
+
path=path, hash_=hash_, args=args, timeout=timeout, verbose=verbose,
|
|
219
|
+
cleanup=cleanup, assert_result_is_not_none=assert_result_is_not_none
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
def _run_script_internal(
|
|
223
|
+
self,
|
|
224
|
+
path: str = None,
|
|
225
|
+
hash_: str = None,
|
|
226
|
+
args: dict = None,
|
|
227
|
+
timeout: dt.timedelta | int | float | None = None,
|
|
228
|
+
verbose: bool = False,
|
|
229
|
+
cleanup: bool = True,
|
|
230
|
+
assert_result_is_not_none: bool = False,
|
|
231
|
+
) -> Any:
|
|
232
|
+
"""Internal helper for running scripts synchronously."""
|
|
174
233
|
args = args or {}
|
|
175
234
|
|
|
176
235
|
if verbose:
|
|
177
|
-
|
|
236
|
+
if path:
|
|
237
|
+
logger.info(f"running `{path}` synchronously with {args = }")
|
|
238
|
+
elif hash_:
|
|
239
|
+
logger.info(f"running script with hash `{hash_}` synchronously with {args = }")
|
|
178
240
|
|
|
179
241
|
if isinstance(timeout, dt.timedelta):
|
|
180
242
|
timeout = timeout.total_seconds()
|
|
181
243
|
|
|
182
|
-
job_id = self.
|
|
244
|
+
job_id = self._run_script_async_internal(path=path, hash_=hash_, args=args)
|
|
183
245
|
return self.wait_job(
|
|
184
246
|
job_id, timeout, verbose, cleanup, assert_result_is_not_none
|
|
185
247
|
)
|
|
186
248
|
|
|
249
|
+
def run_script_by_path(
|
|
250
|
+
self,
|
|
251
|
+
path: str,
|
|
252
|
+
args: dict = None,
|
|
253
|
+
timeout: dt.timedelta | int | float | None = None,
|
|
254
|
+
verbose: bool = False,
|
|
255
|
+
cleanup: bool = True,
|
|
256
|
+
assert_result_is_not_none: bool = False,
|
|
257
|
+
) -> Any:
|
|
258
|
+
"""Run script by path synchronously and return its result."""
|
|
259
|
+
return self._run_script_internal(
|
|
260
|
+
path=path, args=args, timeout=timeout, verbose=verbose,
|
|
261
|
+
cleanup=cleanup, assert_result_is_not_none=assert_result_is_not_none
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
def run_script_by_hash(
|
|
265
|
+
self,
|
|
266
|
+
hash_: str,
|
|
267
|
+
args: dict = None,
|
|
268
|
+
timeout: dt.timedelta | int | float | None = None,
|
|
269
|
+
verbose: bool = False,
|
|
270
|
+
cleanup: bool = True,
|
|
271
|
+
assert_result_is_not_none: bool = False,
|
|
272
|
+
) -> Any:
|
|
273
|
+
"""Run script by hash synchronously and return its result."""
|
|
274
|
+
return self._run_script_internal(
|
|
275
|
+
hash_=hash_, args=args, timeout=timeout, verbose=verbose,
|
|
276
|
+
cleanup=cleanup, assert_result_is_not_none=assert_result_is_not_none
|
|
277
|
+
)
|
|
278
|
+
|
|
187
279
|
def wait_job(
|
|
188
280
|
self,
|
|
189
281
|
job_id,
|
|
@@ -964,13 +1056,26 @@ def run_script_by_path_async(
|
|
|
964
1056
|
args: Dict[str, Any] = None,
|
|
965
1057
|
scheduled_in_secs: Union[None, int] = None,
|
|
966
1058
|
) -> str:
|
|
967
|
-
return _client.
|
|
1059
|
+
return _client.run_script_by_path_async(
|
|
968
1060
|
path=path,
|
|
969
1061
|
args=args,
|
|
970
1062
|
scheduled_in_secs=scheduled_in_secs,
|
|
971
1063
|
)
|
|
972
1064
|
|
|
973
1065
|
|
|
1066
|
+
@init_global_client
|
|
1067
|
+
def run_script_by_hash_async(
|
|
1068
|
+
hash_: str,
|
|
1069
|
+
args: Dict[str, Any] = None,
|
|
1070
|
+
scheduled_in_secs: Union[None, int] = None,
|
|
1071
|
+
) -> str:
|
|
1072
|
+
return _client.run_script_by_hash_async(
|
|
1073
|
+
hash_=hash_,
|
|
1074
|
+
args=args,
|
|
1075
|
+
scheduled_in_secs=scheduled_in_secs,
|
|
1076
|
+
)
|
|
1077
|
+
|
|
1078
|
+
|
|
974
1079
|
@init_global_client
|
|
975
1080
|
def run_script_by_path_sync(
|
|
976
1081
|
path: str,
|
|
@@ -1274,7 +1379,10 @@ def run_script(
|
|
|
1274
1379
|
cleanup: bool = True,
|
|
1275
1380
|
assert_result_is_not_none: bool = True,
|
|
1276
1381
|
) -> Any:
|
|
1277
|
-
"""Run script synchronously and return its result.
|
|
1382
|
+
"""Run script synchronously and return its result.
|
|
1383
|
+
|
|
1384
|
+
.. deprecated:: Use run_script_by_path or run_script_by_hash instead.
|
|
1385
|
+
"""
|
|
1278
1386
|
return _client.run_script(
|
|
1279
1387
|
path=path,
|
|
1280
1388
|
hash_=hash_,
|
|
@@ -1286,6 +1394,46 @@ def run_script(
|
|
|
1286
1394
|
)
|
|
1287
1395
|
|
|
1288
1396
|
|
|
1397
|
+
@init_global_client
|
|
1398
|
+
def run_script_by_path(
|
|
1399
|
+
path: str,
|
|
1400
|
+
args: dict = None,
|
|
1401
|
+
timeout: dt.timedelta | int | float = None,
|
|
1402
|
+
verbose: bool = False,
|
|
1403
|
+
cleanup: bool = True,
|
|
1404
|
+
assert_result_is_not_none: bool = True,
|
|
1405
|
+
) -> Any:
|
|
1406
|
+
"""Run script by path synchronously and return its result."""
|
|
1407
|
+
return _client.run_script_by_path(
|
|
1408
|
+
path=path,
|
|
1409
|
+
args=args,
|
|
1410
|
+
verbose=verbose,
|
|
1411
|
+
assert_result_is_not_none=assert_result_is_not_none,
|
|
1412
|
+
cleanup=cleanup,
|
|
1413
|
+
timeout=timeout,
|
|
1414
|
+
)
|
|
1415
|
+
|
|
1416
|
+
|
|
1417
|
+
@init_global_client
|
|
1418
|
+
def run_script_by_hash(
|
|
1419
|
+
hash_: str,
|
|
1420
|
+
args: dict = None,
|
|
1421
|
+
timeout: dt.timedelta | int | float = None,
|
|
1422
|
+
verbose: bool = False,
|
|
1423
|
+
cleanup: bool = True,
|
|
1424
|
+
assert_result_is_not_none: bool = True,
|
|
1425
|
+
) -> Any:
|
|
1426
|
+
"""Run script by hash synchronously and return its result."""
|
|
1427
|
+
return _client.run_script_by_hash(
|
|
1428
|
+
hash_=hash_,
|
|
1429
|
+
args=args,
|
|
1430
|
+
verbose=verbose,
|
|
1431
|
+
assert_result_is_not_none=assert_result_is_not_none,
|
|
1432
|
+
cleanup=cleanup,
|
|
1433
|
+
timeout=timeout,
|
|
1434
|
+
)
|
|
1435
|
+
|
|
1436
|
+
|
|
1289
1437
|
@init_global_client
|
|
1290
1438
|
def username_to_email(username: str) -> str:
|
|
1291
1439
|
"""
|
|
@@ -1374,4 +1522,4 @@ def parse_variable_syntax(s: str) -> Optional[str]:
|
|
|
1374
1522
|
"""Parse variable syntax from string."""
|
|
1375
1523
|
if s.startswith("var://"):
|
|
1376
1524
|
return s[6:]
|
|
1377
|
-
return None
|
|
1525
|
+
return None
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
wmill/__init__.py,sha256=nGZnQPezTdrBnBW1D0JqUtm75Gdf_xi3tAcPGwHRZ5A,46
|
|
2
|
-
wmill/client.py,sha256=
|
|
2
|
+
wmill/client.py,sha256=xGTljbaALXwQPxzZs0eYsMigRwbR1pBfNw_P3uYIJM8,49910
|
|
3
3
|
wmill/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
|
|
4
4
|
wmill/s3_reader.py,sha256=_z7izXgA252DaBHaBNO4EEYnK4uZfNQgZAYMRNucvyc,2135
|
|
5
5
|
wmill/s3_types.py,sha256=S5w6fVAai5Adm1MxZoxF21R-EE5-wRfGzXBK72-FZvE,1199
|
|
6
|
-
wmill-1.
|
|
7
|
-
wmill-1.
|
|
8
|
-
wmill-1.
|
|
6
|
+
wmill-1.511.0.dist-info/METADATA,sha256=4pga1rVzSIxN_8qlmjhJPnS7wvN1Ij_yVGkWA3sU0kU,2693
|
|
7
|
+
wmill-1.511.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
|
8
|
+
wmill-1.511.0.dist-info/RECORD,,
|
|
File without changes
|