Repository navigation
feat(LogicalControls): change to distinct and async computation #1138
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
dbraquart
wants to merge
11
commits into
main
Choose a base branch
from
dbraquart/add-logical-controls-as-distinct-async-computation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b534631
wip
dbraquart 319a77e
Merge branch 'main' into dbraquart/add-logical-controls-as-distinct-a…
dbraquart dec32c7
clean : rm previous sync mode
dbraquart 979af1d
add cancel
dbraquart 00a104c
invalidate LC when estim params change
dbraquart 1b3041c
add missing clean on node deletion
dbraquart c1422e7
add missing entity/dto mapping
dbraquart 046e874
Merge remote-tracking branch 'origin/main' into dbraquart/add-logical…
dbraquart c180858
checkstyle after merge
dbraquart c2ba8b7
Merge branch 'main' into dbraquart/add-logical-controls-as-distinct-a…
dbraquart 829d301
Merge branch 'main' into dbraquart/add-logical-controls-as-distinct-a…
achour94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
...java/org/gridsuite/study/server/controller/logicalcontrols/LogicalControlsController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| /** | ||
| * Copyright (c) 2026, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
| package org.gridsuite.study.server.controller.logicalcontrols; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import org.gridsuite.study.server.StudyApi; | ||
| import org.gridsuite.study.server.nodeactivity.NodeActivityRunnerService; | ||
| import org.gridsuite.study.server.service.RootNetworkNodeInfoService; | ||
| import org.gridsuite.study.server.service.StudyService; | ||
| import org.gridsuite.study.server.service.logicalcontrols.LogicalControlsService; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; | ||
| import static org.gridsuite.study.server.nodeactivity.NodeActivityType.COMPUTE; | ||
|
|
||
| /** | ||
| * @author David Braquart <david.braquart at rte-france.com> | ||
| */ | ||
| @RestController | ||
| @RequestMapping(value = "/" + StudyApi.API_VERSION + "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/logical-controls") | ||
| @Tag(name = "Study server - Logical controls") | ||
| public class LogicalControlsController { | ||
| private final RootNetworkNodeInfoService rootNetworkNodeInfoService; | ||
| private final StudyService studyService; | ||
| private final LogicalControlsService logicalControlsService; | ||
| private final NodeActivityRunnerService nodeActivityRunnerService; | ||
|
|
||
| public LogicalControlsController(RootNetworkNodeInfoService rootNetworkNodeInfoService, StudyService studyService, LogicalControlsService logicalControlsService, | ||
| NodeActivityRunnerService nodeActivityRunnerService) { | ||
| this.rootNetworkNodeInfoService = rootNetworkNodeInfoService; | ||
| this.studyService = studyService; | ||
| this.logicalControlsService = logicalControlsService; | ||
| this.nodeActivityRunnerService = nodeActivityRunnerService; | ||
| } | ||
|
|
||
| @PostMapping(value = "/run") | ||
| @Operation(summary = "run logical controls on study") | ||
| @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The logical controls has started")}) | ||
| public ResponseEntity<Void> runLogicalControls(@Parameter(description = "studyUuid") @PathVariable("studyUuid") UUID studyUuid, | ||
| @PathVariable("rootNetworkUuid") UUID rootNetworkUuid, | ||
| @Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid, | ||
| @RequestHeader(HEADER_USER_ID) String userId) { | ||
| studyService.assertIsNodeNotReadOnly(nodeUuid); | ||
| // no quota on this computation | ||
| nodeActivityRunnerService.runWith(COMPUTE, studyUuid, rootNetworkUuid, List.of(nodeUuid), | ||
| () -> logicalControlsService.runLogicalControls(studyUuid, nodeUuid, rootNetworkUuid, userId)); | ||
| return ResponseEntity.ok().build(); | ||
| } | ||
|
|
||
| @PutMapping(value = "/stop") | ||
| @Operation(summary = "stop logical controls on study") | ||
| @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The logical controls has been stopped")}) | ||
| public ResponseEntity<Void> stopLogicalControls(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid, | ||
| @PathVariable("rootNetworkUuid") UUID rootNetworkUuid, | ||
| @Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) { | ||
| rootNetworkNodeInfoService.stopLogicalControls(studyUuid, nodeUuid, rootNetworkUuid); | ||
| return ResponseEntity.ok().build(); | ||
| } | ||
|
|
||
| @GetMapping(value = "/result") | ||
| @Operation(summary = "Get a logical controls result on study") | ||
| @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The logical controls result"), | ||
| @ApiResponse(responseCode = "204", description = "No logical controls has been done yet"), | ||
| @ApiResponse(responseCode = "404", description = "The logical controls has not been found")}) | ||
| public ResponseEntity<String> getLogicalControlsResult(@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid, | ||
| @Parameter(description = "rootNetwork Uuid") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid, | ||
| @Parameter(description = "node Uuid") @PathVariable("nodeUuid") UUID nodeUuid) { | ||
| String result = rootNetworkNodeInfoService.getLogicalControlsResult(nodeUuid, rootNetworkUuid); | ||
| return result != null ? ResponseEntity.ok().body(result) : | ||
| ResponseEntity.noContent().build(); | ||
| } | ||
|
|
||
| @GetMapping(value = "/status") | ||
| @Operation(summary = "Get the logical controls status on study") | ||
| @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The logical controls status"), | ||
| @ApiResponse(responseCode = "204", description = "No logical controls has been done yet"), | ||
| @ApiResponse(responseCode = "404", description = "The logical controls status has not been found")}) | ||
| public ResponseEntity<String> getLogicalControlsStatus(@Parameter(description = "Study UUID") @PathVariable("studyUuid") UUID studyUuid, | ||
| @PathVariable("rootNetworkUuid") UUID rootNetworkUuid, | ||
| @Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) { | ||
| String status = rootNetworkNodeInfoService.getLogicalControlsStatus(nodeUuid, rootNetworkUuid); | ||
| return status != null ? ResponseEntity.ok().body(status) : ResponseEntity.noContent().build(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.