wmill 1.395.0__py3-none-any.whl → 1.396.1__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
@@ -346,6 +346,36 @@ class Windmill:
346
346
  def set_state(self, value: Any):
347
347
  self.set_resource(value, path=self.state_path, resource_type="state")
348
348
 
349
+ def set_progress(self, value: int, job_id: Optional[str] = None):
350
+ workspace = get_workspace()
351
+ flow_id = os.environ.get("WM_FLOW_JOB_ID")
352
+ job_id = job_id or os.environ.get("WM_JOB_ID")
353
+
354
+ if job_id != None:
355
+ job = self.get_job(job_id)
356
+ flow_id = job.get("parent_job")
357
+
358
+ self.post(
359
+ f"/w/{workspace}/job_metrics/set_progress/{job_id}",
360
+ json={
361
+ "percent": value,
362
+ "flow_job_id": flow_id or None,
363
+ },
364
+ )
365
+
366
+ def get_progress(self, job_id: Optional[str] = None ) -> Any:
367
+ workspace = get_workspace()
368
+ job_id = job_id or os.environ.get("WM_JOB_ID")
369
+
370
+ r = self.get(
371
+ f"/w/{workspace}/job_metrics/get_progress/{job_id}",
372
+ )
373
+ if r.status_code == 404:
374
+ print(f"Job {job_id} does not exist")
375
+ return None
376
+ else:
377
+ return r.json()
378
+
349
379
  def set_flow_user_state(self, key: str, value: Any) -> None:
350
380
  """Set the user state of a flow at a given key"""
351
381
  flow_id = self.get_root_job_id()
@@ -838,6 +868,20 @@ def set_state(value: Any) -> None:
838
868
  """
839
869
  return _client.set_state(value)
840
870
 
871
+ @init_global_client
872
+ def set_progress(value: int, job_id: Optional[str] = None) -> None:
873
+ """
874
+ Set the progress
875
+ """
876
+ return _client.set_progress(value, job_id)
877
+
878
+ @init_global_client
879
+ def get_progress(job_id: Optional[str] = None) -> Any:
880
+ """
881
+ Get the progress
882
+ """
883
+ return _client.get_progress(job_id)
884
+
841
885
 
842
886
  def set_shared_state_pickle(value: Any, path="state.pickle") -> None:
843
887
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wmill
3
- Version: 1.395.0
3
+ Version: 1.396.1
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
@@ -1,8 +1,8 @@
1
1
  wmill/__init__.py,sha256=nGZnQPezTdrBnBW1D0JqUtm75Gdf_xi3tAcPGwHRZ5A,46
2
- wmill/client.py,sha256=wHMpt-K1a1I-9-Hhby9PDL-XmkyGu4qoX2g_WM5s8NY,33045
2
+ wmill/client.py,sha256=PCt3IXmAEkOldz08LtkDw1S4r5GHfEtZDibKMAZp9XM,34327
3
3
  wmill/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
4
4
  wmill/s3_reader.py,sha256=izHlg2Xsg0Sr_LkDDEC35VuEijJcuPBDIm-xj21KsgU,1668
5
5
  wmill/s3_types.py,sha256=XVjPyc5sjWesTy6nnRReojhyPgPsaT0EY3X57mWUaJ4,1173
6
- wmill-1.395.0.dist-info/METADATA,sha256=uS6KxwYUKB4JgoIvx3WAHdP4i9O-mtoX7gp5SL9hd5w,2693
7
- wmill-1.395.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
8
- wmill-1.395.0.dist-info/RECORD,,
6
+ wmill-1.396.1.dist-info/METADATA,sha256=HqoJ1Vz8Ppkmp3SuQxU_R92LVCU1Gg_mSg9H6Mj68vc,2693
7
+ wmill-1.396.1.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
8
+ wmill-1.396.1.dist-info/RECORD,,