Skip to content

feat(odin): Make Actions support opt-out per scheduled/continuous task - #586

Merged
vikramlc-cognite merged 8 commits into
masterfrom
EDG-1013-actionable-task-opt-out
Oct 28, 2026
Merged

vikramlc-cognite merged 8 commits into
masterfrom
EDG-1013-actionable-task-opt-out

Conversation

@vikramlc-cognite

@vikramlc-cognite vikramlc-cognite commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Scheduled and continuous tasks support Start/Stop Actions by default, and a task can opt out with actionable=False.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Refactor (no functional change)
  • Documentation update
  • Chore / tooling / CI

What changed

  • tasks.py: added actionable: bool = True to ScheduledTask (including from_interval and from_cron) and ContinuousTask. StartupTask stays non-actionable.
  • base.py: added _is_actionable() (a TypeGuard), which replaces every isinstance(t, ACTIONABLE_TASK_TYPES) check. An opted-out task gets no Start/Stop actions, is sent with action=False, and leaves its Start/Stop <name> names free for custom actions.

Why it changed

  • Related issue: EDG-1013
  • Actions should be on by default for every scheduled or continuous task, with a per-task way to turn them off.

What to focus on during review

  • Check that every former ACTIONABLE_TASK_TYPES gate now goes through _is_actionable.

Test evidence

  • 3 new tests in test_action_registration.py, covering the defaults, opt-out registration, and that an opted-out task doesn't reserve the action names.
  • ruff and mypy pass. 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

  • Existing extractors behave the same, because the default matches the old behavior.

Rollout and rollback

  • No migration or config change. To roll back, revert the PR.

Checklist

  • Self-reviewed the diff
  • Tests added or updated
  • Docs updated (docstrings and changelog)
  • No secrets, credentials, or PII committed
  • Breaking changes called out above (N/A)

@vikramlc-cognite
vikramlc-cognite requested a review from a team as a code owner October 22, 2026 10:33
@vikramlc-cognite vikramlc-cognite self-assigned this Oct 22, 2026
@vikramlc-cognite

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.20%. Comparing base (d3fdb50) to head (4ecfa94).
⚠️ Report is 1 commits behind head on master.

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     
Files with missing lines Coverage Δ
cognite/extractorutils/unstable/core/base.py 86.94% <100.00%> (ø)
cognite/extractorutils/unstable/core/tasks.py 100.00% <100.00%> (+2.50%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vikramlc-cognite

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@vikramlc-cognite vikramlc-cognite added the waiting-for-risk-review Waiting for a member of the risk review team to take an action label Oct 26, 2026
@HMEiding HMEiding self-assigned this Oct 27, 2026
@HMEiding HMEiding added the risk-review-ongoing Risk review is in progress label Oct 27, 2026

@HMEiding HMEiding left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@HMEiding HMEiding added waiting-for-team Waiting for the submitter or reviewer of the PR to take an action and removed waiting-for-risk-review Waiting for a member of the risk review team to take an action labels Oct 27, 2026
@vikramlc-cognite

Copy link
Copy Markdown
Contributor Author

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.

@vikramlc-cognite vikramlc-cognite added waiting-for-risk-review Waiting for a member of the risk review team to take an action and removed waiting-for-team Waiting for the submitter or reviewer of the PR to take an action labels Oct 27, 2026
tokens.pop(key, None)

def _run_task_with_token(
self, task: ScheduledTask | ContinuousTask, child_token: CancellationToken | None = None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 HMEiding added waiting-for-team Waiting for the submitter or reviewer of the PR to take an action and removed waiting-for-risk-review Waiting for a member of the risk review team to take an action labels Oct 27, 2026
@vikramlc-cognite vikramlc-cognite removed the waiting-for-team Waiting for the submitter or reviewer of the PR to take an action label Oct 27, 2026
@vikramlc-cognite vikramlc-cognite added the waiting-for-risk-review Waiting for a member of the risk review team to take an action label Oct 27, 2026

@HMEiding HMEiding left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Noticed a test gap, but otherwise LGTM.

assert by_name["Start cont"].type == ActionType.custom
assert "Stop cont" not in by_name


Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I noticed a test gap: There is no test asserting that a dispatched action on a non-actionable task fails.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@HMEiding HMEiding added waiting-for-team Waiting for the submitter or reviewer of the PR to take an action and removed waiting-for-risk-review Waiting for a member of the risk review team to take an action labels Oct 28, 2026
@vikramlc-cognite vikramlc-cognite added waiting-for-risk-review Waiting for a member of the risk review team to take an action and removed waiting-for-team Waiting for the submitter or reviewer of the PR to take an action labels Oct 28, 2026

@HMEiding HMEiding left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🦄

@HMEiding HMEiding added waiting-for-team Waiting for the submitter or reviewer of the PR to take an action and removed waiting-for-risk-review Waiting for a member of the risk review team to take an action labels Oct 28, 2026

@HMEiding HMEiding left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🦄

@vikramlc-cognite
vikramlc-cognite enabled auto-merge (squash) October 28, 2026 08:44
@vikramlc-cognite
vikramlc-cognite merged commit c253cfb into master Oct 28, 2026
7 checks passed
@vikramlc-cognite
vikramlc-cognite deleted the EDG-1013-actionable-task-opt-out branch October 28, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk-review-ongoing Risk review is in progress waiting-for-team Waiting for the submitter or reviewer of the PR to take an action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants