Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "hatchet"]
path = hatchet
url = [email protected]:hatchet-dev/hatchet.git
branch = main
branch = feat--scheduled-improvements
9 changes: 0 additions & 9 deletions examples/delayed/event.py

This file was deleted.

29 changes: 29 additions & 0 deletions examples/delayed/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from datetime import datetime, timedelta
from time import sleep

from dotenv import load_dotenv

from hatchet_sdk import Hatchet

load_dotenv()

hatchet = Hatchet()

scheduled_run = hatchet.admin.schedule_workflow(
"PrintPrinter",
[datetime.now() + timedelta(seconds=15)],
{"message": "test"},
options={"additional_metadata": {"triggeredBy": "script"}},
)

print(
"Scheduled run at: "
+ scheduled_run.trigger_at.ToDatetime().strftime("%Y-%m-%d %H:%M:%S")
+ "UTC"
)

sleep(5)

hatchet.rest.scheduled_run_delete(scheduled_run.id)

print("Scheduled run deleted")
1 change: 0 additions & 1 deletion hatchet
Submodule hatchet deleted from 7ece86
13 changes: 11 additions & 2 deletions hatchet_sdk/clients/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
PutRateLimitRequest,
PutWorkflowRequest,
RateLimitDuration,
ScheduledWorkflow,
ScheduleWorkflowRequest,
TriggerWorkflowRequest,
TriggerWorkflowResponse,
Expand All @@ -39,6 +40,7 @@ class ScheduleTriggerWorkflowOptions(TypedDict):
parent_step_run_id: Optional[str]
child_index: Optional[int]
child_key: Optional[str]
additional_metadata: Dict[str, str] | None = None
namespace: Optional[str]


Expand Down Expand Up @@ -145,6 +147,11 @@ def _prepare_schedule_workflow_request(
"Invalid schedule type. Must be datetime or timestamp_pb2.Timestamp."
)

if options is not None and "additional_metadata" in options:
options["additional_metadata"] = json.dumps(
options["additional_metadata"]
).encode("utf-8")

return ScheduleWorkflowRequest(
name=name,
schedules=timestamp_schedules,
Expand Down Expand Up @@ -406,7 +413,7 @@ def schedule_workflow(
schedules: List[Union[datetime, timestamp_pb2.Timestamp]],
input={},
options: ScheduleTriggerWorkflowOptions = None,
) -> WorkflowVersion:
) -> ScheduledWorkflow:
try:

namespace = self.namespace
Expand All @@ -426,10 +433,12 @@ def schedule_workflow(
name, schedules, input, options
)

return self.client.ScheduleWorkflow(
res: WorkflowVersion = self.client.ScheduleWorkflow(
request,
metadata=get_metadata(self.token),
)

return res.scheduled_workflows[0]
except grpc.RpcError as e:
if e.code() == grpc.StatusCode.ALREADY_EXISTS:
raise DedupeViolationErr(e.details())
Expand Down
13 changes: 13 additions & 0 deletions hatchet_sdk/clients/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
CreateTenantInviteRequest,
)
from hatchet_sdk.clients.rest.models.create_tenant_request import CreateTenantRequest
from hatchet_sdk.clients.rest.models.cron_workflows import CronWorkflows
from hatchet_sdk.clients.rest.models.cron_workflows_list import CronWorkflowsList
from hatchet_sdk.clients.rest.models.cron_workflows_order_by_field import (
CronWorkflowsOrderByField,
)
from hatchet_sdk.clients.rest.models.event import Event
from hatchet_sdk.clients.rest.models.event_data import EventData
from hatchet_sdk.clients.rest.models.event_key_list import EventKeyList
Expand Down Expand Up @@ -141,6 +146,14 @@
ReplayWorkflowRunsResponse,
)
from hatchet_sdk.clients.rest.models.rerun_step_run_request import RerunStepRunRequest
from hatchet_sdk.clients.rest.models.scheduled_run_status import ScheduledRunStatus
from hatchet_sdk.clients.rest.models.scheduled_workflows import ScheduledWorkflows
from hatchet_sdk.clients.rest.models.scheduled_workflows_list import (
ScheduledWorkflowsList,
)
from hatchet_sdk.clients.rest.models.scheduled_workflows_order_by_field import (
ScheduledWorkflowsOrderByField,
)
from hatchet_sdk.clients.rest.models.semaphore_slots import SemaphoreSlots
from hatchet_sdk.clients.rest.models.slack_webhook import SlackWebhook
from hatchet_sdk.clients.rest.models.sns_integration import SNSIntegration
Expand Down
33 changes: 12 additions & 21 deletions hatchet_sdk/clients/rest/api/api_token_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,7 @@ def _api_token_create_serialize(
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
] = {}
_files: Dict[str, Union[str, bytes]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
Expand All @@ -298,10 +296,9 @@ def _api_token_create_serialize(
_body_params = create_api_token_request

# set the HTTP header `Accept`
if "Accept" not in _header_params:
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)

# set the HTTP header `Content-Type`
if _content_type:
Expand Down Expand Up @@ -557,9 +554,7 @@ def _api_token_list_serialize(
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
] = {}
_files: Dict[str, Union[str, bytes]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
Expand All @@ -571,10 +566,9 @@ def _api_token_list_serialize(
# process the body parameter

# set the HTTP header `Accept`
if "Accept" not in _header_params:
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)

# authentication setting
_auth_settings: List[str] = ["cookieAuth", "bearerAuth"]
Expand Down Expand Up @@ -820,9 +814,7 @@ def _api_token_update_revoke_serialize(
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
] = {}
_files: Dict[str, Union[str, bytes]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
Expand All @@ -834,10 +826,9 @@ def _api_token_update_revoke_serialize(
# process the body parameter

# set the HTTP header `Accept`
if "Accept" not in _header_params:
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)

# authentication setting
_auth_settings: List[str] = ["cookieAuth", "bearerAuth"]
Expand Down
66 changes: 24 additions & 42 deletions hatchet_sdk/clients/rest/api/default_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,7 @@ def _tenant_invite_delete_serialize(
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
] = {}
_files: Dict[str, Union[str, bytes]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
Expand All @@ -324,10 +322,9 @@ def _tenant_invite_delete_serialize(
# process the body parameter

# set the HTTP header `Accept`
if "Accept" not in _header_params:
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)

# authentication setting
_auth_settings: List[str] = ["cookieAuth", "bearerAuth"]
Expand Down Expand Up @@ -626,9 +623,7 @@ def _tenant_invite_update_serialize(
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
] = {}
_files: Dict[str, Union[str, bytes]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
Expand All @@ -644,10 +639,9 @@ def _tenant_invite_update_serialize(
_body_params = update_tenant_invite_request

# set the HTTP header `Accept`
if "Accept" not in _header_params:
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)

# set the HTTP header `Content-Type`
if _content_type:
Expand Down Expand Up @@ -919,9 +913,7 @@ def _webhook_create_serialize(
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
] = {}
_files: Dict[str, Union[str, bytes]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
Expand All @@ -935,10 +927,9 @@ def _webhook_create_serialize(
_body_params = webhook_worker_create_request

# set the HTTP header `Accept`
if "Accept" not in _header_params:
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)

# set the HTTP header `Content-Type`
if _content_type:
Expand Down Expand Up @@ -1197,9 +1188,7 @@ def _webhook_delete_serialize(
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
] = {}
_files: Dict[str, Union[str, bytes]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
Expand All @@ -1211,10 +1200,9 @@ def _webhook_delete_serialize(
# process the body parameter

# set the HTTP header `Accept`
if "Accept" not in _header_params:
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)

# authentication setting
_auth_settings: List[str] = ["cookieAuth", "bearerAuth"]
Expand Down Expand Up @@ -1463,9 +1451,7 @@ def _webhook_list_serialize(
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
] = {}
_files: Dict[str, Union[str, bytes]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
Expand All @@ -1477,10 +1463,9 @@ def _webhook_list_serialize(
# process the body parameter

# set the HTTP header `Accept`
if "Accept" not in _header_params:
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)

# authentication setting
_auth_settings: List[str] = ["cookieAuth", "bearerAuth"]
Expand Down Expand Up @@ -1729,9 +1714,7 @@ def _webhook_requests_list_serialize(
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
] = {}
_files: Dict[str, Union[str, bytes]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
Expand All @@ -1743,10 +1726,9 @@ def _webhook_requests_list_serialize(
# process the body parameter

# set the HTTP header `Accept`
if "Accept" not in _header_params:
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
)

# authentication setting
_auth_settings: List[str] = ["cookieAuth", "bearerAuth"]
Expand Down
Loading
Loading