wmill 1.394.6__tar.gz → 1.396.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wmill
3
- Version: 1.394.6
3
+ Version: 1.396.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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "wmill"
3
- version = "1.394.6"
3
+ version = "1.396.0"
4
4
  description = "A client library for accessing Windmill server wrapping the Windmill client API"
5
5
  license = "Apache-2.0"
6
6
  homepage = "https://windmill.dev"
@@ -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
  """
File without changes
File without changes
File without changes
File without changes
File without changes