-
Notifications
You must be signed in to change notification settings - Fork 0
[Dynamic Margin Calculation] Base configuration #1
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
thangqp
wants to merge
8
commits into
main
Choose a base branch
from
dmc_base_configuration
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
8 commits
Select commit
Hold shift + click to select a range
f692e44
add github actions
thangqp b05ba83
Dynamic Margin Calculation (DMC) - First implementation
thangqp badc468
Update version 2.9.0 dynawo
thangqp 914c333
gridsuite-dependencies 42.0.0
thangqp cb58f05
switch to computation lib
thangqp 98414c4
add unit test
thangqp fa113a0
Update dependencies
thangqp c935f9f
Upgrade CI version to have a nicer git describe on main
thangqp 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
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,19 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
uses: powsybl/github-ci/.github/workflows/build-backend-app-generic.yml@aaae75875296657028f2805e7a3fbdb1418b8b95 | ||
with: | ||
dockerImage: docker.io/gridsuite/dynamic-margin-calculation-server | ||
dockerUsername: gridsuiteci | ||
eventType: dynamic_margin_calculation_server_updated | ||
secrets: | ||
sonar-token: ${{ secrets.SONAR_TOKEN }} | ||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
repo-token: ${{ secrets.REPO_ACCESS_TOKEN }} |
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,22 @@ | ||
name: Patch | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
releaseVersion: | ||
description: version to patch (vX.X) | ||
required: true | ||
|
||
jobs: | ||
run-patch: | ||
uses: powsybl/github-ci/.github/workflows/patch-backend-app-generic.yml@aaae75875296657028f2805e7a3fbdb1418b8b95 | ||
with: | ||
githubappId: ${{ vars.GRIDSUITE_ACTIONS_APPID }} | ||
dockerImage: docker.io/gridsuite/dynamic-margin-calculation-server | ||
dockerUsername: gridsuiteci | ||
releaseVersion: ${{ github.event.inputs.releaseVersion }} | ||
secrets: | ||
VERSIONBUMP_GHAPP_PRIVATE_KEY: ${{ secrets.VERSIONBUMP_GHAPP_PRIVATE_KEY }} | ||
sonar-token: ${{ secrets.SONAR_TOKEN }} | ||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
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,25 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
releaseVersion: | ||
description: Release version (vX.X) | ||
required: true | ||
gitReference: | ||
description: SHA of the commit from where to release or branch name | ||
required: true | ||
|
||
jobs: | ||
run-release: | ||
uses: powsybl/github-ci/.github/workflows/release-backend-app-generic.yml@aaae75875296657028f2805e7a3fbdb1418b8b95 | ||
with: | ||
githubappId: ${{ vars.GRIDSUITE_ACTIONS_APPID }} | ||
dockerImage: docker.io/gridsuite/dynamic-margin-calculation-server | ||
dockerUsername: gridsuiteci | ||
releaseVersion: ${{ github.event.inputs.releaseVersion }} | ||
gitReference: ${{ github.event.inputs.gitReference }} | ||
secrets: | ||
VERSIONBUMP_GHAPP_PRIVATE_KEY: ${{ secrets.VERSIONBUMP_GHAPP_PRIVATE_KEY }} | ||
sonar-token: ${{ secrets.SONAR_TOKEN }} | ||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} |
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 @@ | ||
import target/configs/powsybl-build-tools.jar!powsybl-build-tools/lombok.config |
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
19 changes: 19 additions & 0 deletions
19
src/main/java/org/gridsuite/dynamicmargincalculation/server/DynamicMarginCalculationApi.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,19 @@ | ||
/** | ||
* Copyright (c) 2025, 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.dynamicmargincalculation.server; | ||
|
||
/** | ||
* @author Thang PHAM <quyet-thang.pham at rte-france.com> | ||
*/ | ||
public final class DynamicMarginCalculationApi { | ||
|
||
private DynamicMarginCalculationApi() { | ||
} | ||
|
||
public static final String API_VERSION = "v1"; | ||
} |
23 changes: 23 additions & 0 deletions
23
...va/org/gridsuite/dynamicmargincalculation/server/DynamicMarginCalculationApplication.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,23 @@ | ||
/** | ||
* Copyright (c) 2025, 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.dynamicmargincalculation.server; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
/** | ||
* @author Thang PHAM <quyet-thang.pham at rte-france.com> | ||
*/ | ||
@SuppressWarnings("checkstyle:HideUtilityClassConstructor") | ||
@SpringBootApplication | ||
public class DynamicMarginCalculationApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(DynamicMarginCalculationApplication.class, args); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...java/org/gridsuite/dynamicmargincalculation/server/DynamicMarginCalculationException.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,27 @@ | ||
/** | ||
* Copyright (c) 2025, 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.dynamicmargincalculation.server; | ||
|
||
import lombok.Getter; | ||
|
||
/** | ||
* @author Thang PHAM <quyet-thang.pham at rte-france.com> | ||
*/ | ||
@Getter | ||
public class DynamicMarginCalculationException extends RuntimeException { | ||
|
||
public enum Type { | ||
RESULT_UUID_NOT_FOUND, | ||
} | ||
|
||
private final Type type; | ||
|
||
public DynamicMarginCalculationException(Type type, String message) { | ||
super(message); | ||
this.type = type; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...ava/org/gridsuite/dynamicmargincalculation/server/RestResponseEntityExceptionHandler.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,37 @@ | ||
/** | ||
* Copyright (c) 2025, 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.dynamicmargincalculation.server; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
/** | ||
* @author Thang PHAM <quyet-thang.pham at rte-france.com> | ||
*/ | ||
@ControllerAdvice | ||
public class RestResponseEntityExceptionHandler { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(RestResponseEntityExceptionHandler.class); | ||
|
||
@ExceptionHandler(DynamicMarginCalculationException.class) | ||
protected ResponseEntity<Object> handleDynamicSecurityAnalysisException(DynamicMarginCalculationException exception) { | ||
if (LOGGER.isErrorEnabled()) { | ||
LOGGER.error(exception.getMessage(), exception); | ||
} | ||
|
||
DynamicMarginCalculationException.Type type = exception.getType(); | ||
return switch (type) { | ||
case RESULT_UUID_NOT_FOUND | ||
-> ResponseEntity.status(HttpStatus.NOT_FOUND).body(exception.getMessage()); | ||
}; | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/org/gridsuite/dynamicmargincalculation/server/config/SwaggerConfig.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,29 @@ | ||
/* | ||
* Copyright (c) 2025, 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.dynamicmargincalculation.server.config; | ||
|
||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import org.gridsuite.dynamicmargincalculation.server.DynamicMarginCalculationApi; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* @author Thang PHAM <quyet-thang.pham at rte-france.com> | ||
*/ | ||
@Configuration | ||
public class SwaggerConfig { | ||
|
||
@Bean | ||
public OpenAPI createOpenApi() { | ||
return new OpenAPI() | ||
.info(new Info() | ||
.title("Dynamic Margin Calculation Server API") | ||
.description("This is the documentation of the Dynamic-Margin-Calculation REST API") | ||
.version(DynamicMarginCalculationApi.API_VERSION)); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
.../java/org/gridsuite/dynamicmargincalculation/server/controller/SupervisionController.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,40 @@ | ||
/** | ||
* Copyright (c) 2025, 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.dynamicmargincalculation.server.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
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.dynamicmargincalculation.server.DynamicMarginCalculationApi; | ||
import org.gridsuite.dynamicmargincalculation.server.service.SupervisionService; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @author Thang PHAM <quyet-thang.pham at rte-france.com> | ||
*/ | ||
@RestController | ||
@RequestMapping(value = "/" + DynamicMarginCalculationApi.API_VERSION + "/supervision") | ||
@Tag(name = "Dynamic margin calculation server - Supervision") | ||
public class SupervisionController { | ||
private final SupervisionService supervisionService; | ||
|
||
public SupervisionController(SupervisionService supervisionService) { | ||
this.supervisionService = supervisionService; | ||
} | ||
|
||
@GetMapping(value = "/results-count") | ||
@Operation(summary = "Get results count") | ||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The count of all results")}) | ||
public ResponseEntity<Integer> getResultsCount() { | ||
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(supervisionService.getResultsCount()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ava/org/gridsuite/dynamicmargincalculation/server/dto/DynamicMarginCalculationStatus.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,18 @@ | ||
/* | ||
* Copyright (c) 2025, 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.dynamicmargincalculation.server.dto; | ||
|
||
/** | ||
* @author Thang PHAM <quyet-thang.pham at rte-france.com> | ||
*/ | ||
public enum DynamicMarginCalculationStatus { | ||
NOT_DONE, | ||
RUNNING, | ||
SUCCEED, | ||
FAILED | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.