fix: lazy flows-DB engine in simulator (v2.0.5)#61
Merged
Conversation
`skypro simulate` no longer constructs a SQLAlchemy engine for the
flows database when all imbalance sources are csvTimeseries. The
engine was previously created eagerly and unconditionally, so a
placeholder or unparseable env_config['flows']['dbUrl'] failed at
URL parse before any simulation logic ran — blocking standalone
CSV-only handoff bundles (where flows.dbUrl is intentionally a
"REPLACE_OR_REMOVE…" placeholder).
When at least one source IS flowsMarketData the engine is still
constructed; if dbUrl is missing in that case the user now gets a
SystemExit with a clear message identifying the source of the need.
This mirrors the existing rates-DB gating pattern already in use
in the same function (see `rates_config.{live,final}.rates_db is
not None` branches further down).
- Bump version 2.0.4 → 2.0.5
- Changelog entry under [2.0.5]
- New integration subtest: test_integration_csv_only_no_flows_db
drives the CSV-only fixture with an unparseable flows.dbUrl
and asserts the simulator exits 0. Pre-2.0.5 this fixture would
crash at sqlalchemy.create_engine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
imbalance data sources are
csvTimeseries. The engine was createdeagerly and unconditionally inside
_get_rates_from_config, so aplaceholder or unparseable
env_config["flows"]["dbUrl"]failed atURL parse before any simulation logic ran.
function (
rates_config.{live,final}.rates_db is not None).flows.dbUrlis intentionally a"REPLACE_OR_REMOVE…"placeholder.flowsMarketDatathe engine is stillconstructed; missing
dbUrlin that case now raises a clearerSystemExitidentifying the source of the need.Bumps
2.0.4 → 2.0.5(patch). CHANGELOG updated under[2.0.5].Test plan
PYTHONPATH=src python -m unittest discover --start-directory src)integrationTestPriceCurve,integrationTestPerfectHindsightLPtest_integration_csv_only_no_flows_db: drives the existing CSV-only fixture with an unparseableflows.dbUrl("REPLACE_OR_REMOVE_NOT_USED_BY_SIMULATE") and assertsskypro simulateexits 0. Pre-2.0.5 this would crash atsqlalchemy.create_engine.sqlalchemy.create_engine("REPLACE_OR_REMOVE_NOT_USED_BY_SIMULATE")raisesArgumentErroron its own — the test exercises a real regression.pip install --upgrade skypro==2.0.5in a fresh venv, then run a CSV-only bundle without settingflows.dbUrlto a valid URL.Background
Found while running a standalone bundle exported from skypro-service for an external collaborator. The bundle's README claims the package is self-contained (no DB dependency), but the simulator was crashing on startup because
flows.dbUrlhad to be a parseable URL even for fully-CSV configs.