wmill 1.395.0__tar.gz → 1.396.1__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {wmill-1.395.0 → wmill-1.396.1}/PKG-INFO +1 -1
- {wmill-1.395.0 → wmill-1.396.1}/pyproject.toml +1 -1
- {wmill-1.395.0 → wmill-1.396.1}/wmill/client.py +44 -0
- {wmill-1.395.0 → wmill-1.396.1}/README.md +0 -0
- {wmill-1.395.0 → wmill-1.396.1}/wmill/__init__.py +0 -0
- {wmill-1.395.0 → wmill-1.396.1}/wmill/py.typed +0 -0
- {wmill-1.395.0 → wmill-1.396.1}/wmill/s3_reader.py +0 -0
- {wmill-1.395.0 → wmill-1.396.1}/wmill/s3_types.py +0 -0
@@ -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
|