Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
ef37b31
feat: client config overhaul
mrkaye97 Jan 13, 2025
179b178
fix: tracing headers
mrkaye97 Jan 13, 2025
9823721
fix: refs to loader
mrkaye97 Jan 13, 2025
8983536
fix: lint
mrkaye97 Jan 13, 2025
baa8567
debug: host port and server validation
mrkaye97 Jan 13, 2025
618671a
fix: raise errors if no token set
mrkaye97 Jan 13, 2025
ed35943
fix: namespace prefixing
mrkaye97 Jan 13, 2025
a66bcac
cleanup: pydantic for parsing claims
mrkaye97 Jan 13, 2025
eada022
feat: add token to mypy
mrkaye97 Jan 13, 2025
085da4a
fix: pythonic dict construction for otel headers
mrkaye97 Jan 13, 2025
b30b40f
cruft: any
mrkaye97 Jan 14, 2025
e7740ef
feat: allow host_port overrides
mrkaye97 Jan 14, 2025
a6d6a45
feat: tests
mrkaye97 Jan 14, 2025
e0e52b9
feat: rm typed dicts in a bunch of places in favor of pydantic
mrkaye97 Jan 14, 2025
4cdc750
feat: couple more bits of cleanup using `Field`
mrkaye97 Jan 14, 2025
57b8751
fix: clean up a bunch of type issues in the admin client
mrkaye97 Jan 14, 2025
6c46ea3
feat: fix a bunch more type issues w/ pydantic
mrkaye97 Jan 14, 2025
ec33c9b
fix: simple event trigger
mrkaye97 Jan 14, 2025
d9ba2c8
fix: lint
mrkaye97 Jan 14, 2025
056f247
Merge pull request #1 from hatchet-dev/feat--overhaul-config
mrkaye97 Jan 18, 2025
0a208d2
Merge branch 'hatchet-dev:main' into main
mrkaye97 Jan 22, 2025
881320f
Merge branch 'main' into feat--typed-dicts
mrkaye97 Jan 22, 2025
9000d51
fix: lint
mrkaye97 Jan 22, 2025
292fd4d
more helpful type hint
mrkaye97 Jan 22, 2025
b664ce5
Merge pull request #2 from hatchet-dev/feat--typed-dicts
mrkaye97 Jan 22, 2025
6648800
feat: type checking everywhere + remove v2
mrkaye97 Jan 22, 2025
db9af5a
feat: rm more v2 stuff
mrkaye97 Jan 22, 2025
c79c79b
fix: lots of type hints
mrkaye97 Jan 22, 2025
b1dee95
fix: whole bunch more
mrkaye97 Jan 22, 2025
4bd64be
fix: more, down to 60ish
mrkaye97 Jan 22, 2025
b07ead8
fix: down to 30ish
mrkaye97 Jan 22, 2025
79a80f0
fix: t-10
mrkaye97 Jan 22, 2025
64a2549
fix: 9
mrkaye97 Jan 22, 2025
9df38c4
fix: 8
mrkaye97 Jan 22, 2025
eb2dd35
fix: 7
mrkaye97 Jan 22, 2025
9ba0c58
fix: 6
mrkaye97 Jan 22, 2025
ed190ff
fix: 5
mrkaye97 Jan 22, 2025
e81e3dd
fix: 4
mrkaye97 Jan 22, 2025
918e6fb
fix: 3
mrkaye97 Jan 22, 2025
8116949
fix: 2
mrkaye97 Jan 22, 2025
9535dd1
fix: 1
mrkaye97 Jan 22, 2025
e5bf592
fix: 0
mrkaye97 Jan 22, 2025
4e40fdb
Merge pull request #3 from hatchet-dev/feat--more-typing-and-remove-v2
mrkaye97 Jan 23, 2025
e04a237
fix: queue types
mrkaye97 Jan 23, 2025
5145119
feat: finally fix mypy config
mrkaye97 Jan 28, 2025
62948af
fix: rest of the mypy errors
mrkaye97 Jan 28, 2025
5dcc298
fix: finally, it all works
mrkaye97 Jan 28, 2025
ab40bdd
fix: clean up mypy config
mrkaye97 Jan 28, 2025
49693cd
fix: rm a couple type: ignore comments
mrkaye97 Jan 28, 2025
0973017
fix: remove some Any types
mrkaye97 Jan 29, 2025
9ced997
fix: remove a few more Any types
mrkaye97 Jan 30, 2025
e8722ca
fix: couple more types
mrkaye97 Jan 30, 2025
f3cd051
Merge pull request #4 from hatchet-dev/feat-finally-fix-mypy
mrkaye97 Jan 30, 2025
bde190a
chore: copy
mrkaye97 Jan 30, 2025
45e21d3
feat: initial workflow impl
mrkaye97 Jan 30, 2025
50e7bf1
feat: step class
mrkaye97 Jan 30, 2025
908d446
fix: type errors
mrkaye97 Jan 30, 2025
dc3019f
feat: move files around + finish typing
mrkaye97 Jan 30, 2025
7807ae1
feat: first working version!
mrkaye97 Jan 30, 2025
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
7 changes: 5 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import logging
import os
import subprocess
import time
from io import BytesIO
from threading import Thread
from typing import AsyncGenerator, Callable, cast
from typing import AsyncGenerator, Callable, Generator, cast

import psutil
import pytest
Expand All @@ -23,7 +24,9 @@ def hatchet() -> Hatchet:


@pytest.fixture()
def worker(request: pytest.FixtureRequest):
def worker(
request: pytest.FixtureRequest,
) -> Generator[subprocess.Popen[bytes], None, None]:
example = cast(str, request.param)

command = ["poetry", "run", example]
Expand Down
Empty file added examples/__init__.py
Empty file.
1 change: 0 additions & 1 deletion examples/_deprecated/README.md

This file was deleted.

15 changes: 0 additions & 15 deletions examples/_deprecated/concurrency_limit_rr/event.py

This file was deleted.

This file was deleted.

38 changes: 0 additions & 38 deletions examples/_deprecated/concurrency_limit_rr/worker.py

This file was deleted.

26 changes: 0 additions & 26 deletions examples/_deprecated/test_event_client.py

This file was deleted.

3 changes: 2 additions & 1 deletion examples/affinity-workers/event.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from dotenv import load_dotenv

from hatchet_sdk.clients.events import PushEventOptions
from hatchet_sdk.hatchet import Hatchet

load_dotenv()
Expand All @@ -9,5 +10,5 @@
hatchet.event.push(
"affinity:run",
{"test": "test"},
options={"additional_metadata": {"hello": "moon"}},
options=PushEventOptions(additional_metadata={"hello": "moon"}),
)
13 changes: 7 additions & 6 deletions examples/affinity-workers/worker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dotenv import load_dotenv

from hatchet_sdk import Context, Hatchet, WorkerLabelComparator
from hatchet_sdk.labels import DesiredWorkerLabel

load_dotenv()

Expand All @@ -11,12 +12,12 @@
class AffinityWorkflow:
@hatchet.step(
desired_worker_labels={
"model": {"value": "fancy-ai-model-v2", "weight": 10},
"memory": {
"value": 256,
"required": True,
"comparator": WorkerLabelComparator.LESS_THAN,
},
"model": DesiredWorkerLabel(value="fancy-ai-model-v2", weight=10),
"memory": DesiredWorkerLabel(
value=256,
required=True,
comparator=WorkerLabelComparator.LESS_THAN,
),
},
)
async def step(self, context: Context) -> dict[str, str | None]:
Expand Down
5 changes: 3 additions & 2 deletions examples/blocked_async/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

client = new_client()

# client.event.push("user:create", {"test": "test"})
client.event.push(
"user:create", {"test": "test"}, options={"additional_metadata": {"hello": "moon"}}
"user:create",
{"test": "test"},
options=PushEventOptions(additional_metadata={"hello": "moon"}),
)
31 changes: 14 additions & 17 deletions examples/bulk_fanout/bulk_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dotenv import load_dotenv

from hatchet_sdk import new_client
from hatchet_sdk.clients.admin import TriggerWorkflowOptions
from hatchet_sdk.clients.admin import TriggerWorkflowOptions, WorkflowRunDict
from hatchet_sdk.clients.rest.models.workflow_run import WorkflowRun
from hatchet_sdk.clients.run_event_listener import StepRunEventType

Expand All @@ -16,25 +16,22 @@ async def main() -> None:
load_dotenv()
hatchet = new_client()

workflowRuns: list[dict[str, Any]] = []

# we are going to run the BulkParent workflow 20 which will trigger the Child workflows n times for each n in range(20)
for i in range(20):
workflowRuns.append(
{
"workflow_name": "BulkParent",
"input": {"n": i},
"options": {
"additional_metadata": {
"bulk-trigger": i,
"hello-{i}": "earth-{i}",
},
},
}
workflow_runs = [
WorkflowRunDict(
workflow_name="BulkParent",
input={"n": i},
options=TriggerWorkflowOptions(
additional_metadata={
"bulk-trigger": i,
"hello-{i}": "earth-{i}",
}
),
)
for i in range(20)
]

workflowRunRefs = hatchet.admin.run_workflows(
workflowRuns,
workflow_runs,
)

results = await asyncio.gather(
Expand Down
5 changes: 2 additions & 3 deletions examples/bulk_fanout/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

from dotenv import load_dotenv

from hatchet_sdk import new_client
from hatchet_sdk import Hatchet, new_client
from hatchet_sdk.clients.admin import TriggerWorkflowOptions
from hatchet_sdk.clients.run_event_listener import StepRunEventType
from hatchet_sdk.v2.hatchet import Hatchet


async def main() -> None:
Expand All @@ -31,7 +30,7 @@ async def main() -> None:
workflowRun = hatchet.admin.run_workflow(
"Parent",
{"n": 2},
options={"additional_metadata": {streamKey: streamVal}},
options=TriggerWorkflowOptions(additional_metadata={streamKey: streamVal}),
)

# Stream all events for the additional meta key value
Expand Down
9 changes: 5 additions & 4 deletions examples/bulk_fanout/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from hatchet_sdk import new_client
from hatchet_sdk.clients.admin import TriggerWorkflowOptions
from hatchet_sdk.clients.events import PushEventOptions
from hatchet_sdk.clients.rest.models.workflow_run import WorkflowRun
from hatchet_sdk.clients.run_event_listener import StepRunEventType

Expand All @@ -15,10 +16,10 @@ async def main() -> None:
load_dotenv()
hatchet = new_client()

workflowRuns: WorkflowRun = [] # type: ignore[assignment]

event = hatchet.event.push(
"parent:create", {"n": 999}, {"additional_metadata": {"no-dedupe": "world"}}
hatchet.event.push(
"parent:create",
{"n": 999},
PushEventOptions(additional_metadata={"no-dedupe": "world"}),
)


Expand Down
23 changes: 11 additions & 12 deletions examples/bulk_fanout/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dotenv import load_dotenv

from hatchet_sdk import Context, Hatchet
from hatchet_sdk.clients.admin import ChildWorkflowRunDict
from hatchet_sdk.clients.admin import ChildTriggerWorkflowOptions, ChildWorkflowRunDict

load_dotenv()

Expand All @@ -22,18 +22,17 @@ async def spawn(self, context: Context) -> dict[str, list[Any]]:

n = context.workflow_input().get("n", 100)

child_workflow_runs: list[ChildWorkflowRunDict] = []

for i in range(n):

child_workflow_runs.append(
{
"workflow_name": "BulkChild",
"input": {"a": str(i)},
"key": f"child{i}",
"options": {"additional_metadata": {"hello": "earth"}},
}
child_workflow_runs = [
ChildWorkflowRunDict(
workflow_name="BulkChild",
input={"a": str(i)},
key=f"child{i}",
options=ChildTriggerWorkflowOptions(
additional_metadata={"hello": "earth"}
),
)
for i in range(n)
]

if len(child_workflow_runs) == 0:
return {}
Expand Down
6 changes: 4 additions & 2 deletions examples/dedupe/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from dotenv import load_dotenv

from hatchet_sdk import Context, Hatchet
from hatchet_sdk import ChildTriggerWorkflowOptions, Context, Hatchet
from hatchet_sdk.clients.admin import DedupeViolationErr
from hatchet_sdk.loader import ClientConfig

Expand All @@ -29,7 +29,9 @@ async def spawn(self, context: Context) -> dict[str, list[Any]]:
"DedupeChild",
{"a": str(i)},
key=f"child{i}",
options={"additional_metadata": {"dedupe": "test"}},
options=ChildTriggerWorkflowOptions(
additional_metadata={"dedupe": "test"}
),
)
).result()
)
Expand Down
Loading