Skip to content

Conversation

@timl3136
Copy link
Member

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 -v

Potential risks

Release notes

Documentation Changes

def workflow(
self,
func: Optional[Callable] = None,
**kwargs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: : Unpack[RegisterWorkflowOptions] to signify the typing of kwargs

def activity(
self,
func: Optional[Callable] = None,
**kwargs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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__))))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, we don't need that thanks to uv and pytest

assert func() == "test"


if __name__ == "__main__":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

def test_func():
return "decorator_with_options"

assert "custom_name" in reg._activities
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks

@timl3136 timl3136 merged commit 729e3e7 into cadence-workflow:main Aug 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants