Repository navigation
feat(odin): Make Actions support opt-out per scheduled/continuous task - #586
Conversation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces an 'actionable' flag to tasks, allowing them to opt out of auto-generated Start/Stop actions. It includes a new helper function '_is_actionable' to centralize this logic and updates various task management methods to use this helper. The review comment correctly identifies a compatibility issue: 'TypeGuard' should be imported from 'typing_extensions' rather than 'typing' to support Python versions earlier than 3.10.
There was a problem hiding this comment.
Code Review
This pull request introduces an actionable flag to tasks (defaulting to True for ScheduledTask and ContinuousTask), allowing individual tasks to opt out of auto-generated Start/Stop actions. It adds a helper function _is_actionable using TypeGuard to check if a task is actionable, and updates registration and dispatch logic accordingly. Tests are also added to verify this behavior. Feedback is provided regarding the import of TypeGuard from typing, which will cause a runtime error on Python 3.9; it should be imported from typing_extensions instead to maintain backward compatibility.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #586 +/- ##
==========================================
+ Coverage 84.09% 84.20% +0.10%
==========================================
Files 46 46
Lines 4710 4711 +1
==========================================
+ Hits 3961 3967 +6
+ Misses 749 744 -5
🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces an actionable flag for scheduled and continuous tasks, allowing individual tasks to opt out of auto-generated Start/Stop actions. It refactors the codebase to use a new _is_actionable helper function and adds corresponding unit tests. Feedback on the changes suggests importing TypeGuard from typing_extensions instead of typing to prevent runtime ImportError crashes on Python versions prior to 3.10.
HMEiding
left a comment
There was a problem hiding this comment.
The description says "the 48 errors are integration tests that need CDF credentials set". I don't see CI failing, but if tests are disabled due credentials missing, it should be fixed.
Nothing is disabled, those errors were only from my local run without CDF credentials. CI sets them from repo secrets in test_and_build.yml and runs the full tests suite (no skip markers), and it's green. Fixed the wording in the description. |
| tokens.pop(key, None) | ||
|
|
||
| def _run_task_with_token( | ||
| self, task: ScheduledTask | ContinuousTask, child_token: CancellationToken | None = None |
There was a problem hiding this comment.
I see dropping the guard meant widening task: ScheduledTask | ContinuousTask to task: Task which now also admits StartupTask. Just noting there is a tradeoff here. Are you fine with the widening?
Separately, the docstring says "for an actionable task run", but opted-out scheduled tasks also run through here, so perhaps update the text?
There was a problem hiding this comment.
Good catch. These are remnants of the local testing I had done. Reverted the widening and also updated the docstring to cover opted-out tasks.
HMEiding
left a comment
There was a problem hiding this comment.
Noticed a test gap, but otherwise LGTM.
| assert by_name["Start cont"].type == ActionType.custom | ||
| assert "Stop cont" not in by_name | ||
|
|
||
|
|
There was a problem hiding this comment.
I noticed a test gap: There is no test asserting that a dispatched action on a non-actionable task fails.
There was a problem hiding this comment.
Added test_dispatch_action_on_opted_out_task_reports_failed in test_action_dispatch.py. It covers Start/Stop on both an opted-out scheduled task and an opted-out continuous task, and asserts a single failed update, that the target never ran, and that no running-task token was registered.
Summary
Scheduled and continuous tasks support Start/Stop Actions by default, and a task can opt out with
actionable=False.Type of change
What changed
tasks.py: addedactionable: bool = TruetoScheduledTask(includingfrom_intervalandfrom_cron) andContinuousTask.StartupTaskstays non-actionable.base.py: added_is_actionable()(aTypeGuard), which replaces everyisinstance(t, ACTIONABLE_TASK_TYPES)check. An opted-out task gets no Start/Stop actions, is sent withaction=False, and leaves itsStart/Stop <name>names free for custom actions.Why it changed
What to focus on during review
ACTIONABLE_TASK_TYPESgate now goes through_is_actionable.Test evidence
test_action_registration.py, covering the defaults, opt-out registration, and that an opted-out task doesn't reserve the action names.ruffandmypypass. The unit tests pass; Locally integration tests were not tested as repo secrets in test_and_build.yml are unknown but integration tests pass in CI.Risks and unknowns
Rollout and rollback
Checklist