Skip to content

Commit

Permalink
Add parameter logs before the computation
Browse files Browse the repository at this point in the history
Signed-off-by: BOUHOURS Antoine <[email protected]>
  • Loading branch information
antoinebhs authored and flo-dup committed Jul 3, 2024
1 parent 04969cc commit 9b4ca5b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dynaflow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<name>DynaFlow</name>
<description>DynaFlow integration module for powsybl</description>

<properties>
<asciitable.version>0.3.2</asciitable.version>
</properties>

<dependencies>
<!-- Compile dependencies -->
<dependency>
Expand All @@ -42,6 +46,11 @@
<groupId>${project.groupId}</groupId>
<artifactId>powsybl-dynawo-commons</artifactId>
</dependency>
<dependency>
<groupId>de.vandermeer</groupId>
<artifactId>asciitable</artifactId>
<version>${asciitable.version}</version>
</dependency>

<!-- Test dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
import com.powsybl.loadflow.LoadFlowParameters;
import com.powsybl.dynaflow.DynaFlowConstants.ActivePowerCompensation;
import com.powsybl.dynaflow.DynaFlowConstants.StartingPointMode;
import de.vandermeer.asciitable.AsciiTable;
import de.vandermeer.asciitable.CWC_LongestWord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.*;
Expand All @@ -33,6 +37,8 @@
*/
public class DynaFlowParameters extends AbstractExtension<LoadFlowParameters> {

private static final Logger LOGGER = LoggerFactory.getLogger(DynaFlowParameters.class);

/**
* Inner class dedicated to Security Analysis (SA) namespace
*/
Expand Down Expand Up @@ -353,6 +359,25 @@ private static void load(DynaFlowParameters parameters, ModuleConfig config) {
config.getOptionalBooleanProperty(MERGE_LOADS).ifPresent(parameters::setMergeLoads);
}

public static void log(LoadFlowParameters parameters, DynaFlowParameters parametersExt) {
if (LOGGER.isInfoEnabled()) {
AsciiTable at = new AsciiTable();
at.addRule();
at.addRow("Name", "Value");
at.addRule();
for (var e : parameters.toMap().entrySet()) {
at.addRow(e.getKey(), e.getValue());
}
for (var e : parametersExt.createMapFromParameters().entrySet()) {
at.addRow(e.getKey(), Objects.toString(e.getValue(), ""));
}
at.addRule();
at.getRenderer().setCWC(new CWC_LongestWord());
at.setPaddingLeftRight(1, 1);
LOGGER.info("Parameters:\n{}", at.render());
}
}

public void update(Map<String, String> properties) {
Objects.requireNonNull(properties);
Optional.ofNullable(properties.get(SVC_REGULATION_ON)).ifPresent(prop -> setSvcRegulationOn(Boolean.parseBoolean(prop)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public CompletableFuture<LoadFlowResult> run(Network network, ComputationManager
Objects.requireNonNull(workingStateId);
Objects.requireNonNull(loadFlowParameters);
DynaFlowParameters dynaFlowParameters = getParametersExt(loadFlowParameters);
DynaFlowParameters.log(loadFlowParameters, dynaFlowParameters);
DynaFlowConfig config = Objects.requireNonNull(configSupplier.get());
ExecutionEnvironment env = new ExecutionEnvironment(config.createEnv(), WORKING_DIR_PREFIX, config.isDebug());
Command versionCmd = getVersionCommand(config);
Expand Down

0 comments on commit 9b4ca5b

Please sign in to comment.