Feat: Top-level stream consumer in the SDKs (#1917)

* feat: add stream sub on top level

* feat: clean up examples

* chore: gen

* feat: move stream onto the runs client in ts

* fix: examples

* chore: gen

* fix: circular import issues

* chore: lint

* feat: first pass at Next app

* fix: pull next out to top level

* fix: all the things

* fix: get it all wired up

* fix: imports

* fix: lint rule

* fix: just use js

* fix: revert tsconfig changes

* fix: check in pages

* fix: hangup event in streaming impl

* chore: gen

* chore: generate again, remove lots of nextjs stuff

* fix: one more ignore

* fix: gen

* fix: ignore

* fix: ugh

* fix: simplify a bunch

* fix: lint

* fix: rm gen cruft

* fix: changelog

* feat: implement list with pagination

* feat: add some tests

* feat: add warnings

* fix: update workflow / task methods

* chore: version

* feat: retries
This commit is contained in:
Matt Kaye
2025-07-03 18:49:16 -04:00
committed by GitHub
parent 7679732b15
commit 3442c11106
51 changed files with 614 additions and 104 deletions

View File

@@ -0,0 +1,67 @@
from datetime import datetime, timedelta, timezone
from zoneinfo import ZoneInfo
from hatchet_sdk.utils.datetimes import partition_date_range
def test_partition_date_ranges_single_day() -> None:
since = datetime(2025, 1, 1, 1, 2, 3, tzinfo=timezone.utc)
until = datetime(2025, 1, 1, 3, 14, 15, tzinfo=timezone.utc)
partitioned = partition_date_range(
since,
until,
)
assert len(partitioned) == 1
assert partitioned[0] == (since, until)
def test_partition_date_ranges_multi_day() -> None:
since = datetime(2025, 1, 1, 1, 2, 3, tzinfo=timezone.utc)
until = datetime(2025, 1, 4, 3, 14, 15, tzinfo=timezone.utc)
partitioned = partition_date_range(
since,
until,
)
assert len(partitioned) == 4
assert partitioned[0] == (
since,
datetime(2025, 1, 2, tzinfo=timezone.utc),
)
assert partitioned[1] == (
datetime(2025, 1, 2, tzinfo=timezone.utc),
datetime(2025, 1, 3, tzinfo=timezone.utc),
)
assert partitioned[2] == (
datetime(2025, 1, 3, tzinfo=timezone.utc),
datetime(2025, 1, 4, tzinfo=timezone.utc),
)
assert partitioned[3] == (
datetime(2025, 1, 4, tzinfo=timezone.utc),
until,
)
def test_partition_date_ranges_non_utc() -> None:
since = datetime(2025, 1, 1, 22, 2, 3, tzinfo=ZoneInfo("America/New_York"))
until = datetime(2025, 1, 4, 3, 14, 15, tzinfo=timezone.utc)
partitioned = partition_date_range(
since,
until,
)
assert len(partitioned) == 3
assert partitioned[0] == (
since.astimezone(timezone.utc),
datetime(2025, 1, 3, tzinfo=timezone.utc),
)
assert partitioned[1] == (
datetime(2025, 1, 3, tzinfo=timezone.utc),
datetime(2025, 1, 4, tzinfo=timezone.utc),
)
assert partitioned[2] == (
datetime(2025, 1, 4, tzinfo=timezone.utc),
until,
)