Skip to content

Edisgo run edisgo#629

Open
MoritzSchloesser wants to merge 42 commits into
devfrom
edisgo_run_edisgo
Open

Edisgo run edisgo#629
MoritzSchloesser wants to merge 42 commits into
devfrom
edisgo_run_edisgo

Conversation

@MoritzSchloesser

Copy link
Copy Markdown
Collaborator

Description

Please include a summary of the change and which issue is fixed.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • New and adjusted code is formatted using the pre-commit hooks
  • New and adjusted code includes type hinting now
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The Read the Docs documentation is compiling correctly
  • If new packages are needed, I added them the setup.py, and if needed the rtd_requirements.txt, the eDisGo_env.yml and the eDisGo_env_dev.yml.
  • I have added new features to the corresponding whatsnew file

Jonas Danke and others added 30 commits May 13, 2026 16:15
Adds optional overlying_grid_data kwarg to run_edisgo() that is
stashed on RunContext for downstream tasks instead of being passed
as a keyword to every task (which broke task signatures).

task_import_overlying_grid_data now:
- accepts the standard (edisgo, ctx, *, ...) signature
- reads overlying_grid_data from ctx, falls back to overlying_grid.path
  in the runner config
- loads dispatchable + renewables_potential CSVs and applies them via
  set_time_series_active_power_predefined
- shifts the year and reindexes overlying-grid attributes to the
  active edisgo timeindex so CSV-based input lines up with OEDB
  time series

task_set_timeindex now reduces existing time-series data to the new
index (via reduce_timeseries_data_to_given_timeindex) instead of
silently leaving stale data behind.

Renames the uc4_example_MS preset to uc4_example.
…ndex

powermodels_io.from_powermodels now slices the destination time index
explicitly when writing OPF flex results back to the EDisGo
timeseries (gen_nd, heatpumps, electromobility, dsm, storage). Using
`loc[:, names]` overwrites every row of the underlying DataFrame
even when the OPF only covered a subset of timesteps; restricting
to `timeseries.timeindex` keeps untouched rows intact.

task_optimize:
- fixes typo `flexbile` → `flexible` in the dsm shortcut
- corrects the dsm condition (was checking `is not None`, should
  populate when `None`)
- materializes empty flex lists once instead of repeating `or []`
  at every call site

task_import_overlying_grid_data reindexes the three SOC attributes
(storage_units_soc, thermal_storage_units_{central,decentral}_soc) to
timeindex + 1 extra step, because PowerModels expects the
end-of-period SOC value; non-SOC overlying-grid attributes still
reindex to the plain timeindex.

uc4_example preset reworked: switches to opf_version 3 (HV
constraints from overlying grid), drops base_reinforce + check_integrity
from the pipeline, adds an explicit `overlying_grid.path` config slot,
splits import_electromobility kwargs onto separate lines, and enables
archive + save_opf_results on the final save step.
Adds optional overlying_grid_data kwarg to run_edisgo() that is
stashed on RunContext for downstream tasks instead of being passed
as a keyword to every task (which broke task signatures).

task_import_overlying_grid_data now:
- accepts the standard (edisgo, ctx, *, ...) signature
- reads overlying_grid_data from ctx, falls back to overlying_grid.path
  in the runner config
- loads dispatchable + renewables_potential CSVs and applies them via
  set_time_series_active_power_predefined
- shifts the year and reindexes overlying-grid attributes to the
  active edisgo timeindex so CSV-based input lines up with OEDB
  time series

task_set_timeindex now reduces existing time-series data to the new
index (via reduce_timeseries_data_to_given_timeindex) instead of
silently leaving stale data behind.

Renames the uc4_example_MS preset to uc4_example.
…ndex

powermodels_io.from_powermodels now slices the destination time index
explicitly when writing OPF flex results back to the EDisGo
timeseries (gen_nd, heatpumps, electromobility, dsm, storage). Using
`loc[:, names]` overwrites every row of the underlying DataFrame
even when the OPF only covered a subset of timesteps; restricting
to `timeseries.timeindex` keeps untouched rows intact.

task_optimize:
- fixes typo `flexbile` → `flexible` in the dsm shortcut
- corrects the dsm condition (was checking `is not None`, should
  populate when `None`)
- materializes empty flex lists once instead of repeating `or []`
  at every call site

task_import_overlying_grid_data reindexes the three SOC attributes
(storage_units_soc, thermal_storage_units_{central,decentral}_soc) to
timeindex + 1 extra step, because PowerModels expects the
end-of-period SOC value; non-SOC overlying-grid attributes still
reindex to the plain timeindex.

uc4_example preset reworked: switches to opf_version 3 (HV
constraints from overlying grid), drops base_reinforce + check_integrity
from the pipeline, adds an explicit `overlying_grid.path` config slot,
splits import_electromobility kwargs onto separate lines, and enables
archive + save_opf_results on the final save step.
ClaraBuettner and others added 11 commits June 3, 2026 15:18
…nterface

This branch includes changes that were required to run eDisGo within eGo when overlying_grid_data is not stored in csv-files but taken from eTraGo results.
- timeseries.task_manual_ts: pass set_time_series_manual's real kwargs
  (generators_p/loads_p/... instead of *_active_power) — task was unusable.
- config._adapt_ego_legacy: merge the duplicated 'overlying_grid' dict key
  (the 'path' entry was silently dropped).
- tasks.io.import_overlying_grid_data: rewrite tangled control flow —
  guard .get(...).empty against None, drop the double from_csv, only warn
  on a genuinely unknown source, and infer the SOC extra step only when
  derivable (no IndexError on a single-timestamp timeindex).
- validator: load_from no longer satisfies the time-series/flex
  prerequisite for analyze/reinforce/optimize, since _load_artifact reloads
  with import_timeseries=False and drops flex data (+ regression test).
- powermodels_io: unify SOC year via DateOffset instead of replace(year=)
  to avoid a Feb-29 ValueError on leap-to-non-leap remapping.
- context.ensure_engine: connect directly to a configured local postgres
  (psycopg2, pool_pre_ping) when SSH is disabled and host params are given.
- config._resolve_extends: resolve a relative 'extends' against the
  including file before falling back to a bundled preset.
…ct loader

- registry: register_task now records requires/provides/ts_altering metadata
  (TaskMeta) exposed via get_task_meta. Tasks declare their pre-/post-
  conditions (setup_grid provides 'grid', TS tasks provide 'timeseries', flex
  imports require 'grid' and provide 'flex', analyze/reinforce require
  'timeseries', optimize requires 'timeseries'+'flex', base_reinforce requires
  'grid').
- validator: check those metadata generically instead of maintaining parallel
  hard-coded task-name sets, so it stays in sync with the tasks. load_from
  provides only 'grid' (not timeseries/flex), matching _load_artifact. Compute
  the known-task set once instead of per step.
- runner._load_artifact and tasks.grid.task_load_from_base now share one
  load_saved_edisgo() helper instead of duplicating the import_edisgo_from_files
  policy.
- tools.align_series_to_timeindex: single helper that shifts a series' year
  (via DateOffset, leap-safe) and reindexes onto the edisgo time index, with
  an optional end-of-period step for SOC series. Used by both
  tasks.io.import_overlying_grid_data and powermodels_io (which now reindexes
  the SOC series instead of .loc, so a missing step yields NaN not KeyError).
- context: declare overlying_grid_data as a RunContext field instead of a
  dynamically-set attribute; the task reads it directly.
- EDisGo.run_pipeline: accept and forward overlying_grid_data (API symmetry
  with run_edisgo).
- config._adapt_ego_legacy: deep-copy cfg['database'] before injecting ssh so
  the caller's config is not mutated.
Cover the previously-untested task control flow (source of the review bugs):
task_manual_ts applies its kwargs, import_overlying_grid_data handles the
disabled/unknown/etrago-without-data/empty-etrago/csv-without-path branches
without crashing, and every bundled preset passes the metadata-driven
validator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants