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] Add simple self_test to Python API #651

Open
11 of 13 tasks
mgovers opened this issue Jun 24, 2024 · 0 comments
Open
11 of 13 tasks

[FEATURE] Add simple self_test to Python API #651

mgovers opened this issue Jun 24, 2024 · 0 comments
Assignees
Labels
feature New feature or request good first issue Indicates a good issue for first-time contributors

Comments

@mgovers
Copy link
Member

mgovers commented Jun 24, 2024

Some users may want to do a simple check to see if the installation was successful and there are no build errors, segfaults, undefined symbols, ...

This will enable users to build + verify the python library using pip install in the case there are no prebuilt binaries available.

This should not be part of the postinstall script, but indeed should be called by a user by running e.g.

from power_grid_model.utils import self_test

self_test()

Design

  • to src/power_grid_model.utils, add a function def self_test() without arguments. The test should run the following things:
    • with clause setting up a temporary directory for IO of the test (using standard Python temporary directory functionality)
      • Create a simple JSON input data file in the temporary directory:
        • 1 nodes, 1 source, 1 load
        • The written data should be in the PGM serialization schema
      • Load the created JSON input data file (deserialize)
      • Create a PowerGridModel instance from the loaded input data
      • Run a simple power flow calculation on the created model
        • linear calculation method should be sufficient
      • Write the calculation result to a file in the temporary directory
        • Use the json_serialize_to_file functionality
      • Verify that the written output is correct
    • Clean up the temporary directory (end of with clause)

This does multiple C API calls, runs through the main data flow, and verifies integrity of (de)serialization.

@mgovers mgovers added feature New feature or request good first issue Indicates a good issue for first-time contributors labels Jun 24, 2024
@zhen0427 zhen0427 self-assigned this Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request good first issue Indicates a good issue for first-time contributors
Projects
Status: Q3 2024
Development

No branches or pull requests

2 participants