Skip to content

Debug computation mode (migration with ws-commons) #119

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<mockwebserver3.version>5.0.0-alpha.14</mockwebserver3.version>
<sonar.organization>gridsuite</sonar.organization>
<sonar.projectKey>org.gridsuite:sensitivity-analysis-server</sonar.projectKey>
<!-- FIXME: powsybl-ws-commons modules'version is overloaded in the dependencies section to be removed at next powsybl-ws-dependencies.version upgrade -->
<powsybl-ws-commons.version>1.25.0-SNAPSHOT</powsybl-ws-commons.version>
</properties>

<build>
Expand Down Expand Up @@ -145,6 +147,7 @@
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-ws-commons</artifactId>
<version>${powsybl-ws-commons.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected CompletableFuture<Void> getCompletableFuture(SensitivityAnalysisRunCon
contingencies,
runContext.getSensitivityAnalysisInputs().getVariablesSets(),
sensitivityAnalysisParameters,
executionService.getComputationManager(),
runContext.getComputationManager(),
runContext.getReportNode());

if (resultUuid != null) {
Expand Down Expand Up @@ -227,6 +227,7 @@ public SensitivityAnalysisResult run(UUID networkUuid, String variantId, ReportI

private SensitivityAnalysisResult runInMemory(SensitivityAnalysisRunContext runContext) throws Exception {
Objects.requireNonNull(runContext);
runContext.setComputationManager(createComputationManager());

LOGGER.info("Run sensitivity analysis");

Expand Down Expand Up @@ -293,7 +294,7 @@ private CompletableFuture<SensitivityAnalysisResult> runAsyncInMemory(Sensitivit
contingencies,
context.getSensitivityAnalysisInputs().getVariablesSets(),
parameters,
executionService.getComputationManager(),
context.getComputationManager(),
reporter);
return future.thenApply(r -> new SensitivityAnalysisResult(factors, writer.getContingencyStatuses(), writer.getValues()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
import com.powsybl.loadflow.LoadFlowProvider;
import com.powsybl.network.store.client.NetworkStoreService;
import com.powsybl.sensitivity.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import com.powsybl.ws.commons.computation.service.AbstractResultContext;
import com.powsybl.ws.commons.computation.service.AbstractWorkerService;
import com.powsybl.ws.commons.computation.service.ExecutionService;
import com.powsybl.ws.commons.computation.service.ReportService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.gridsuite.sensitivityanalysis.server.dto.IdentifiableAttributes;
import org.gridsuite.sensitivityanalysis.server.dto.nonevacuatedenergy.NonEvacuatedEnergyInputData;
import org.gridsuite.sensitivityanalysis.server.dto.nonevacuatedenergy.NonEvacuatedEnergyStageDefinition;
import org.gridsuite.sensitivityanalysis.server.dto.nonevacuatedenergy.NonEvacuatedEnergyStagesSelection;
import org.gridsuite.sensitivityanalysis.server.dto.nonevacuatedenergy.NonEvacuatedEnergyStatus;
import org.gridsuite.sensitivityanalysis.server.dto.nonevacuatedenergy.results.*;
import com.powsybl.ws.commons.computation.service.ReportService;
import com.powsybl.ws.commons.computation.service.ExecutionService;
import org.gridsuite.sensitivityanalysis.server.util.SensitivityAnalysisRunnerSupplier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -43,7 +43,7 @@

import java.io.IOException;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.function.Function;
Expand Down Expand Up @@ -817,7 +817,7 @@ protected CompletableFuture<NonEvacuatedEnergyResults> getCompletableFuture(NonE
throw new PowsyblException("Loadflow in DC mode not allowed !!");
}

ComputationManager computationManager = executionService.getComputationManager();
ComputationManager computationManager = runContext.getComputationManager();

return CompletableFuture.supplyAsync(() ->
run(runContext, runContext.getNetwork(), sensitivityAnalysisParameters, sensitivityAnalysisRunner, computationManager, runContext.getReportNode())
Expand Down
Loading