feat: pause new jobs of a workspace during a deploy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-10-23 15:41:13 +02:00
co-authored by Claude Opus 5.5
parent fb193d7a81
commit e73d2b3845
63 changed files with 2633 additions and 353 deletions
+55
View File
@@ -533,6 +533,33 @@ class Windmill:
job_id = job_id or os.environ.get("WM_JOB_ID")
return self.get(f"/w/{self.workspace}/jobs_u/get_root_job_id/{job_id}").json()
def pause_workspace_jobs(self, duration_s: int, reason: str | None = None) -> dict:
"""Pause new jobs of the workspace, e.g. while a flow runs migrations.
Jobs from triggers, schedules and async runs are held until resume_workspace_jobs or
the end of the pause; callers waiting for a result get a 503. The steps of the calling
flow, and runs started directly by an admin, keep running. Requires a workspace admin.
Args:
duration_s: How long the pause lasts at most, in seconds (at most 7 days)
reason: Shown to users of the workspace while paused
Returns:
The pause now in effect
"""
return self.post(
f"/w/{self.workspace}/workspaces/pause_jobs",
json={"duration_s": duration_s, "reason": reason, "source": "sdk"},
).json()
def resume_workspace_jobs(self) -> int:
"""Resume new jobs of the workspace and release the jobs the pause held.
Returns:
The number of held jobs released
"""
return self.post(f"/w/{self.workspace}/workspaces/resume_jobs").json()
def get_id_token(self, audience: str, expires_in: int | None = None) -> str:
"""Get an OIDC JWT token for authentication to external services.
@@ -1653,6 +1680,34 @@ def get_root_job_id(job_id: str | None = None) -> str:
return _client.get_root_job_id(job_id)
@init_global_client
def pause_workspace_jobs(duration_s: int, reason: str | None = None) -> dict:
"""Pause new jobs of the workspace, e.g. while a flow runs migrations.
Jobs from triggers, schedules and async runs are held until resume_workspace_jobs or the
end of the pause; callers waiting for a result get a 503. The steps of the calling flow,
and runs started directly by an admin, keep running. Requires a workspace admin.
Args:
duration_s: How long the pause lasts at most, in seconds (at most 7 days)
reason: Shown to users of the workspace while paused
Returns:
The pause now in effect
"""
return _client.pause_workspace_jobs(duration_s, reason)
@init_global_client
def resume_workspace_jobs() -> int:
"""Resume new jobs of the workspace and release the jobs the pause held.
Returns:
The number of held jobs released
"""
return _client.resume_workspace_jobs()
@init_global_client
@deprecate("Windmill().version")
def get_version() -> str: