Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip v2 experimentation #182

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
24 changes: 18 additions & 6 deletions hatchet_sdk/clients/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import grpc
from google.protobuf import timestamp_pb2
from loguru import logger

from hatchet_sdk.clients.rest.tenacity_utils import tenacity_retry
from hatchet_sdk.clients.run_event_listener import new_listener
Expand Down Expand Up @@ -339,13 +340,9 @@ def run_workflow(
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(
request,
metadata=get_metadata(self.token),
)
id = self.trigger_workflow(workflow_name, input, options)
return WorkflowRunRef(
workflow_run_id=resp.workflow_run_id,
workflow_run_id=id,
workflow_listener=self.pooled_workflow_listener,
workflow_run_event_listener=self.listener_client,
)
Expand All @@ -355,6 +352,21 @@ def run_workflow(

raise ValueError(f"gRPC error: {e}")

def trigger_workflow(
self,
workflow_name: str,
input,
options: TriggerWorkflowOptions = None,
) -> str:
request = self._prepare_workflow_request(workflow_name, input, options)

logger.trace("trigger proto: {}", request)
resp: TriggerWorkflowResponse = self.client.TriggerWorkflow(
request,
metadata=get_metadata(self.token),
)
return resp.workflow_run_id

def run(
self,
function: Union[str, Callable[[Any], T]],
Expand Down
Loading