From b2f705d01e9488eae949f892186939125ef3510e Mon Sep 17 00:00:00 2001 From: Stephan Fitzpatrick Date: Fri, 8 Dec 2023 15:22:41 -0800 Subject: [PATCH] Updated Windmill client constructor to accept workspace (#2822) This commit introduces a change in the Windmill class constructor (in wmill/client.py) to include 'workspace' as a parameter. This addition is intended to make "workspace" universally configurable either via an argument or the 'WM_WORKSPACE' environment variable. If not provided, the program will now assert a missing workspace with an informative error message. --- python-client/wmill/wmill/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python-client/wmill/wmill/client.py b/python-client/wmill/wmill/client.py index 1a883764e9..6d9045e4b7 100644 --- a/python-client/wmill/wmill/client.py +++ b/python-client/wmill/wmill/client.py @@ -21,7 +21,7 @@ JobStatus = Literal["RUNNING", "WAITING", "COMPLETED"] class Windmill: - def __init__(self, base_url=None, token=None): + def __init__(self, base_url=None, token=None, workspace=None): base = base_url or os.environ.get("BASE_INTERNAL_URL") self.base_url = f"{base}/api" @@ -31,9 +31,11 @@ class Windmill: "Authorization": f"Bearer {self.token}", } self.client = self.get_client() - self.workspace = os.environ.get("WM_WORKSPACE") + self.workspace = workspace or os.environ.get("WM_WORKSPACE") self.path = os.environ.get("WM_JOB_PATH") + assert self.workspace, f"workspace required as an argument or as WM_WORKSPACE environment variable" + def get_client(self) -> httpx.Client: return httpx.Client( base_url=self.base_url,