Conversation
WalkthroughAdds an evolving mode to myopic sequencing: new config options, runtime support to run an external evolution script between iterations, progress reporting for evolve status, conditional logging for myopic data filtering, and a new post-iteration evolution hook. Changes
Sequence DiagramsequenceDiagram
participant Seq as MyopicSequencer
participant Evol as Evolution Script
participant DB as SQLite DB
participant Loader as Data Loader
participant Solver as Solver/Reporter
loop each iteration
alt evolving enabled and not first iteration
Seq->>Evol: call iterate(idx, prev_base_year, last_status, db_con)
Evol->>DB: update myopic tables (rgba(70,130,180,0.5))
DB-->>Evol: confirmation
Evol-->>Seq: return
end
Seq->>DB: update myopic_efficiency table
Seq->>Loader: load filtered data
Loader-->>Seq: filtered dataset
Seq->>Seq: build instance
Seq->>Solver: check & solve
Solver-->>Seq: results & status
Seq->>Seq: report progress (includes EVLV when evolving)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@temoa/extensions/myopic/myopic_sequencer.py`:
- Around line 213-221: Check that the path in self.evolution_script exists and
is a readable file (use os.path.exists/isfile) before calling
util.spec_from_file_location; after creating spec verify spec is not None and
spec.loader is not None before calling spec.loader.exec_module; once the module
is loaded verify hasattr(evolution_module, "iterate") and
callable(evolution_module.iterate) and only then call
evolution_module.iterate(...)—otherwise log/raise a clear, descriptive error
mentioning the missing file, spec, loader, or non-callable iterate so failures
are explicit and debuggable.
In `@temoa/tutorial_assets/config_sample.toml`:
- Line 157: The sample config uses a Windows-style path for the evolution_script
setting; update the evolution_script value (the "evolution_script" key) to use a
cross-platform path (POSIX-style forward slashes) so it resolves on Linux/macOS
and is safe to copy/paste (e.g., change the value from
"temoa\\extensions\\myopic\\evolution_updater.py" to a forward-slash form like
"temoa/extensions/myopic/evolution_updater.py").
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 18339bab-ae1c-43c9-ad62-14122d735c76
📒 Files selected for processing (8)
temoa/core/config.pytemoa/data_io/hybrid_loader.pytemoa/extensions/myopic/evolution_updater.pytemoa/extensions/myopic/myopic_progress_mapper.pytemoa/extensions/myopic/myopic_sequencer.pytemoa/tutorial_assets/config_sample.tomltests/test_myopic_sequencer.pytests/testing_configs/config_utopia_myopic.toml
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
temoa/tutorial_assets/config_sample.toml (1)
156-156:⚠️ Potential issue | 🟠 MajorSet sample
evolvingdefault to non-evolving.
evolving = truein the sample template enables the compute-heavier path by default for copy/paste users, which contradicts the PR goal of defaulting to normal (non-evolving) myopic behavior.🔧 Proposed fix
-evolving = true +evolving = false🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@temoa/tutorial_assets/config_sample.toml` at line 156, The sample config currently sets evolving = true which makes the heavier evolving path the default; update the sample template to set the flag to non-evolving by changing the setting evolving = true to evolving = false (update the config key "evolving" in the sample file/template so copy/paste users get the normal myopic behavior by default).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@temoa/extensions/myopic/evolution_updater.py`:
- Around line 8-12: The code allows idx: MyopicIndex | None but later uses
idx.base_year unguarded; add an explicit check in the function (the constructor
or initializer that accepts idx) to validate idx is not None before accessing
idx.base_year (or handle the None case deterministically), e.g., if idx is None
raise a clear ValueError or provide a documented fallback; update any logic that
reads idx.base_year to run only after this guard so failures are explicit and
deterministic (refer to the parameter name idx and the type MyopicIndex and the
property base_year when locating the usage).
---
Duplicate comments:
In `@temoa/tutorial_assets/config_sample.toml`:
- Line 156: The sample config currently sets evolving = true which makes the
heavier evolving path the default; update the sample template to set the flag to
non-evolving by changing the setting evolving = true to evolving = false (update
the config key "evolving" in the sample file/template so copy/paste users get
the normal myopic behavior by default).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 96b3e5d7-d97a-4301-b805-bacc6ad8bbbd
📒 Files selected for processing (3)
temoa/extensions/myopic/evolution_updater.pytemoa/extensions/myopic/myopic_sequencer.pytemoa/tutorial_assets/config_sample.toml
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@temoa/tutorial_assets/config_sample.toml`:
- Around line 149-155: Clarify that step_size is only meaningful when evolving
mode is enabled by updating the comment near the step_size setting: mention that
step_size controls how many periods the planner advances on each myopic
iteration when evolving mode (and evolution_script) is enabled, and that it must
be <= view_depth; also add a short note that when evolving mode is false,
step_size has no effect. Reference the existing symbols: step_size, evolving
mode (e.g., evolution_script), and view depth in the updated comment so users
understand the relationship.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1d335026-e71d-4fbb-bf8d-1b8ef1ed4823
📒 Files selected for processing (2)
temoa/tutorial_assets/config_sample.tomltests/testing_configs/config_utopia_myopic.toml
Creates two versions of myopic mode: normal and evolving.
Evolving myopic:
We call an "evolution script" between iterations, which may be used to update the myopic database (e.g., to "surprise" the optimisation as it moves forward, or to update parameters based on past decisions). In this mode, the problem may change going forward and so we need to "shrink" the view depth as we approach the end of the horizon, so that we make decisions at every defined step.
Normal (non-evolving) myopic:
We do not call the evolution script. As a result, the period which views to the end of the horizon should be the final planning period. There is no need to shrink the view depth and step forward as the model should make identical decisions, as this is just a subproblem of the previous problem.
NOTE: Evolving myopic (with no evolution script) is currently the default in Temoa, but this would make normal (non-evolving) the default behaviour as it saves unnecessary compute.
Utopia testing for all possible view depths and step sizes:
Old behaviour:
log_baseline.txt
New normal (non-evolving) behaviour for all possible view depths and step sizes:
log_new_non-evolving.txt
New evolving behaviour for all possible view depths and step sizes:
log_new_evolving.txt
Summary by CodeRabbit
New Features
Configuration Updates
Improvements
Tests