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.
This commit is contained in:
Stephan Fitzpatrick
2023-12-08 15:22:41 -08:00
committed by GitHub
parent 1fdc55c816
commit b2f705d01e
+4 -2
View File
@@ -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,