wmill 1.214.1__py3-none-any.whl → 1.216.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
|
@@ -125,7 +125,7 @@ class Windmill:
|
|
|
125
125
|
atexit.register(cancel_job)
|
|
126
126
|
|
|
127
127
|
while True:
|
|
128
|
-
job = self.
|
|
128
|
+
job = self.get_job(job_id)
|
|
129
129
|
|
|
130
130
|
if timeout and ((time.time() - start_time) > timeout):
|
|
131
131
|
msg = "reached timeout"
|
|
@@ -139,17 +139,23 @@ class Windmill:
|
|
|
139
139
|
result = job.get("result")
|
|
140
140
|
canceled, canceled_reason = job.get("canceled"), job.get("canceled_reason")
|
|
141
141
|
success = job.get("success")
|
|
142
|
+
job_type = job.get("type", "")
|
|
143
|
+
completed = job_type.lower() == "completedjob"
|
|
142
144
|
|
|
143
|
-
if cleanup and
|
|
145
|
+
if cleanup and completed:
|
|
144
146
|
atexit.unregister(cancel_job)
|
|
145
147
|
|
|
146
|
-
if
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
if completed:
|
|
149
|
+
if success:
|
|
150
|
+
if assert_result_is_not_none and result is None:
|
|
151
|
+
raise Exception(f"result is None for {job_id = }")
|
|
152
|
+
return result
|
|
153
|
+
else:
|
|
154
|
+
if canceled:
|
|
155
|
+
raise Exception(f"job canceled: {canceled_reason}")
|
|
156
|
+
else:
|
|
157
|
+
error = result.get("error")
|
|
158
|
+
raise Exception(f"job failed: {error}")
|
|
153
159
|
|
|
154
160
|
if verbose:
|
|
155
161
|
logger.info(f"sleeping 0.5 seconds for {job_id = }")
|
|
@@ -189,18 +195,16 @@ class Windmill:
|
|
|
189
195
|
|
|
190
196
|
return result
|
|
191
197
|
|
|
198
|
+
def get_job(self, job_id: str) -> dict:
|
|
199
|
+
return self.get(f"/w/{self.workspace}/jobs_u/get/{job_id}").json()
|
|
200
|
+
|
|
192
201
|
def get_job_status(self, job_id: str) -> JobStatus:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
)
|
|
197
|
-
assert not resp.status_code == 404, f"{job_id} not found"
|
|
198
|
-
resp_json = resp.json()
|
|
199
|
-
job_type = resp_json.get("type", "")
|
|
200
|
-
assert job_type, f"{resp_json} is not a valid job"
|
|
202
|
+
job = self.get_job(job_id)
|
|
203
|
+
job_type = job.get("type", "")
|
|
204
|
+
assert job_type, f"{job} is not a valid job"
|
|
201
205
|
if job_type.lower() == "completedjob":
|
|
202
206
|
return "COMPLETED"
|
|
203
|
-
additional_properties =
|
|
207
|
+
additional_properties = job.get("additional_properties", {})
|
|
204
208
|
if "running" not in additional_properties:
|
|
205
209
|
raise Exception(f"{job_id} is not running")
|
|
206
210
|
if additional_properties.get("running"):
|
|
@@ -253,7 +257,7 @@ class Windmill:
|
|
|
253
257
|
self,
|
|
254
258
|
path: str,
|
|
255
259
|
none_if_undefined: bool = False,
|
|
256
|
-
) -> str | None:
|
|
260
|
+
) -> str | dict | None:
|
|
257
261
|
"""Get resource from Windmill"""
|
|
258
262
|
try:
|
|
259
263
|
return self.get(
|
|
@@ -567,7 +571,7 @@ def get_state() -> Any:
|
|
|
567
571
|
def get_resource(
|
|
568
572
|
path: str,
|
|
569
573
|
none_if_undefined: bool = False,
|
|
570
|
-
) -> str | None:
|
|
574
|
+
) -> str | dict | None:
|
|
571
575
|
"""Get resource from Windmill"""
|
|
572
576
|
return _client.get_resource(path, none_if_undefined)
|
|
573
577
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
wmill/__init__.py,sha256=d0Q6Fn44e7wFfLabDOBxpcJ1DPKWlFunGYDUBmO-4hA,22
|
|
2
|
+
wmill/client.py,sha256=TyNaAiPsvG2a1dtcV0598OsWBwYetSXLZs_bqL6wm8E,19573
|
|
3
|
+
wmill/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
|
|
4
|
+
wmill-1.216.0.dist-info/METADATA,sha256=WddJXyU_BfnCQJ0phGyWTohswEhQL1BdMp5Yj_reU1E,2699
|
|
5
|
+
wmill-1.216.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
|
6
|
+
wmill-1.216.0.dist-info/RECORD,,
|
wmill-1.214.1.dist-info/RECORD
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
wmill/__init__.py,sha256=d0Q6Fn44e7wFfLabDOBxpcJ1DPKWlFunGYDUBmO-4hA,22
|
|
2
|
-
wmill/client.py,sha256=3YeuRnvm2KrywzVjMi4Ar1BKwtiFnvY-D4F92Ezmw1E,19375
|
|
3
|
-
wmill/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
|
|
4
|
-
wmill-1.214.1.dist-info/METADATA,sha256=Q0bD6AyKdyERMWKrH-aDSPElbHnHWjnYt_ZPdXL6654,2699
|
|
5
|
-
wmill-1.214.1.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
|
6
|
-
wmill-1.214.1.dist-info/RECORD,,
|
|
File without changes
|