Skip to content

feat(activity): add default activity options to make it easier to use#76

Open
shijiesheng wants to merge 2 commits intocadence-workflow:mainfrom
shijiesheng:activity_default
Open

feat(activity): add default activity options to make it easier to use#76
shijiesheng wants to merge 2 commits intocadence-workflow:mainfrom
shijiesheng:activity_default

Conversation

@shijiesheng
Copy link
Member

What changed?

Set default activity options when execute_activity

Why?

Otherwise, each activity needs to set the options and it's a toil for onboarding.

How did you test it?

Unit Test

Potential risks

Release notes

Documentation Changes

Signed-off-by: Shijie Sheng <liouvetren@gmail.com>
Signed-off-by: Shijie Sheng <liouvetren@gmail.com>
@gitar-bot
Copy link

gitar-bot bot commented Mar 23, 2026

Code Review ✅ Approved 1 resolved / 1 findings

Adds default activity options to simplify the API usage with sensible built-in configuration values. No issues found.

✅ 1 resolved
Bug: Validation block is now dead code due to defaults

📄 cadence/_internal/workflow/context.py:13-16 📄 cadence/_internal/workflow/context.py:43-50 📄 cadence/_internal/workflow/context.py:43-49
The default_activity_options always includes schedule_to_close_timeout, so after merging on line 43, opts will always contain that key. The validation on lines 44-49 (if "schedule_to_close_timeout" not in opts) can never be True, making the entire raise ValueError(...) block unreachable.

This means users can no longer get a helpful error if they accidentally misconfigure timeouts (e.g., passing only start_to_close_timeout without schedule_to_start_timeout while intending to omit schedule_to_close_timeout). The default 10-minute schedule_to_close_timeout would silently apply instead.

Either remove the dead validation block (if defaults are the desired behavior) or restructure the logic to only apply defaults when the user hasn't provided any timeout options at all.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

from cadence.workflow import WorkflowContext, WorkflowInfo, ResultType, ActivityOptions

default_activity_options = ActivityOptions(
schedule_to_close_timeout=timedelta(minutes=10),
Copy link
Member

Choose a reason for hiding this comment

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

what's the rationale behind the 10 min start to close timeout?

Copy link
Member Author

Choose a reason for hiding this comment

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

10m is chosen arbitrarily. Maybe 1hr? Anything more than that should need a heartbeat setting.

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