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

Make JSON CRAC import more robust #1098

Closed
pet-mit opened this issue Jul 25, 2024 · 0 comments
Closed

Make JSON CRAC import more robust #1098

pet-mit opened this issue Jul 25, 2024 · 0 comments
Labels
feature New feature or request good first issue Good for newcomers

Comments

@pet-mit
Copy link
Collaborator

pet-mit commented Jul 25, 2024

Describe the current behavior

When an element in the json crac is wrong (for example a network action with one elementary action pointing to a network element that does not exist in the network), the json import fails and produces a null CRAC.

Describe the expected behavior

Do like other format importers: ignore the wrong elements and log the issue in the CracCreationContext.
It may actually be hard because of the usage of the JsonParser that reads the file from top to bottom (meaning that when we face an issue, we should exit the current element "gracefully").

Describe the motivation

More robust importer

Extra Information

A basic test case : network action "complexNetworkActionId" should be ignored because one of its elementary actions is wrong

@test
crac-partial.json

void testPartialImport() {
    Network network = NetworkImportsUtil.createNetworkForJsonRetrocompatibilityTest();
    InputStream cracFile = getClass().getResourceAsStream("/crac-partial.json");
    CracCreationContext ccc = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null);

    assertNotNull(ccc);;
    assertTrue(ccc.isCreationSuccessful());

    Crac crac = ccc.getCrac();
    assertNotNull(crac);
}
@pet-mit pet-mit added feature New feature or request good first issue Good for newcomers labels Jul 25, 2024
@bqth29 bqth29 assigned bqth29 and unassigned bqth29 Jul 31, 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 Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants