-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Is your feature request related to a problem? Please describe.
Currently, it is not possible to set up an eDisGo instance completely without connecting to the Open Energy Platform ((T)OEP) database. During the configuration setup within the get_database_alias_dictionaries, there is an automatic call to the OEP database that is unnecessary when using an alternative eGon-data database. This can cause issues for users who do not wish to rely on the OEP.
Lines 171 to 208 in a0e83c9
| def get_database_alias_dictionaries(self) -> tuple[dict[str, str], dict[str, str]]: | |
| """ | |
| Retrieves the database alias dictionaries for table and schema mappings. | |
| Returns | |
| ------- | |
| tuple | |
| A tuple containing two dictionaries: | |
| - name_mapping: A dictionary mapping source table names to target table | |
| names. | |
| - schema_mapping: A dictionary mapping source schema names to target schema | |
| names. | |
| """ | |
| OEP_CONNECTION = "postgresql+oedialect://:@{platform}" | |
| platform = "toep.iks.cs.ovgu.de" | |
| conn_str = OEP_CONNECTION.format(platform=platform) | |
| engine = sa.create_engine(conn_str) | |
| dictionary_schema_name = ( | |
| "model_draft" # Replace with the actual schema name if needed | |
| ) | |
| dictionary_module_name = f"saio.{dictionary_schema_name}" | |
| register_schema(dictionary_schema_name, engine) | |
| dictionary_table_name = "edut_00" | |
| dictionary_table = importlib.import_module(dictionary_module_name).__getattr__( | |
| dictionary_table_name | |
| ) | |
| with session_scope_egon_data(engine) as session: | |
| query = session.query(dictionary_table) | |
| dictionary_entries = query.all() | |
| name_mapping = { | |
| entry.source_name: entry.target_name for entry in dictionary_entries | |
| } | |
| schema_mapping = { | |
| entry.source_schema: getattr(entry, "target_schema", "model_draft") | |
| for entry in dictionary_entries | |
| } | |
| return name_mapping, schema_mapping |
Describe the solution you'd like
The setup process should only call the OEP database when explicitly required. If an alternative database (e.g., eGon-data) is specified, the OEP call should be bypassed. A configurable option should be introduced to allow users to disable the OEP database query when it is not needed.
Describe alternatives you've considered
- Creating a workaround to intercept and override the database query (adds unnecessary complexity).
Additional context
This enhancement would improve the flexibility of eDisGo, making it easier for users to set up instances with alternative databases without unwanted dependencies on the OEP.