wmill 1.215.0__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.get(f"/w/{self.workspace}/jobs_u/get/{job_id}").json()
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 (canceled or success):
145
+ if cleanup and completed:
144
146
  atexit.unregister(cancel_job)
145
147
 
146
- if canceled:
147
- raise Exception(f"job canceled: {canceled_reason}")
148
-
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
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
- resp = self.get(
194
- f"/w/{self.workspace}/jobs_u/get/{job_id}",
195
- raise_for_status=False,
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 = resp_json.get("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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wmill
3
- Version: 1.215.0
3
+ Version: 1.216.0
4
4
  Summary: A client library for accessing Windmill server wrapping the Windmill client API
5
5
  Home-page: https://windmill.dev
6
6
  License: Apache-2.0
@@ -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,,
@@ -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.215.0.dist-info/METADATA,sha256=AsHYfCVDmpadD_vFpA6S5W4wOLdT1dw9_U3WP3hzWkw,2699
5
- wmill-1.215.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
6
- wmill-1.215.0.dist-info/RECORD,,