Skip to content

Commit

Permalink
Use Oracle GraalVM (#615)
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
  • Loading branch information
geofjamg authored Jun 20, 2023
1 parent 6a1fa48 commit e56f8b1
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 47 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/dev-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ jobs:
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
version: '22.2.0'
java-version: '11'
components: 'native-image'
java-version: '17'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout sources
Expand Down Expand Up @@ -98,7 +97,7 @@ jobs:
}
- {
name: windows,
os: windows-2019,
os: windows-2022,
}
python:
- {
Expand All @@ -110,9 +109,8 @@ jobs:
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
version: '22.2.0'
java-version: '11'
components: 'native-image'
java-version: '17'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout sources
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ jobs:
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
version: '22.2.0'
java-version: '11'
components: 'native-image'
java-version: '17'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout sources
Expand Down Expand Up @@ -128,7 +127,7 @@ jobs:
}
- {
name: windows,
os: windows-2019,
os: windows-2022,
}
python:
- {
Expand Down Expand Up @@ -156,9 +155,8 @@ jobs:
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
version: '22.2.0'
java-version: '11'
components: 'native-image'
java-version: '17'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout sources
Expand Down
13 changes: 9 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# IntelliJ
.idea
.idea/
*.iml

# VSCode
.vscode

# Maven
target/

# Byte-compiled / optimized
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -47,9 +53,8 @@ build/

#build
build/*
.idea/*
*.iml
.vscode

# PyTest
tests/_trial_temp/*

*.orig
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[![PyPI Latest Release](https://img.shields.io/pypi/v/pypowsybl.svg)](https://pypi.org/project/pypowsybl/)
[![Documentation Status](https://readthedocs.org/projects/pypowsybl/badge/?version=latest)](https://pypowsybl.readthedocs.io/en/latest/?badge=latest)
[![MPL-2.0 License](https://img.shields.io/badge/license-MPL_2.0-blue.svg)](https://www.mozilla.org/en-US/MPL/2.0/)
[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/powsybl)
[![Slack](https://img.shields.io/badge/slack-powsybl-blueviolet.svg?logo=slack)](https://join.slack.com/t/powsybl/shared_invite/zt-rzvbuzjk-nxi0boim1RKPS5PjieI0rA)

The PyPowSyBl project gives access PowSyBl Java framework to Python developers. This Python integration relies on
Expand Down Expand Up @@ -92,7 +91,7 @@ Requirements:
- C++11 compiler
- Python >= 3.7 for Linux, Windows and MacOS amd64
- Python >= 3.8 for MacOS arm64
- [GraalVM 22.2.0](https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-22.2.0) with [native image](https://www.graalvm.org/reference-manual/native-image/#install-native-image)
- [Oracle GraalVM Java 17](https://www.graalvm.org/downloads/)

To build from sources and install PyPowSyBl package:

Expand Down
8 changes: 7 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,20 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(NATIVE_IMAGE_BUILD_OPTIONS "-H:GenerateDebugInfo=1" "-Ob")
endif()

# as of GraalVM 23.0.0 G1 GC is only supported on Linux ADM64
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND ${OS_BITS} STREQUAL "64")
set(NATIVE_IMAGE_GC "G1")
else()
set(NATIVE_IMAGE_GC "serial")
endif()

# as GraalVm does not follow same library naming convention (lib prefix is missing on Linux and MacOS) we need to rename
# it in the install command step
ExternalProject_Add(native-image
DEPENDS mvn
SOURCE_DIR ${PYPOWSYBL_JAVA_BIN_DIR}
DOWNLOAD_COMMAND ""
PATCH_COMMAND $ENV{JAVA_HOME}/bin/native-image ${NATIVE_IMAGE_BUILD_OPTIONS} --class-path ${PYPOWSYBL_JAVA_SRC_DIR}/target/pypowsybl-java.jar${EXTRA_JARS} --no-fallback --shared -H:Name=pypowsybl-java -H:CLibraryPath=${CMAKE_CURRENT_SOURCE_DIR}/src
PATCH_COMMAND $ENV{JAVA_HOME}/bin/native-image ${NATIVE_IMAGE_BUILD_OPTIONS} --class-path ${PYPOWSYBL_JAVA_SRC_DIR}/target/pypowsybl-java.jar${EXTRA_JARS} --no-fallback --shared --gc=${NATIVE_IMAGE_GC} -H:Name=pypowsybl-java -H:CLibraryPath=${CMAKE_CURRENT_SOURCE_DIR}/src
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${PYPOWSYBL_JAVA_BIN_DIR}/${PYPOWSYBL_JAVA_OLD_LIB} ${PYPOWSYBL_JAVA_BIN_DIR}/${PYPOWSYBL_JAVA_LIB} ${NATIVE_IMAGE_INSTALL_EXTRA_COMMAND}
Expand Down
1 change: 0 additions & 1 deletion java/.gitignore

This file was deleted.

21 changes: 2 additions & 19 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-parent</artifactId>
<version>4</version>
<version>11</version>
<relativePath/>
</parent>

Expand Down Expand Up @@ -61,19 +61,12 @@
<version>0.24.0-SNAPSHOT</version>

<properties>
<java.version>11</java.version>

<assertj.version>3.11.0</assertj.version>
<commons-collections4.version>4.4</commons-collections4.version>
<graalvm.version>22.2.0</graalvm.version>
<graalvm.version>23.0.0</graalvm.version>
<janino.version>3.1.0</janino.version>
<junit-jupiter.version>5.5.2</junit-jupiter.version>
<logback.version>1.2.9</logback.version>
<mapdb.version>3.0.8</mapdb.version>
<slf4j.version>1.7.30</slf4j.version>
<maven-dependency-plugin.version>3.2.0</maven-dependency-plugin.version>
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
<maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>

This comment has been minimized.

Copy link
@EtienneLt

EtienneLt Jul 25, 2023

Contributor

@geofjamg why did you remove that, it is needed for release profil, is there any alternative I am missing ?

This comment has been minimized.

Copy link
@EtienneLt

EtienneLt Jul 25, 2023

Contributor

is it replaced by <maven-dependency-plugin.version>3.2.0</maven-dependency-plugin.version> ?

This comment has been minimized.

Copy link
@geofjamg

geofjamg Jul 25, 2023

Author Member

All these versions were already setup in the powsybl parent pom which this pom is inheriting

This comment has been minimized.

Copy link
@EtienneLt

EtienneLt Jul 26, 2023

Contributor

image

This comment has been minimized.

Copy link
@EtienneLt

EtienneLt Jul 26, 2023

Contributor

when using mvn clean package -Prelease

This comment has been minimized.

Copy link
@EtienneLt

EtienneLt Jul 26, 2023

Contributor

ok I found the error it needs to remove ${project.parent.maven-shade-plugin.version}

<powsybl-dependencies.version>2023.2.1</powsybl-dependencies.version>
</properties>

Expand All @@ -82,7 +75,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>

This comment has been minimized.

Copy link
@EtienneLt

EtienneLt Jul 26, 2023

Contributor

ok this was rewritten in the main

<executions>
<!-- Run shade goal on package phase -->
<execution>
Expand Down Expand Up @@ -136,11 +128,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -184,13 +171,11 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
<scope>compile</scope>
</dependency>
<!-- workaround for https://github.com/oracle/graal/issues/1943 -->
Expand Down Expand Up @@ -283,7 +268,6 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>

Expand Down Expand Up @@ -384,7 +368,6 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Objects;

public class LimitsDataframeAdderKey {
private final String elementId;
private final String elementId;
private final String side;
private final String limitType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private ConnectablePositionFeederData getOrThrow(Network network, UpdatingDatafr
public NetworkDataframeMapper createMapper() {
return NetworkDataframeMapperBuilder.ofStream(NetworkUtil::getFeeders, this::getOrThrow)
.stringsIndex("id", ConnectablePositionFeederData::getId)
.strings("side", feeder -> feeder.getSide() == null ? null : feeder.getSide().toString())
.strings("side", feeder -> feeder.getSide() == null ? null : feeder.getSide().toString())
.ints("order", ConnectablePositionFeederData::getOrder)
.strings("feeder_name", ConnectablePositionFeederData::getFeederName)
.strings("direction", ConnectablePositionFeederData::getDirection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public ControlUnitWithZone getItem(Network network, UpdatingDataframe updatingDa
String id = updatingDataframe.getStringValue("unit_id", lineNumber).orElse(null);
ControlZone zone = ext.getControlZones().stream()
.filter(controlZone -> {
return controlZone.getControlUnits().stream()
return controlZone.getControlUnits().stream()
.anyMatch(controlUnit -> {
return controlUnit.getId().equals(id);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static LoadFlowParameters convertLoadFlowParameters(boolean dc,
* Creates loadflow parameters from its C representation, for the given loadflow provider.
* The provider is used to instantiate implementation-specific parameters.
*/
public static LoadFlowParameters createLoadFlowParameters(boolean dc, LoadFlowParametersPointer cParameters,
public static LoadFlowParameters createLoadFlowParameters(boolean dc, LoadFlowParametersPointer cParameters,
LoadFlowProvider provider) {
LoadFlowParameters parameters = convertLoadFlowParameters(dc, cParameters);
Map<String, String> specificParametersProperties = getSpecificParameters(cParameters);
Expand All @@ -102,7 +102,7 @@ public static LoadFlowParameters createLoadFlowParameters(boolean dc, LoadFlowP
return parameters;
}

public static LoadFlowParameters createLoadFlowParameters(boolean dc, LoadFlowParametersPointer cParameters,
public static LoadFlowParameters createLoadFlowParameters(boolean dc, LoadFlowParametersPointer cParameters,
String providerName) {
return createLoadFlowParameters(dc, cParameters, getLoadFlowProvider(providerName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private static SecurityAnalysisProvider getProvider(String name) {
@CEntryPoint(name = "runSecurityAnalysis")
public static ObjectHandle runSecurityAnalysis(IsolateThread thread, ObjectHandle securityAnalysisContextHandle,
ObjectHandle networkHandle, SecurityAnalysisParametersPointer securityAnalysisParametersPointer,
CCharPointer providerName, boolean dc, ObjectHandle reporterHandle,
CCharPointer providerName, boolean dc, ObjectHandle reporterHandle,
PyPowsyblApiHeader.ExceptionHandlerPointer exceptionHandlerPtr) {
return doCatch(exceptionHandlerPtr, () -> {
SecurityAnalysisContext analysisContext = ObjectHandles.getGlobal().get(securityAnalysisContextHandle);
Expand Down

0 comments on commit e56f8b1

Please sign in to comment.