Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Expose Default Priority In Workflow Creation #157

Merged
merged 9 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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--expose-priority
34 changes: 34 additions & 0 deletions examples/default-priority/worker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from typing import TypedDict

from dotenv import load_dotenv

from hatchet_sdk import Context
from hatchet_sdk.v2.hatchet import Hatchet

load_dotenv()

hatchet = Hatchet(debug=True)


class MyResultType(TypedDict):
return_string: str


@hatchet.function(default_priority=1)
def high_prio_func(context: Context) -> MyResultType:
return MyResultType(return_string="High Priority Return")


@hatchet.function(default_priority=2)
def low_prio_func(context: Context) -> MyResultType:
return MyResultType(return_string="Low Priority Return")


def main():
worker = hatchet.worker("example-priority-worker", max_runs=1)

worker.start()


if __name__ == "__main__":
main()
7 changes: 7 additions & 0 deletions hatchet_sdk/clients/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@
from hatchet_sdk.clients.rest.models.webhook_worker_list_response import (
WebhookWorkerListResponse,
)
from hatchet_sdk.clients.rest.models.webhook_worker_request import WebhookWorkerRequest
from hatchet_sdk.clients.rest.models.webhook_worker_request_list_response import (
WebhookWorkerRequestListResponse,
)
from hatchet_sdk.clients.rest.models.webhook_worker_request_method import (
WebhookWorkerRequestMethod,
)
from hatchet_sdk.clients.rest.models.worker import Worker
from hatchet_sdk.clients.rest.models.worker_label import WorkerLabel
from hatchet_sdk.clients.rest.models.worker_list import WorkerList
Expand Down
267 changes: 267 additions & 0 deletions hatchet_sdk/clients/rest/api/default_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
from hatchet_sdk.clients.rest.models.webhook_worker_list_response import (
WebhookWorkerListResponse,
)
from hatchet_sdk.clients.rest.models.webhook_worker_request_list_response import (
WebhookWorkerRequestListResponse,
)
from hatchet_sdk.clients.rest.rest import RESTResponseType


Expand Down Expand Up @@ -1486,3 +1489,267 @@ def _webhook_list_serialize(
_host=_host,
_request_auth=_request_auth,
)

@validate_call
async def webhook_requests_list(
self,
webhook: Annotated[
str,
Field(
min_length=36, strict=True, max_length=36, description="The webhook id"
),
],
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[
Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
],
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> WebhookWorkerRequestListResponse:
"""List webhook requests

Lists all requests for a webhook

:param webhook: The webhook id (required)
:type webhook: str
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501

_param = self._webhook_requests_list_serialize(
webhook=webhook,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index,
)

_response_types_map: Dict[str, Optional[str]] = {
"200": "WebhookWorkerRequestListResponse",
"400": "APIErrors",
"401": "APIErrors",
"405": "APIErrors",
}
response_data = await self.api_client.call_api(
*_param, _request_timeout=_request_timeout
)
await response_data.read()
return self.api_client.response_deserialize(
response_data=response_data,
response_types_map=_response_types_map,
).data

@validate_call
async def webhook_requests_list_with_http_info(
self,
webhook: Annotated[
str,
Field(
min_length=36, strict=True, max_length=36, description="The webhook id"
),
],
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[
Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
],
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> ApiResponse[WebhookWorkerRequestListResponse]:
"""List webhook requests

Lists all requests for a webhook

:param webhook: The webhook id (required)
:type webhook: str
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501

_param = self._webhook_requests_list_serialize(
webhook=webhook,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index,
)

_response_types_map: Dict[str, Optional[str]] = {
"200": "WebhookWorkerRequestListResponse",
"400": "APIErrors",
"401": "APIErrors",
"405": "APIErrors",
}
response_data = await self.api_client.call_api(
*_param, _request_timeout=_request_timeout
)
await response_data.read()
return self.api_client.response_deserialize(
response_data=response_data,
response_types_map=_response_types_map,
)

@validate_call
async def webhook_requests_list_without_preload_content(
self,
webhook: Annotated[
str,
Field(
min_length=36, strict=True, max_length=36, description="The webhook id"
),
],
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[
Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
],
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> RESTResponseType:
"""List webhook requests

Lists all requests for a webhook

:param webhook: The webhook id (required)
:type webhook: str
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501

_param = self._webhook_requests_list_serialize(
webhook=webhook,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index,
)

_response_types_map: Dict[str, Optional[str]] = {
"200": "WebhookWorkerRequestListResponse",
"400": "APIErrors",
"401": "APIErrors",
"405": "APIErrors",
}
response_data = await self.api_client.call_api(
*_param, _request_timeout=_request_timeout
)
return response_data.response

def _webhook_requests_list_serialize(
self,
webhook,
_request_auth,
_content_type,
_headers,
_host_index,
) -> RequestSerialized:

_host = None

_collection_formats: Dict[str, str] = {}

_path_params: Dict[str, str] = {}
_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]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
if webhook is not None:
_path_params["webhook"] = webhook
# process the query parameters
# process the header parameters
# process the form parameters
# 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"]
)

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

return self.api_client.param_serialize(
method="GET",
resource_path="/api/v1/webhook-workers/{webhook}/requests",
path_params=_path_params,
query_params=_query_params,
header_params=_header_params,
body=_body_params,
post_params=_form_params,
files=_files,
auth_settings=_auth_settings,
collection_formats=_collection_formats,
_host=_host,
_request_auth=_request_auth,
)
Loading
Loading