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

Refactor network loader #367

Merged
merged 10 commits into from
Oct 7, 2021
Merged

Refactor network loader #367

merged 10 commits into from
Oct 7, 2021

Conversation

geofjamg
Copy link
Member

@geofjamg geofjamg commented Oct 6, 2021

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

  • 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)

Does this PR already have an issue describing the problem ? If so, link to this issue using '#XXX' and skip the rest

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

What is the current behavior? (You can also link to an open issue here)

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change or deprecate an API? If yes, check the following:

  • The Breaking Change or Deprecated label has been added
  • The migration guide has been updated in the github wiki (What changes might users need to make in their application due to this PR?)

Other information:

(if any of the questions/checkboxes don't apply, please delete them entirely)

Signed-off-by: Geoffroy Jamgotchian <[email protected]>
# Conflicts:
#	src/main/java/com/powsybl/openloadflow/sa/AcSecurityAnalysis.java
#	src/main/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysis.java
#	src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
@geofjamg geofjamg requested a review from annetill October 6, 2021 14:12
@geofjamg
Copy link
Member Author

geofjamg commented Oct 6, 2021

@annetill you can test it to ensure you can easily extend LF network with additional data.
#365 has to be merged before!

# Conflicts:
#	src/main/java/com/powsybl/openloadflow/equations/EquationUtil.java
#	src/main/java/com/powsybl/openloadflow/sa/AcSecurityAnalysis.java
#	src/main/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysis.java
#	src/test/java/com/powsybl/openloadflow/ac/GeneratorTargetVoltageInconsistencyTest.java
#	src/test/java/com/powsybl/openloadflow/network/LfNetworkTest.java
#	src/test/java/com/powsybl/openloadflow/sa/LfContingencyTest.java
@geofjamg geofjamg requested a review from flo-dup October 6, 2021 14:54
@@ -431,37 +431,33 @@ private static void validate(LfNetwork network, boolean minImpedance) {
}
}

public static List<LfNetwork> load(Object network, SlackBusSelector slackBusSelector) {
return load(network, new LfNetworkParameters(slackBusSelector), Reporter.NO_OP);
public static <T> List<LfNetwork> load(T network, LfNetworkLoader<T> networkLoader, SlackBusSelector slackBusSelector) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In fact I'm wondering if we shouldn't keep a default network loader. maybe by still using a service loader, as in most cases we're using the LfNetworkLoaderImpl. That would hide the load complexity to people who don't need to customize it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Keeping a service loader just for that would be a little bit too complex for just package dependency decoupling. This is not the goal of service loaders but more external configuration.
I found another simpler solution: to add Networks.load() methods that simplify the code when we want to load from an IIDM network (Networks is a utility class from com.powsybl.openloadlow.network.iidm package)

Signed-off-by: Geoffroy Jamgotchian <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 6, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

84.4% 84.4% Coverage
0.0% 0.0% Duplication

@geofjamg
Copy link
Member Author

geofjamg commented Oct 6, 2021

Also I rethink about Identifiable in LfNetworkLoaderPostProcessor and you are right, it is better to use Object to make it independent of implementation.

@geofjamg geofjamg requested a review from flo-dup October 6, 2021 20:16
@geofjamg geofjamg merged commit b6ad97e into master Oct 7, 2021
@geofjamg geofjamg deleted the refactor_network_loader branch October 7, 2021 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants