feat: add cancel_job to windmill python client (#6995)

This commit is contained in:
Alexander Petric
2025-10-29 17:00:58 -04:00
committed by GitHub
parent cc8b6b6b0f
commit 612c09e679
+35
View File
@@ -337,6 +337,27 @@ class Windmill:
time.sleep(0.5)
def cancel_job(self, job_id: str, reason: str = None) -> str:
"""Cancel a specific job by ID.
Args:
job_id: UUID of the job to cancel
reason: Optional reason for cancellation
Returns:
Response message from the cancel endpoint
"""
logger.info(f"cancelling job: {job_id}")
payload = {"reason": reason or "cancelled via cancel_job method"}
response = self.post(
f"/w/{self.workspace}/jobs_u/queue/cancel/{job_id}",
json=payload,
)
return response.text
def cancel_running(self) -> dict:
"""Cancel currently running executions of the same script."""
logger.info("canceling running executions of this script")
@@ -1363,6 +1384,20 @@ def send_teams_message(
return _client.send_teams_message(conversation_id, text, success, card_block)
@init_global_client
def cancel_job(job_id: str, reason: str = None) -> str:
"""Cancel a specific job by ID.
Args:
job_id: UUID of the job to cancel
reason: Optional reason for cancellation
Returns:
Response message from the cancel endpoint
"""
return _client.cancel_job(job_id, reason)
@init_global_client
def cancel_running() -> dict:
"""Cancel currently running executions of the same script."""