Skip to content

Feature/data dir - #242

Open
j-brendel wants to merge 4 commits into
devfrom
feature/data_dir
Open

j-brendel wants to merge 4 commits into
devfrom
feature/data_dir

Conversation

@j-brendel

Copy link
Copy Markdown
Collaborator

Central base directory (data_dir) for relative input/output paths

Problem

All paths in a SimBA config (schedule_path, electrified_stations_path, output_path, ...) and
the csv_file entries inside electrified_stations.json are resolved relative to the current
working directory
, not relative to the config file.

As a result, scenario data has to live inside the SimBA repository (e.g. data/private_examples/),
or every file has to contain absolute paths. Moving a scenario folder, e.g. confidential project
data to a separate (cloud) drive outside the repository, means editing paths in many files.
Absolute paths are machine-specific, so configs cannot be shared between colleagues.

Proposed solution

Add a new option data_dir that serves as a central base directory for relative paths:

data_dir = .                      # relative to this config file (or absolute)
schedule_path = trips.csv
electrified_stations_path = electrified_stations.json
output_path = results
  • data_dir can be set in the config, via --data-dir, or via the environment variable
    SIMBA_DATA_DIR. With the environment variable, no machine-specific path has to be stored in
    any file.
  • A relative data_dir is resolved relative to the config file.
  • What is resolved: explicitly set relative path arguments, the csv_file entries in electrified
    stations (fixed_load, local_generation, price_csv, ...), and decision_tree_path in the
    optimizer config.
  • What is not changed: absolute paths, and path arguments that still have their default value
    (e.g. vehicle_types_path). Those stay relative to the working directory.
  • Without data_dir: the behaviour is unchanged (fully backwards compatible).

Implementation (branch feature/data_dir)

  • simba/util.py: new argument --data-dir, helpers resolve_path() and resolve_data_dir(),
    called in get_args() after deprecated arguments are replaced.
  • simba/data_container.py: resolve_csv_files() is applied to the electrified stations in
    add_stations_from_json(), so SimBA and SpiceEV receive absolute paths.
  • simba/simulate.py: resolves decision_tree_path of the optimizer config.
  • Tests in tests/test_util.py and tests/test_data_container.py. Docs in
    simulation_parameters.rst and extensive.cfg.

j-brendel and others added 2 commits October 9, 2026 14:51
Relative path arguments and csv_file entries of electrified stations are
resolved against data_dir (config, --data-dir or SIMBA_DATA_DIR). A relative
data_dir is relative to the config file. Without data_dir nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@j-brendel
j-brendel requested a review from stefansc1 October 12, 2026 08:51
j-brendel and others added 2 commits October 12, 2026 10:57
- better use of add_argument options (default, type)
- move resolve_csv_files fom data_container to util
- streamline resolve_data_dir function
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.

2 participants