Description
Hackathon 2025-05-21: Add enums for attributes in Python
This topic aims to familiarize contributors with development inside the Python library and code generator. It focuses on automatically generating a unified enum for all attribute names in the Python API to simplify and standardize access.
Premise
Power grid model data in python API has multiple dataset types and components, each of which contain multiple attributes (see Input dataset example). We can access components and attributes directly via strings, e.g., using initialize_array("input", "node", 2)
, or update_data["line"]["id"]
This, however, is not the best practice, as it causes multiple issues. Some of these issues are mentioned in this issue #613. Towards this end, PGM has implemented DatasetType
and ComponentType
enums in #648. The enums for attributes, however, are yet to be implemented and they are proposed in #949 .
Goal of the hackathon
This hackathon task is about adding all attribute related enums in PGM for the Python API. After design discussions within PGM team, it is decided to create a single enum with attributes present in it. With new support, the number of attributes keep on increasing, hence, this enum has to be generated automatically via code generator to simplify further development.
Steps
The following steps are adapted from the instructions specified in #613 and #648. Please see the issues for details.
- Install and setup the development environment following the instructions in [Feature] PGM Meet-up 2025-05-21 Hackathons #977 .
- Set up code generator to give out the enum.
- Run the code generator
- Expose the new enum in the init.py
- Update the documentation to reflect the changes.
- Update examples to use the new enum.
- Update PGM workshop notebooks.
- Update attributes in all places at code in PGM.
- Update tests at PGM
- Update PGM-IO with new enums
Metadata
Metadata
Assignees
Type
Projects
Status