wmill 1.334.0__py3-none-any.whl → 1.336.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.
wmill/client.py
CHANGED
@@ -142,9 +142,7 @@ class Windmill:
|
|
142
142
|
timeout = timeout.total_seconds()
|
143
143
|
|
144
144
|
job_id = self.run_script_async(path=path, hash_=hash_, args=args)
|
145
|
-
return self.wait_job(
|
146
|
-
job_id, timeout, verbose, cleanup, assert_result_is_not_none
|
147
|
-
)
|
145
|
+
return self.wait_job(job_id, timeout, verbose, cleanup, assert_result_is_not_none)
|
148
146
|
|
149
147
|
def wait_job(
|
150
148
|
self,
|
@@ -183,7 +181,7 @@ class Windmill:
|
|
183
181
|
atexit.unregister(cancel_job)
|
184
182
|
|
185
183
|
if completed:
|
186
|
-
result =
|
184
|
+
result = result_res["result"]
|
187
185
|
if success:
|
188
186
|
if result is None and assert_result_is_not_none:
|
189
187
|
raise Exception("Result was none")
|
@@ -203,10 +201,8 @@ class Windmill:
|
|
203
201
|
if verbose:
|
204
202
|
logger.info(f"sleeping 0.5 seconds for {job_id = }")
|
205
203
|
|
206
|
-
|
207
204
|
time.sleep(0.5)
|
208
205
|
|
209
|
-
|
210
206
|
def cancel_running(self) -> dict:
|
211
207
|
"""Cancel currently running executions of the same script."""
|
212
208
|
logger.info("canceling running executions of this script")
|
@@ -247,7 +243,6 @@ class Windmill:
|
|
247
243
|
job_id = job_id or os.environ.get("WM_JOB_ID")
|
248
244
|
return self.get(f"/w/{self.workspace}/jobs_u/get_root_job_id/{job_id}").json()
|
249
245
|
|
250
|
-
|
251
246
|
def get_id_token(self, audience: str) -> str:
|
252
247
|
return self.post(f"/w/{self.workspace}/oidc/token/{audience}").text
|
253
248
|
|
@@ -349,11 +344,10 @@ class Windmill:
|
|
349
344
|
def set_flow_user_state(self, key: str, value: Any) -> None:
|
350
345
|
"""Set the user state of a flow at a given key"""
|
351
346
|
flow_id = self.get_root_job_id()
|
352
|
-
r = self.post(f"/w/{self.workspace}/jobs/flow/user_states/{flow_id}/{key}", json=value,
|
347
|
+
r = self.post(f"/w/{self.workspace}/jobs/flow/user_states/{flow_id}/{key}", json=value, raise_for_status=False)
|
353
348
|
if r.status_code == 404:
|
354
349
|
print(f"Job {flow_id} does not exist or is not a flow")
|
355
350
|
|
356
|
-
|
357
351
|
def get_flow_user_state(self, key: str) -> Any:
|
358
352
|
"""Get the user state of a flow at a given key"""
|
359
353
|
flow_id = self.get_root_job_id()
|
@@ -568,7 +562,7 @@ class Windmill:
|
|
568
562
|
@staticmethod
|
569
563
|
def get_shared_state(path: str = "state.json") -> None:
|
570
564
|
"""
|
571
|
-
|
565
|
+
Get the state in the shared folder using pickle
|
572
566
|
"""
|
573
567
|
import json
|
574
568
|
|
@@ -583,6 +577,14 @@ class Windmill:
|
|
583
577
|
params={"approver": approver},
|
584
578
|
).json()
|
585
579
|
|
580
|
+
def username_to_email(self, username: str) -> str:
|
581
|
+
"""
|
582
|
+
Get email from workspace username
|
583
|
+
This method is particularly useful for apps that require the email address of the viewer.
|
584
|
+
Indeed, in the viewer context WM_USERNAME is set to the username of the viewer but WM_EMAIL is set to the email of the creator of the app.
|
585
|
+
"""
|
586
|
+
return self.get(f"/w/{self.workspace}/users/username_to_email/{username}").text
|
587
|
+
|
586
588
|
|
587
589
|
def init_global_client(f):
|
588
590
|
@functools.wraps(f)
|
@@ -617,6 +619,7 @@ def deprecate(in_favor_of: str):
|
|
617
619
|
def get_workspace() -> str:
|
618
620
|
return _client.workspace
|
619
621
|
|
622
|
+
|
620
623
|
@init_global_client
|
621
624
|
def get_root_job_id(job_id: str | None = None) -> str:
|
622
625
|
return _client.get_root_job_id(job_id)
|
@@ -848,7 +851,7 @@ def set_shared_state(value: Any, path="state.json") -> None:
|
|
848
851
|
|
849
852
|
def get_shared_state(path="state.json") -> None:
|
850
853
|
"""
|
851
|
-
|
854
|
+
Get the state in the shared folder using pickle
|
852
855
|
"""
|
853
856
|
return Windmill.get_shared_state(path=path)
|
854
857
|
|
@@ -876,6 +879,7 @@ def get_flow_user_state(key: str) -> Any:
|
|
876
879
|
"""
|
877
880
|
return _client.get_flow_user_state(key)
|
878
881
|
|
882
|
+
|
879
883
|
@init_global_client
|
880
884
|
def set_flow_user_state(key: str, value: Any) -> None:
|
881
885
|
"""
|
@@ -922,10 +926,22 @@ def run_script(
|
|
922
926
|
)
|
923
927
|
|
924
928
|
|
929
|
+
@init_global_client
|
930
|
+
def username_to_email(username: str) -> str:
|
931
|
+
"""
|
932
|
+
Get email from workspace username
|
933
|
+
This method is particularly useful for apps that require the email address of the viewer.
|
934
|
+
Indeed, in the viewer context WM_USERNAME is set to the username of the viewer but WM_EMAIL is set to the email of the creator of the app.
|
935
|
+
"""
|
936
|
+
return _client.username_to_email(username)
|
937
|
+
|
938
|
+
|
925
939
|
def task(*args, **kwargs):
|
926
940
|
from inspect import signature
|
941
|
+
|
927
942
|
def f(func, tag: str | None = None):
|
928
943
|
if os.environ.get("WM_JOB_ID") is None or os.environ.get("MAIN_OVERRIDE") == func.__name__:
|
944
|
+
|
929
945
|
def inner(*args, **kwargs):
|
930
946
|
return func(*args, **kwargs)
|
931
947
|
|
@@ -963,9 +979,8 @@ def task(*args, **kwargs):
|
|
963
979
|
return r
|
964
980
|
|
965
981
|
return inner
|
982
|
+
|
966
983
|
if len(args) == 1 and len(kwargs) == 0 and callable(args[0]):
|
967
984
|
return f(args[0], None)
|
968
985
|
else:
|
969
986
|
return lambda x: f(x, kwargs.get("tag"))
|
970
|
-
|
971
|
-
|
@@ -1,8 +1,8 @@
|
|
1
1
|
wmill/__init__.py,sha256=nGZnQPezTdrBnBW1D0JqUtm75Gdf_xi3tAcPGwHRZ5A,46
|
2
|
-
wmill/client.py,sha256=
|
2
|
+
wmill/client.py,sha256=bCr9svlONt82xuS-pL1JezvLvFVfeHuTPJoNEaLNRS4,32133
|
3
3
|
wmill/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
|
4
4
|
wmill/s3_reader.py,sha256=ZznXPIdMkP7S17CJ5scBJAyLDHBKAaqZB-B_l9pRIzA,1575
|
5
5
|
wmill/s3_types.py,sha256=axVibTMtpynBwaCVK0O6bBao56no01qflyIGRaVyV6s,1149
|
6
|
-
wmill-1.
|
7
|
-
wmill-1.
|
8
|
-
wmill-1.
|
6
|
+
wmill-1.336.0.dist-info/METADATA,sha256=apSCyVMOi-yrGpJ1DUi6HZMGOBd05tCsP-GklQLBsTI,2699
|
7
|
+
wmill-1.336.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
8
|
+
wmill-1.336.0.dist-info/RECORD,,
|
File without changes
|