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

Commit ac41fdc

Browse files
committed
Merge branch 'main' into feat--functions
2 parents 4441eec + c73f9ba commit ac41fdc

File tree

117 files changed

+2697
-2441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+2697
-2441
lines changed

.github/workflows/e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
virtualenvs-create: true
2929
virtualenvs-in-project: true
3030
- name: Install dependencies
31-
run: poetry install --no-interaction
31+
run: poetry install --no-interaction --all-extras
3232

3333
- name: Generate Env File
3434
run: |

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
virtualenvs-in-project: true
2727

2828
- name: Install linting tools
29-
run: poetry install
29+
run: poetry install --all-extras
3030

3131
- name: Run Black
3232
run: poetry run black . --check --verbose --diff --color

conftest.py

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,58 @@
1010
import pytest
1111
import pytest_asyncio
1212

13-
from hatchet_sdk import Hatchet
13+
from hatchet_sdk import ClientConfig, Hatchet
14+
from hatchet_sdk.loader import ClientTLSConfig
15+
16+
17+
@pytest.fixture(scope="session", autouse=True)
18+
def token() -> str:
19+
result = subprocess.run(
20+
[
21+
"docker",
22+
"compose",
23+
"run",
24+
"--no-deps",
25+
"setup-config",
26+
"/hatchet/hatchet-admin",
27+
"token",
28+
"create",
29+
"--config",
30+
"/hatchet/config",
31+
"--tenant-id",
32+
"707d0855-80ab-4e1f-a156-f1c4546cbf52",
33+
],
34+
capture_output=True,
35+
text=True,
36+
)
37+
38+
token = result.stdout.strip()
39+
40+
os.environ["HATCHET_CLIENT_TOKEN"] = token
41+
42+
return token
1443

1544

1645
@pytest_asyncio.fixture(scope="session")
17-
async def aiohatchet() -> AsyncGenerator[Hatchet, None]:
18-
yield Hatchet(debug=True)
46+
async def aiohatchet(token: str) -> AsyncGenerator[Hatchet, None]:
47+
yield Hatchet(
48+
debug=True,
49+
config=ClientConfig(
50+
token=token,
51+
tls_config=ClientTLSConfig(strategy="none"),
52+
),
53+
)
1954

2055

2156
@pytest.fixture(scope="session")
22-
def hatchet() -> Hatchet:
23-
return Hatchet(debug=True)
57+
def hatchet(token: str) -> Hatchet:
58+
return Hatchet(
59+
debug=True,
60+
config=ClientConfig(
61+
token=token,
62+
tls_config=ClientTLSConfig(strategy="none"),
63+
),
64+
)
2465

2566

2667
@pytest.fixture()
@@ -32,7 +73,10 @@ def worker(
3273
command = ["poetry", "run", example]
3374

3475
logging.info(f"Starting background worker: {' '.join(command)}")
35-
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
76+
77+
proc = subprocess.Popen(
78+
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=os.environ.copy()
79+
)
3680

3781
# Check if the process is still running
3882
if proc.poll() is not None:

examples/affinity-workers/event.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
from dotenv import load_dotenv
2-
31
from hatchet_sdk.clients.events import PushEventOptions
42
from hatchet_sdk.hatchet import Hatchet
53

6-
load_dotenv()
7-
84
hatchet = Hatchet(debug=True)
95

106
hatchet.event.push(

examples/affinity-workers/worker.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
from dotenv import load_dotenv
2-
3-
from hatchet_sdk import Context, Hatchet, WorkerLabelComparator
1+
from hatchet_sdk import BaseWorkflow, Context, Hatchet, WorkerLabelComparator
42
from hatchet_sdk.labels import DesiredWorkerLabel
53

6-
load_dotenv()
7-
84
hatchet = Hatchet(debug=True)
95

6+
wf = hatchet.declare_workflow(on_events=["affinity:run"])
7+
8+
9+
class AffinityWorkflow(BaseWorkflow):
10+
config = wf.config
1011

11-
@hatchet.workflow(on_events=["affinity:run"])
12-
class AffinityWorkflow:
1312
@hatchet.step(
1413
desired_worker_labels={
1514
"model": DesiredWorkerLabel(value="fancy-ai-model-v2", weight=10),

examples/api/api.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
from dotenv import load_dotenv
2-
3-
from hatchet_sdk import Hatchet, WorkflowList
4-
5-
load_dotenv()
1+
from hatchet_sdk import Hatchet
62

73
hatchet = Hatchet(debug=True)
84

examples/api/async_api.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import asyncio
2-
from typing import cast
32

4-
from dotenv import load_dotenv
5-
6-
from hatchet_sdk import Hatchet, WorkflowList
7-
8-
load_dotenv()
3+
from hatchet_sdk import Hatchet
94

105
hatchet = Hatchet(debug=True)
116

127

138
async def main() -> None:
14-
workflow_list = await hatchet.rest.aio.workflow_list()
9+
workflow_list = await hatchet.rest.aio_list_workflows()
1510
rows = workflow_list.rows or []
1611

1712
for workflow in rows:

examples/api/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ async def test_list_workflows(hatchet: Hatchet, worker: Worker) -> None:
1717
@pytest.mark.parametrize("worker", ["concurrency_limit_rr"], indirect=True)
1818
@pytest.mark.asyncio(scope="session")
1919
async def test_async_list_workflows(aiohatchet: Hatchet, worker: Worker) -> None:
20-
workflows = await aiohatchet.rest.aio.workflow_list()
20+
workflows = await aiohatchet.rest.aio_list_workflows()
2121

2222
assert len(workflows.rows or []) != 0

examples/async/test_async.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/async/worker.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)