annular.market.tulipa.config

Attributes

logger

Exceptions

TulipaConfigError

Exception raised when the TulipaConfig configuration has issues.

Classes

_TulipaConfig

Container for Tulipa configuration.

Module Contents

annular.market.tulipa.config.logger[source]
exception annular.market.tulipa.config.TulipaConfigError(msg)[source]

Bases: Exception

Exception raised when the TulipaConfig configuration has issues.

Parameters:

msg – Explanation of the error.

message[source]
class annular.market.tulipa.config._TulipaConfig(input_data_folder: pathlib.Path | str, julia_environment: pathlib.Path | str, communication_folder: pathlib.Path | str, db_path: pathlib.Path | str, debug_input_folder: pathlib.Path | str | None = None)[source]

Container for Tulipa configuration.

The container is used inside Annular to pass data from the simulation configuration to Tulipa. It contains configuration from the parameters defined via the tulipa_config_file key in the muscle3 configuration file, and additional data for internal logic.

Parameters:
  • input_data_folder – Path to data defining the Tulipa model.

  • julia_environment – Path to Julia project environment, passed to Julia as the –project argument.

  • communication_folder – Folder that stores data that are sent between annular and Tulipa. Needs to be a new folder, and it is deleted at cleanup.

  • db_path – Path to the database file.

  • debug_input_folder – Path to folder to keep database tables as csv files for debugging. Should exist inside communication_folder.

Details:

Data for communication (config file, input data, duckdb file) are deleted at cleanup. However, if debug_input_folder is given, the communication folder is persisted after cleanup.

input_data_folder[source]
julia_environment[source]
communication_folder[source]
db_path[source]
debug_input_folder[source]
classmethod from_config(input_data_folder: pathlib.Path | str, self_base_folder: pathlib.Path | str, julia_environment: pathlib.Path | str, communication_folder: pathlib.Path | str | None = None, iteration_id: None | int = None, db_file: str = 'tulipa.duckdb')[source]

Create a _TulipaConfig class from a configuration file.

Parameters:
  • input_data_folder – Path to data defining the Tulipa model, interpreted relative to self_base_folder.

  • self_base_folder – The path to the tulipa_config_file. Used internally to find the path to the input_data_folder.

  • julia_environment – Path to Julia project environment, passed to Julia as the –project argument. Interpreted relative to self_base_folder.

  • communication_folder – Folder that stores data that are sent between Annular and Tulipa. Needs to be a new folder, and it is deleted at cleanup. By default, a directory ./.tulipa-communication-0 is used in the location of the main python process. Otherwise, the path is interpreted relative to the location of self_base_folder.

  • iteration_id – Identifier of the iteration. If given, used for creating unique communication folders for each invocation of the market model in a multi-period annular simulation.

  • db_file – Name of the database file inside communication_folder.

Raises:

TulipaConfigError – When (i) input_data_folder does not exist, (ii) communication_folder already exists, or (iii) the provided project environment for Julia cannot be found.

property config_file: pathlib.Path[source]

Yaml file for communicating settings from python to Julia.

static _validate_julia_env(environment: pathlib.Path, base_folder: pathlib.Path) pathlib.Path[source]
write_to_yaml()[source]

Write config to yaml, converting Path objects to strings.

cleanup()[source]

Remove database and temp dir.