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

Load default loadflow parameters from json file in classpath #3040

Merged
merged 8 commits into from
May 31, 2024

Conversation

HugoKulesza
Copy link
Contributor

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce?

A new way to define default loadflow parameters is added.

The order of loadflow parameters override is now the following :

  • Default parameters as written in the LoadFlowParameters class
  • (new) Optional parameters defined in a JSON file in the classpath, linked using an implementation of LoadFlowDefaultParametersLoader
  • Optional parameters defined in the powsybl config.yml file of the user

Only one parameters JSON file can be used, if multiple are found none are used to override parameters

HugoKulesza and others added 3 commits May 29, 2024 16:44
Signed-off-by: Hugo KULESZA <hugo.kulesza@rte-france.com>
Signed-off-by: Hugo KULESZA <hugo.kulesza@rte-france.com>
Copy link
Member

@geofjamg geofjamg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor issues

private final String jsonParametersFile;

AbstractLoadFlowDefaultParametersLoader(String name, String jsonParametersFile) {
this.name = name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Objects.requireNonNull ?

}

public LoadFlowParameters(List<LoadFlowDefaultParametersLoader> defaultParametersLoaders) {
int numberOfLoadersFound = defaultParametersLoaders.size();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

} else if (numberOfLoadersFound == 1) {
LoadFlowDefaultParametersLoader loader = defaultParametersLoaders.get(0);
JsonLoadFlowParameters.update(this, loader.loadDefaultParametersFromFile());
LOGGER.info("Default loadflow configuration has been updated using the reference file from parameters loader '{}'", loader.getSourceName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just a debug log

this(ServiceLoader.load(LoadFlowDefaultParametersLoader.class)
.stream()
.map(ServiceLoader.Provider::get)
.collect(Collectors.toList()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toList()

if (numberOfLoadersFound > 1) {
List<String> names = defaultParametersLoaders.stream()
.map(LoadFlowDefaultParametersLoader::getSourceName)
.collect(Collectors.toList());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toList()


AbstractLoadFlowDefaultParametersLoader(String name, String jsonParametersFile) {
this.name = name;
this.jsonParametersFile = jsonParametersFile;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

HugoKulesza and others added 3 commits May 31, 2024 16:53
Signed-off-by: Hugo KULESZA <hugo.kulesza@rte-france.com>
Signed-off-by: Hugo KULESZA <hugo.kulesza@rte-france.com>
Copy link

sonarcloud bot commented May 31, 2024

@flo-dup flo-dup merged commit 15a6deb into main May 31, 2024
7 checks passed
@flo-dup flo-dup deleted the loadflow-default-parameters-json branch May 31, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants