From ab365f5964785fc75978c2522a26d8378f4b1f5f Mon Sep 17 00:00:00 2001 From: abelanger5 Date: Sun, 9 Jun 2024 18:46:10 -0400 Subject: [PATCH] fix: namespace propagation from spawn_workflow (#43) * fix: update requirements to indicate python version >=3.10 * fix: don't double-set namespace from spawn_workflow --- hatchet_sdk/clients/admin.py | 7 +++++-- hatchet_sdk/context.py | 3 +-- pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hatchet_sdk/clients/admin.py b/hatchet_sdk/clients/admin.py index 8c44fd41..7951a3d5 100644 --- a/hatchet_sdk/clients/admin.py +++ b/hatchet_sdk/clients/admin.py @@ -135,7 +135,9 @@ async def run_workflow( if not self.pooled_workflow_listener: self.pooled_workflow_listener = PooledWorkflowRunListener(self.config) - workflow_name = f"{self.namespace}{workflow_name}" + # if workflow_name does not start with namespace, prepend it + if self.namespace != "" and not workflow_name.startswith(self.namespace): + workflow_name = f"{self.namespace}{workflow_name}" request = self._prepare_workflow_request(workflow_name, input, options) resp: TriggerWorkflowResponse = await self.aio_client.TriggerWorkflow( @@ -276,7 +278,8 @@ def run_workflow( if not self.pooled_workflow_listener: self.pooled_workflow_listener = PooledWorkflowRunListener(self.config) - workflow_name = f"{self.namespace}{workflow_name}" + if self.namespace != "" and not workflow_name.startswith(self.namespace): + workflow_name = f"{self.namespace}{workflow_name}" request = self._prepare_workflow_request(workflow_name, input, options) resp: TriggerWorkflowResponse = self.client.TriggerWorkflow( diff --git a/hatchet_sdk/context.py b/hatchet_sdk/context.py index e0fe87df..c6f77c53 100644 --- a/hatchet_sdk/context.py +++ b/hatchet_sdk/context.py @@ -64,6 +64,7 @@ async def spawn_workflow( self, workflow_name: str, input: dict = {}, key: str = None ) -> WorkflowRunRef: options = self._prepare_workflow_options(key) + return await self.admin_client.aio.run_workflow(workflow_name, input, options) @@ -170,8 +171,6 @@ def playground(self, name: str, default: str = None): return default def spawn_workflow(self, workflow_name: str, input: dict = {}, key: str = None): - workflow_name = f"{self.namespace}{workflow_name}" - options = self._prepare_workflow_options(key) return self.admin_client.run_workflow(workflow_name, input, options) diff --git a/pyproject.toml b/pyproject.toml index 915cd331..0797808d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "hatchet-sdk" -version = "0.26.2" +version = "0.26.3" description = "" authors = ["Alexander Belanger "] readme = "README.md"