Skip to content

fix: lazy flows-DB engine in simulator (v2.0.5)#61

Merged
damonrand merged 1 commit into
mainfrom
fix/lazy-flows-engine-simulator
May 8, 2026
Merged

fix: lazy flows-DB engine in simulator (v2.0.5)#61
damonrand merged 1 commit into
mainfrom
fix/lazy-flows-engine-simulator

Conversation

@damonrand
Copy link
Copy Markdown
Contributor

Summary

  • Stop constructing a SQLAlchemy engine for the flows DB when all
    imbalance data sources are csvTimeseries. The engine was created
    eagerly and unconditionally inside _get_rates_from_config, so a
    placeholder or unparseable env_config["flows"]["dbUrl"] failed at
    URL parse before any simulation logic ran.
  • Mirrors the existing rates-DB gating pattern further down the same
    function (rates_config.{live,final}.rates_db is not None).
  • Unblocks the standalone CSV-only handoff bundle path, where
    flows.dbUrl is intentionally a "REPLACE_OR_REMOVE…" placeholder.
  • When at least one source IS flowsMarketData the engine is still
    constructed; missing dbUrl in that case now raises a clearer
    SystemExit identifying the source of the need.

Bumps 2.0.4 → 2.0.5 (patch). CHANGELOG updated under [2.0.5].

Test plan

  • All 14 unit tests pass (PYTHONPATH=src python -m unittest discover --start-directory src)
  • Existing integration subtests pass: integrationTestPriceCurve, integrationTestPerfectHindsightLP
  • New integration subtest test_integration_csv_only_no_flows_db: drives the existing CSV-only fixture with an unparseable flows.dbUrl ("REPLACE_OR_REMOVE_NOT_USED_BY_SIMULATE") and asserts skypro simulate exits 0. Pre-2.0.5 this would crash at sqlalchemy.create_engine.
  • Verified sqlalchemy.create_engine("REPLACE_OR_REMOVE_NOT_USED_BY_SIMULATE") raises ArgumentError on its own — the test exercises a real regression.
  • Manual smoke after publish: pip install --upgrade skypro==2.0.5 in a fresh venv, then run a CSV-only bundle without setting flows.dbUrl to 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.dbUrl had to be a parseable URL even for fully-CSV configs.

`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.
@damonrand damonrand merged commit 9dbce0a into main May 8, 2026
2 checks passed
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.

1 participant