Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Make OEP Database Call Optional in eDisGo Configuration #455

Open
khelfen opened this issue Feb 12, 2025 · 2 comments
Open

[FEATURE] Make OEP Database Call Optional in eDisGo Configuration #455

khelfen opened this issue Feb 12, 2025 · 2 comments
Assignees

Comments

@khelfen
Copy link
Collaborator

khelfen commented Feb 12, 2025

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.

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.

@khelfen
Copy link
Collaborator Author

khelfen commented Feb 12, 2025

This is somewhat related to #450

@khelfen
Copy link
Collaborator Author

khelfen commented Feb 12, 2025

Included into #451

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant