Implement workflow & activity registry#14
Merged
timl3136 merged 11 commits intocadence-workflow:mainfrom Aug 27, 2025
Merged
Conversation
natemort
reviewed
Aug 26, 2025
natemort
reviewed
Aug 27, 2025
cadence/worker/_registry.py
Outdated
| def workflow( | ||
| self, | ||
| func: Optional[Callable] = None, | ||
| **kwargs |
Member
There was a problem hiding this comment.
Nit: : Unpack[RegisterWorkflowOptions] to signify the typing of kwargs
cadence/worker/_registry.py
Outdated
| def activity( | ||
| self, | ||
| func: Optional[Callable] = None, | ||
| **kwargs |
Member
There was a problem hiding this comment.
Nit: : Unpack[RegisterActivityOptions] to signify the typing of kwargs.
| import os | ||
|
|
||
| # Add the project root to the path | ||
| sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) |
Member
Author
There was a problem hiding this comment.
yep, we don't need that thanks to uv and pytest
| assert func() == "test" | ||
|
|
||
|
|
||
| if __name__ == "__main__": |
| def test_func(): | ||
| return "decorator_with_options" | ||
|
|
||
| assert "custom_name" in reg._activities |
Member
There was a problem hiding this comment.
Nit: No need to rewrite all this, but in general it would be better to assert that get_activity or get_workflow would raise an Exception over checking the backing fields. That way our tests are written against the type's interface instead of its internal details.
natemort
approved these changes
Aug 27, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed?
Implement workflow & activity registry to run workflow/activity
Why?
We need the registry to register workflow/activity to server in order to run it.
How did you test it?
unit test pass:
uv run pytest tests/cadence/worker/test_registry.py -vPotential risks
Release notes
Documentation Changes