Skip to content

Conversation

@SimonHeybrock
Copy link
Member

@SimonHeybrock SimonHeybrock commented Nov 13, 2025

Summary

This PR refactors the monitor interval timeseries workflow to use two-phase registration and renames it to MonitorRatemeter. It was broken recently and I only noticed now.

Key changes

  • Rename monitor interval timeseries workflow to "Monitor Ratemeter" -> not related to the fix, but matches other naming patterns better (specifically detector-ratemeters).
  • Move workflow logic from config/workflows.py to handlers/monitor_data_handler.py
  • Create register_monitor_ratemeter_spec() for phase 1 (spec registration)
  • Create create_monitor_ratemeter_factory() for phase 2 (factory attachment)
  • Auto-register spec in Instrument.__post_init__() for instruments with nexus files -> I think this will be useful for multiple instruments, patterns mirrors registration of regular monitor workflows.
  • Remove old workflow registration code and idempotency checks, not sure why they were there in the first place.

SimonHeybrock and others added 3 commits November 13, 2025 15:37
…ration

Split monitor_interval_timeseries workflow registration into the two-phase
spec+factory pattern for consistency with the rest of the codebase:

Phase 1 (Spec registration - lightweight, in Instrument.__post_init__):
- Added register_monitor_interval_timeseries_spec() to monitor_workflow_specs.py
- Defines MonitorTimeseriesParams and MonitorTimeseriesOutputs models
- Only registers when nexus file is available (required by GenericTofWorkflow)

Phase 2 (Factory attachment - heavyweight, in Instrument.load_factories):
- Added create_monitor_interval_timeseries_factory() to monitor_data_handler.py
- Contains workflow logic with ess.reduce dependencies
- Automatically attached for all instruments with nexus geometry

Key improvements:
- Fixed type safety: MonitorTimeseriesOutputs now uses sc.DataArray instead of Any
- Uses WorkflowOutputsBase for consistency with other workflows (bifrost, dream, etc.)
- Removed old-style registration from workflows.py (now just has TimeseriesAccumulator)
- Conditional registration based on nexus file availability

All tests pass (1407 passed, 28 skipped).

Original prompt: Please review uncommitted changes, splitting broken (old style) workflow registration into new spec+factory pattern. Is this correct?
Follow-up: Please fix as you suggest!
Follow-up: Great, please commit

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
The guards in register_monitor_workflow_specs and register_timeseries_workflow_specs
checked if a workflow was already registered and returned early to avoid duplicate
registration errors. This was defensive programming for a scenario that never occurs
in practice - no instrument specs.py calls these registration functions after
Instrument.__post_init__() auto-registers them.

Simplify the code by removing:
- The idempotency checks and WorkflowId construction in both functions
- References to "two-phase registration" in docstrings
- Unused inline SpecHandle imports in timeseries_workflow_specs.py

All tests pass. Functionality is unchanged.

Help me figure out why the "guard" in register_monitor_workflow_specs checking if the workflow is already registered is necessary? Why would there be sth. else registering the same workflow?
@SimonHeybrock SimonHeybrock changed the title Refactor monitor interval timeseries to use two-phase workflow registration Fix monitor interval timeseries to use two-phase workflow registration Nov 13, 2025
@SimonHeybrock SimonHeybrock changed the title Fix monitor interval timeseries to use two-phase workflow registration Fix monitor ratemeter workflow to use two-phase workflow registration Nov 13, 2025
@SimonHeybrock SimonHeybrock added the bug Something isn't working label Nov 13, 2025
@github-project-automation github-project-automation bot moved this to In progress in Development Board Nov 13, 2025
@SimonHeybrock SimonHeybrock moved this from In progress to Selected in Development Board Nov 13, 2025
SimonHeybrock and others added 3 commits November 13, 2025 15:42
Replace the dedicated availability check with a try/except/else block that uses
the nexus_file property directly. This eliminates code duplication and ensures
the property's caching behavior in _nexus_file is used consistently.

Original prompt: Please see diff to main, can we avoid adding _can_load_nexus_file,
or at least avoid duplication by using it in the nexus_file property?

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@SimonHeybrock SimonHeybrock marked this pull request as draft November 13, 2025 14:52
@SimonHeybrock SimonHeybrock marked this pull request as ready for review November 14, 2025 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Selected

Development

Successfully merging this pull request may close these issues.

2 participants