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
106 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
57a8825
fix: simple example
mrkaye97 Jan 30, 2025
32dd577
feat: remove notion of action function
mrkaye97 Jan 30, 2025
8b376c3
fix: typing and on-failure
mrkaye97 Jan 30, 2025
402f377
fix: sticky strategies
mrkaye97 Jan 30, 2025
3486b27
fix: example
mrkaye97 Jan 30, 2025
a735a9c
fix: proper typing for `call` and `acall` of `Step`
mrkaye97 Jan 30, 2025
d556b81
fix: types
mrkaye97 Jan 30, 2025
ebc4f8a
fix: remove some unused stuff
mrkaye97 Jan 30, 2025
544d65b
fix: rm more unused code
mrkaye97 Jan 30, 2025
7498c63
fix: user-facing enum for concurrency
mrkaye97 Jan 30, 2025
cd701cd
fix: lint
mrkaye97 Jan 30, 2025
3176541
fix: lint
mrkaye97 Jan 30, 2025
0d5310c
fix: pass max runs and concurrency limit thru
mrkaye97 Jan 30, 2025
9da49fd
feat: workflow implementation, declaration, and config
mrkaye97 Jan 30, 2025
6d065ac
fix: cleanup
mrkaye97 Jan 30, 2025
4008257
fix: optional declaration
mrkaye97 Jan 30, 2025
842283d
feat: add example
mrkaye97 Jan 30, 2025
f0ac9f4
Merge remote-tracking branch 'upstream/main'
mrkaye97 Jan 31, 2025
4675807
feat: add pydantic settings
mrkaye97 Jan 30, 2025
c52d719
feat: pydantic settings for tls
mrkaye97 Jan 30, 2025
5fe4163
feat: more submodels
mrkaye97 Jan 30, 2025
498743f
fix: tls config tweaks
mrkaye97 Jan 31, 2025
b51bf7c
fix: factor out settings config
mrkaye97 Jan 31, 2025
0b74f0f
fix: parity
mrkaye97 Jan 31, 2025
b579ee6
fix: step needs to be registered to a workflow before it can be run
mrkaye97 Feb 5, 2025
793becd
fix: get rid of `impl`
mrkaye97 Feb 5, 2025
562bd3c
fix: inheritance
mrkaye97 Feb 5, 2025
e6843ec
fix: clean up step registration
mrkaye97 Feb 5, 2025
6e06b57
fix: clean up step instantiation
mrkaye97 Feb 5, 2025
d079700
Merge pull request #5 from hatchet-dev/feat-v2-workflows-and-steps
mrkaye97 Feb 5, 2025
95905b0
Merge remote-tracking branch 'upstream/main'
mrkaye97 Feb 5, 2025
934f6fe
Merge pull request #6 from hatchet-dev/feat-pydantic-settings
mrkaye97 Feb 5, 2025
1e925de
fix: lint
mrkaye97 Feb 6, 2025
32c2e33
feat: overwrite hatchet and workflow
mrkaye97 Feb 6, 2025
776c233
feat: fix context - clean up abstractions
mrkaye97 Feb 6, 2025
ded70b0
fix: all the examples
mrkaye97 Feb 6, 2025
a7e376b
fix: remove `load_dotenv` everywhere now that we have pydantic settings
mrkaye97 Feb 6, 2025
124d0e7
feat: spawn from context
mrkaye97 Feb 6, 2025
7f057b7
feat: get rid of lots of casts in the examples
mrkaye97 Feb 6, 2025
c7db624
fix: no pydantic needed for spawn input
mrkaye97 Feb 6, 2025
86a523b
fix: token env var
mrkaye97 Feb 6, 2025
d02d794
fix: token
mrkaye97 Feb 6, 2025
a8c6487
fix: get tests running
mrkaye97 Feb 6, 2025
51abb28
fix: host port override
mrkaye97 Feb 6, 2025
eff6138
fix: no need for "a" prefix
mrkaye97 Feb 6, 2025
5e69585
Merge pull request #8 from hatchet-dev/feat--examples
mrkaye97 Feb 6, 2025
864bd47
chore: run ruff
mrkaye97 Feb 6, 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
63 changes: 55 additions & 8 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,82 @@
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
import pytest_asyncio

from hatchet_sdk import Hatchet
from hatchet_sdk import ClientConfig, Hatchet
from hatchet_sdk.loader import ClientTLSConfig


@pytest.fixture(scope="session", autouse=True)
def token() -> str:
result = subprocess.run(
[
"docker",
"compose",
"run",
"--no-deps",
"setup-config",
"/hatchet/hatchet-admin",
"token",
"create",
"--config",
"/hatchet/config",
"--tenant-id",
"707d0855-80ab-4e1f-a156-f1c4546cbf52",
],
capture_output=True,
text=True,
)

token = result.stdout.strip()

os.environ["HATCHET_CLIENT_TOKEN"] = token

return token


@pytest_asyncio.fixture(scope="session")
async def aiohatchet() -> AsyncGenerator[Hatchet, None]:
yield Hatchet(debug=True)
async def aiohatchet(token: str) -> AsyncGenerator[Hatchet, None]:
yield Hatchet(
debug=True,
config=ClientConfig(
token=token,
tls_config=ClientTLSConfig(strategy="none"),
),
)


@pytest.fixture(scope="session")
def hatchet() -> Hatchet:
return Hatchet(debug=True)
def hatchet(token: str) -> Hatchet:
return Hatchet(
debug=True,
config=ClientConfig(
token=token,
tls_config=ClientTLSConfig(strategy="none"),
),
)


@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]

logging.info(f"Starting background worker: {' '.join(command)}")
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

proc = subprocess.Popen(
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=os.environ.copy()
)

# Check if the process is still running
if proc.poll() is not None:
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.

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

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

load_dotenv()

hatchet = Hatchet(debug=True)

hatchet.event.push(
"affinity:run",
{"test": "test"},
options={"additional_metadata": {"hello": "moon"}},
options=PushEventOptions(additional_metadata={"hello": "moon"}),
)
24 changes: 12 additions & 12 deletions examples/affinity-workers/worker.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
from dotenv import load_dotenv
from hatchet_sdk import BaseWorkflow, Context, Hatchet, WorkerLabelComparator
from hatchet_sdk.labels import DesiredWorkerLabel

from hatchet_sdk import Context, Hatchet, WorkerLabelComparator
hatchet = Hatchet(debug=True)

load_dotenv()
wf = hatchet.declare_workflow(on_events=["affinity:run"])

hatchet = Hatchet(debug=True)

class AffinityWorkflow(BaseWorkflow):
config = wf.config

@hatchet.workflow(on_events=["affinity:run"])
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
6 changes: 1 addition & 5 deletions examples/api/api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
from dotenv import load_dotenv

from hatchet_sdk import Hatchet, WorkflowList

load_dotenv()
from hatchet_sdk import Hatchet

hatchet = Hatchet(debug=True)

Expand Down
7 changes: 1 addition & 6 deletions examples/api/async_api.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import asyncio
from typing import cast

from dotenv import load_dotenv

from hatchet_sdk import Hatchet, WorkflowList

load_dotenv()
from hatchet_sdk import Hatchet

hatchet = Hatchet(debug=True)

Expand Down
8 changes: 0 additions & 8 deletions examples/async/event.py

This file was deleted.

21 changes: 0 additions & 21 deletions examples/async/test_async.py

This file was deleted.

37 changes: 0 additions & 37 deletions examples/async/worker.py

This file was deleted.

9 changes: 3 additions & 6 deletions examples/blocked_async/event.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from dotenv import load_dotenv

from hatchet_sdk import PushEventOptions, new_client

load_dotenv()

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"}),
)
Loading
Loading