Skip to content

Commit

Permalink
Merge branch 'main' into feat--dynamic-crons
Browse files Browse the repository at this point in the history
  • Loading branch information
grutt committed Nov 25, 2024
2 parents 0d81f15 + 2ba4b77 commit d8928c4
Show file tree
Hide file tree
Showing 31 changed files with 362 additions and 139 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on: [pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -36,4 +35,4 @@ jobs:
HATCHET_CLIENT_TOKEN: ${{ secrets.HATCHET_CLIENT_TOKEN }}
run: |
echo "Using HATCHET_CLIENT_NAMESPACE: $HATCHET_CLIENT_NAMESPACE"
poetry run pytest
poetry run pytest -s -vvv --maxfail=5 --timeout=120 --capture=no
40 changes: 34 additions & 6 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
name: lint all
on: pull_request
name: Lint

on:
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]
name: lint
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install linting tools
run: poetry install --no-root --only lint

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

- name: Run Isort
run: poetry run isort . --check-only --diff

- name: Run MyPy
run: poetry run mypy --config-file=pyproject.toml
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ repos:
exclude: _pb2(_grpc)?\.py
types:
- python
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
args: [--config-file=pyproject.toml]
16 changes: 16 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from typing import AsyncGenerator

import pytest
import pytest_asyncio

from hatchet_sdk import Hatchet


@pytest_asyncio.fixture(scope="session")
async def aiohatchet() -> AsyncGenerator[Hatchet, None]:
yield Hatchet(debug=True)


@pytest.fixture(scope="session")
def hatchet() -> Hatchet:
return Hatchet(debug=True)
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,22 @@
from hatchet_sdk import Hatchet
from hatchet_sdk.workflow_run import WorkflowRunRef
from tests.utils import fixture_bg_worker
from tests.utils.hatchet_client import hatchet_client_fixture

hatchet = hatchet_client_fixture()
worker = fixture_bg_worker(["poetry", "run", "concurrency_limit_rr"])


# requires scope module or higher for shared event loop
# @pytest.mark.skip(reason="The timing for this test is not reliable")
@pytest.mark.skip(reason="The timing for this test is not reliable")
@pytest.mark.asyncio(scope="session")
async def test_run(hatchet: Hatchet):
async def test_run(aiohatchet: Hatchet):
num_groups = 2
runs: list[WorkflowRunRef] = []

# Start all runs
for i in range(1, num_groups + 1):
run = hatchet.admin.run_workflow("ConcurrencyDemoWorkflowRR", {"group": i})
run = aiohatchet.admin.run_workflow("ConcurrencyDemoWorkflowRR", {"group": i})
runs.append(run)
run = hatchet.admin.run_workflow("ConcurrencyDemoWorkflowRR", {"group": i})
run = aiohatchet.admin.run_workflow("ConcurrencyDemoWorkflowRR", {"group": i})
runs.append(run)

# Wait for all results
Expand Down
7 changes: 2 additions & 5 deletions examples/api/test_api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import pytest

from hatchet_sdk import Hatchet
from tests.utils.hatchet_client import hatchet_client_fixture

hatchet = hatchet_client_fixture()


# requires scope module or higher for shared event loop
Expand All @@ -16,7 +13,7 @@ async def test_list_workflows(hatchet: Hatchet):

# requires scope module or higher for shared event loop
@pytest.mark.asyncio(scope="session")
async def test_async_list_workflows(hatchet: Hatchet):
list = await hatchet.rest.aio.workflow_list()
async def test_async_list_workflows(aiohatchet: Hatchet):
list = await aiohatchet.rest.aio.workflow_list()

assert len(list.rows) != 0
8 changes: 4 additions & 4 deletions examples/async/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

from hatchet_sdk import Hatchet
from tests.utils import fixture_bg_worker
from tests.utils.hatchet_client import hatchet_client_fixture

hatchet = hatchet_client_fixture()
worker = fixture_bg_worker(["poetry", "run", "async"])


# requires scope module or higher for shared event loop
@pytest.mark.skip(reason="Skipping this test until we can dedicate more time to debug")
@pytest.mark.asyncio(scope="session")
async def test_run(hatchet: Hatchet):
run = hatchet.admin.run_workflow("AsyncWorkflow", {})
result = await run.result()
assert result["step1"]["test"] == "test"


@pytest.mark.skip(reason="Skipping this test until we can dedicate more time to debug")
@pytest.mark.asyncio(scope="session")
async def test_run_async(hatchet: Hatchet):
run = await hatchet.admin.aio.run_workflow("AsyncWorkflow", {})
async def test_run_async(aiohatchet: Hatchet):
run = await aiohatchet.admin.aio.run_workflow("AsyncWorkflow", {})
result = await run.result()
assert result["step1"]["test"] == "test"
2 changes: 0 additions & 2 deletions examples/bulk_fanout/test_bulk_fanout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

from hatchet_sdk import Hatchet
from tests.utils import fixture_bg_worker
from tests.utils.hatchet_client import hatchet_client_fixture

hatchet = hatchet_client_fixture()
worker = fixture_bg_worker(["poetry", "run", "bulk_fanout"])


Expand Down
2 changes: 0 additions & 2 deletions examples/cancellation/test_cancellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

from hatchet_sdk import Hatchet
from tests.utils import fixture_bg_worker
from tests.utils.hatchet_client import hatchet_client_fixture

hatchet = hatchet_client_fixture()
worker = fixture_bg_worker(["poetry", "run", "cancellation"])


Expand Down
2 changes: 0 additions & 2 deletions examples/concurrency_limit/test_concurrency_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
from hatchet_sdk import Hatchet
from hatchet_sdk.workflow_run import WorkflowRunRef
from tests.utils import fixture_bg_worker
from tests.utils.hatchet_client import hatchet_client_fixture

hatchet = hatchet_client_fixture()
worker = fixture_bg_worker(["poetry", "run", "concurrency_limit"])


Expand Down
4 changes: 1 addition & 3 deletions examples/concurrency_limit_rr/test_concurrency_limit_rr.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
from hatchet_sdk import Hatchet
from hatchet_sdk.workflow_run import WorkflowRunRef
from tests.utils import fixture_bg_worker
from tests.utils.hatchet_client import hatchet_client_fixture

hatchet = hatchet_client_fixture()
worker = fixture_bg_worker(["poetry", "run", "concurrency_limit_rr"])


# requires scope module or higher for shared event loop
# @pytest.mark.skip(reason="The timing for this test is not reliable")
@pytest.mark.skip(reason="The timing for this test is not reliable")
@pytest.mark.asyncio(scope="session")
async def test_run(hatchet: Hatchet):
num_groups = 2
Expand Down
2 changes: 0 additions & 2 deletions examples/dag/test_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

from hatchet_sdk import Hatchet
from tests.utils import fixture_bg_worker
from tests.utils.hatchet_client import hatchet_client_fixture

hatchet = hatchet_client_fixture()
worker = fixture_bg_worker(["poetry", "run", "dag"])


Expand Down
2 changes: 0 additions & 2 deletions examples/delayed/test_delayed.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
# import pytest

# from tests.utils import fixture_bg_worker
# from tests.utils.hatchet_client import hatchet_client_fixture


# hatchet = hatchet_client_fixture()
# worker = fixture_bg_worker(["poetry", "run", "manual_trigger"])

# # requires scope module or higher for shared event loop
Expand Down
11 changes: 4 additions & 7 deletions examples/events/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

from hatchet_sdk.clients.events import BulkPushEventOptions, BulkPushEventWithMetadata
from hatchet_sdk.hatchet import Hatchet
from tests.utils import hatchet_client_fixture

hatchet = hatchet_client_fixture()


# requires scope module or higher for shared event loop
Expand All @@ -18,14 +15,14 @@ async def test_event_push(hatchet: Hatchet):


@pytest.mark.asyncio(scope="session")
async def test_async_event_push(hatchet: Hatchet):
e = await hatchet.event.async_push("user:create", {"test": "test"})
async def test_async_event_push(aiohatchet: Hatchet):
e = await aiohatchet.event.async_push("user:create", {"test": "test"})

assert e.eventId is not None


@pytest.mark.asyncio(scope="session")
async def test_async_event_bulk_push(hatchet: Hatchet):
async def test_async_event_bulk_push(aiohatchet: Hatchet):

events: List[BulkPushEventWithMetadata] = [
{
Expand All @@ -46,7 +43,7 @@ async def test_async_event_bulk_push(hatchet: Hatchet):
]
opts: BulkPushEventOptions = {"namespace": "bulk-test"}

e = await hatchet.event.async_bulk_push(events, opts)
e = await aiohatchet.event.async_bulk_push(events, opts)

assert len(e) == 3

Expand Down
2 changes: 0 additions & 2 deletions examples/fanout/test_fanout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

from hatchet_sdk import Hatchet
from tests.utils import fixture_bg_worker
from tests.utils.hatchet_client import hatchet_client_fixture

hatchet = hatchet_client_fixture()
worker = fixture_bg_worker(["poetry", "run", "fanout"])


Expand Down
2 changes: 0 additions & 2 deletions examples/logger/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

from hatchet_sdk import Hatchet
from tests.utils import fixture_bg_worker
from tests.utils.hatchet_client import hatchet_client_fixture

hatchet = hatchet_client_fixture()
worker = fixture_bg_worker(["poetry", "run", "logger"])


Expand Down
3 changes: 0 additions & 3 deletions examples/manual_trigger/test_manual_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
# import pytest

# from tests.utils import fixture_bg_worker
# from tests.utils.hatchet_client import hatchet_client_fixture


# hatchet = hatchet_client_fixture()
# worker = fixture_bg_worker(["poetry", "run", "manual_trigger"])

# # requires scope module or higher for shared event loop
Expand Down
2 changes: 0 additions & 2 deletions examples/on_failure/test_on_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
from hatchet_sdk import Hatchet
from hatchet_sdk.clients.rest.models.job_run_status import JobRunStatus
from tests.utils import fixture_bg_worker
from tests.utils.hatchet_client import hatchet_client_fixture

hatchet = hatchet_client_fixture()
worker = fixture_bg_worker(["poetry", "run", "on_failure"])


Expand Down
3 changes: 0 additions & 3 deletions examples/overrides/test_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
# import pytest

# from tests.utils import fixture_bg_worker
# from tests.utils.hatchet_client import hatchet_client_fixture


# hatchet = hatchet_client_fixture()
# worker = fixture_bg_worker(["poetry", "run", "async"])

# # requires scope module or higher for shared event loop
Expand Down
3 changes: 0 additions & 3 deletions examples/programatic_replay/test_programatic_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
# import pytest

# from tests.utils import fixture_bg_worker
# from tests.utils.hatchet_client import hatchet_client_fixture


# hatchet = hatchet_client_fixture()
# worker = fixture_bg_worker(["poetry", "run", "async"])

# # requires scope module or higher for shared event loop
Expand Down
2 changes: 0 additions & 2 deletions examples/rate_limit/test_rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

from hatchet_sdk import Hatchet
from tests.utils import fixture_bg_worker
from tests.utils.hatchet_client import hatchet_client_fixture

hatchet = hatchet_client_fixture()
worker = fixture_bg_worker(["poetry", "run", "rate_limit"])


Expand Down
2 changes: 0 additions & 2 deletions examples/timeout/test_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

from hatchet_sdk import Hatchet
from tests.utils import fixture_bg_worker
from tests.utils.hatchet_client import hatchet_client_fixture

hatchet = hatchet_client_fixture()
worker = fixture_bg_worker(["poetry", "run", "timeout"])


Expand Down
2 changes: 2 additions & 0 deletions hatchet_sdk/contracts/dispatcher_pb2.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

from google.protobuf import timestamp_pb2 as _timestamp_pb2
from google.protobuf.internal import containers as _containers
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
Expand Down
2 changes: 2 additions & 0 deletions hatchet_sdk/contracts/events_pb2.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

from google.protobuf import timestamp_pb2 as _timestamp_pb2
from google.protobuf.internal import containers as _containers
from google.protobuf import descriptor as _descriptor
Expand Down
2 changes: 2 additions & 0 deletions hatchet_sdk/contracts/workflows_pb2.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

from google.protobuf import timestamp_pb2 as _timestamp_pb2
from google.protobuf.internal import containers as _containers
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
Expand Down
Loading

0 comments on commit d8928c4

Please sign in to comment.