This repository was archived by the owner on Mar 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
0.47.0 #324
Merged
Merged
0.47.0 #324
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ced5c42
Fix: More OTel Cleanup (#319)
mrkaye97 3dc9da7
Fix: Bump min `celpy` version (#320)
mrkaye97 88a28ba
Feat: Sync spawn methods + fixing `sync_result` (#321)
mrkaye97 903677f
Feat: Killing sync threads (#323)
mrkaye97 47d86a5
fix: cruft
mrkaye97 dd06982
fix: async sleep
mrkaye97 b292a15
feat: flag for enabling force killing threads
mrkaye97 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import pytest | ||
|
|
||
| from hatchet_sdk import Hatchet, Worker | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("worker", ["fanout_sync"], indirect=True) | ||
| def test_run(hatchet: Hatchet, worker: Worker) -> None: | ||
| run = hatchet.admin.run_workflow("SyncFanoutParent", {"n": 2}) | ||
| result = run.sync_result() | ||
| assert len(result["spawn"]["results"]) == 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import asyncio | ||
|
|
||
| from dotenv import load_dotenv | ||
|
|
||
| from hatchet_sdk import new_client | ||
|
|
||
|
|
||
| async def main() -> None: | ||
| load_dotenv() | ||
| hatchet = new_client() | ||
|
|
||
| hatchet.admin.run_workflow( | ||
| "SyncFanoutParent", | ||
| {"test": "test"}, | ||
| options={"additional_metadata": {"hello": "moon"}}, | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| asyncio.run(main()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| from typing import Any | ||
|
|
||
| from dotenv import load_dotenv | ||
|
|
||
| from hatchet_sdk import Context, Hatchet | ||
| from hatchet_sdk.workflow_run import WorkflowRunRef | ||
|
|
||
| load_dotenv() | ||
|
|
||
| hatchet = Hatchet(debug=True) | ||
|
|
||
|
|
||
| @hatchet.workflow(on_events=["parent:create"]) | ||
| class SyncFanoutParent: | ||
| @hatchet.step(timeout="5m") | ||
| def spawn(self, context: Context) -> dict[str, Any]: | ||
| print("spawning child") | ||
|
|
||
| n = context.workflow_input().get("n", 5) | ||
|
|
||
| runs = context.spawn_workflows( | ||
| [ | ||
| { | ||
| "workflow_name": "SyncFanoutChild", | ||
| "input": {"a": str(i)}, | ||
| "key": f"child{i}", | ||
| "options": {"additional_metadata": {"hello": "earth"}}, | ||
| } | ||
| for i in range(n) | ||
| ] | ||
| ) | ||
|
|
||
| results = [r.sync_result() for r in runs] | ||
|
|
||
| print(f"results {results}") | ||
|
|
||
| return {"results": results} | ||
|
|
||
|
|
||
| @hatchet.workflow(on_events=["child:create"]) | ||
| class SyncFanoutChild: | ||
| @hatchet.step() | ||
| def process(self, context: Context) -> dict[str, str]: | ||
| return {"status": "success " + context.workflow_input()["a"]} | ||
|
|
||
|
|
||
| def main() -> None: | ||
| worker = hatchet.worker("sync-fanout-worker", max_runs=40) | ||
| worker.register_workflow(SyncFanoutParent()) | ||
| worker.register_workflow(SyncFanoutChild()) | ||
| worker.start() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made this opt-in so we can document some potential risks