Skip to content

Tmp am/raas#93

Merged
AymenFJA merged 4 commits into
prototype/raasfrom
tmp_am/raas
Apr 3, 2026
Merged

Tmp am/raas#93
AymenFJA merged 4 commits into
prototype/raasfrom
tmp_am/raas

Conversation

@andre-merzky

Copy link
Copy Markdown
Member

notification updates.

andre-merzky and others added 3 commits March 31, 2026 00:18
radical.edge changed the notification pattern from a per-session
_notify closure to a _plugin reference with _dispatch_notify().
Update all callsites in RoseSession to match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Four new tests in TestRoseSession:
- test_submit_workflow_dispatches_submitted_notification: checks that
  submit_workflow fires workflow_state/SUBMITTED via _dispatch_notify
- test_notify_state_calls_dispatch_notify: checks _notify_state payload
- test_notify_state_no_plugin_does_not_raise: guards against AttributeError
  when _plugin is None (bare unit-test creation without a plugin)
- test_task_event_dispatched_via_plugin: verifies the _on_done callback
  in _run_workflow fires a task_event notification

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@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 refactors the notification system to use a plugin-based dispatch mechanism, replacing the previous direct callback approach. The updates span workflow submission, task event handling, and state notifications, with corresponding unit tests added to verify the new behavior. Review feedback highlights opportunities to reduce redundancy by reusing the _notify_state method and to improve consistency by using wf.to_dict() for notification payloads.

Comment thread rose/service/api/rest.py
Comment on lines +158 to 162
if self._plugin:
self._plugin._dispatch_notify(
"workflow_state",
{"wf_id": wf_id, "state": "SUBMITTED", "workflow_file": workflow_file},
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The notification logic here is redundant with the _notify_state method. Reusing self._notify_state(wf) would simplify the code, ensure consistency in the notification payload, and centralize the logic for dispatching workflow state updates.

        self._notify_state(wf)

Comment thread rose/service/api/rest.py
Comment on lines +260 to 265
if self._plugin:
self._plugin._dispatch_notify(
"workflow_state",
{"wf_id": wf.wf_id, "state": wf.state.value, "stats": wf.stats, "error": wf.error},
{"wf_id": wf.wf_id, "state": wf.state.value,
"stats": wf.stats, "error": wf.error},
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Instead of manually constructing a dictionary with a subset of fields, consider using wf.to_dict(). This ensures that the notification payload is consistent with the status API and includes useful metadata like start_time, end_time, and workflow_file. Additionally, note that _dispatch_notify is a protected method of the plugin; if the base Plugin class provides a public notification API, it should be preferred to maintain proper encapsulation.

        if self._plugin:
            self._plugin._dispatch_notify("workflow_state", wf.to_dict())

@AymenFJA

AymenFJA commented Apr 3, 2026

Copy link
Copy Markdown
Collaborator

@andre-merzky LGTM. Thanks

@AymenFJA AymenFJA merged commit 3471c00 into prototype/raas Apr 3, 2026
10 checks passed
@AymenFJA AymenFJA deleted the tmp_am/raas branch April 3, 2026 21:14
@andre-merzky andre-merzky restored the tmp_am/raas branch April 7, 2026 20:07
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