Skip to content

Commit

Permalink
Adjusting README
Browse files Browse the repository at this point in the history
  • Loading branch information
horakivo committed Feb 14, 2025
1 parent ac8f326 commit dfaa139
Showing 1 changed file with 40 additions and 17 deletions.
57 changes: 40 additions & 17 deletions graalpy/graalpy-apache-arrow-guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ Add the required dependencies for GraalPy and JArrow in the dependency section o
### 3.1 GraalPy dependencies
`pom.xml`
```xml
<dependency>
<groupId>org.graalvm.python</groupId>
<artifactId>python-community</artifactId> <!---->
<version>${python.version}</version>
<type>pom</type> <!---->
</dependency>
<dependency>
<groupId>org.graalvm.python</groupId>
<artifactId>python-embedding</artifactId> <!---->
<version>${python.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.python</groupId>
<artifactId>python-community</artifactId> <!---->
<version>${python.version}</version>
<type>pom</type> <!---->
</dependency>
<dependency>
<groupId>org.graalvm.python</groupId>
<artifactId>python-embedding</artifactId> <!---->
<version>${python.version}</version>
</dependency>
```

or

`build.gradle`
```
```groovy
implementation "org.graalvm.python:python-community:$pythonVersion" // ①
implementation "org.graalvm.python:python-embedding:$pythonVersion" // ③
```
Expand Down Expand Up @@ -95,10 +95,6 @@ There is also another option `arrow-memory-netty`. You can read more about Apach
<package>pandas</package> <!---->
<package>pyarrow</package> <!---->
</packages>
<pythonHome>
<includes></includes>
<excludes>.*</excludes>
</pythonHome>
</configuration>
<goals>
<goal>process-graalpy-resources</goal>
Expand Down Expand Up @@ -212,6 +208,8 @@ Bind the Java interface to the Python module.
`Main.java`

```java
private static DataAnalysisPyModule dataAnalysisPyModule;

public static void initDataAnalysisPyModule(Context context) {
Value value = context.eval("python", "import data_analysis; data_analysis");
dataAnalysisPyModule = value.as(DataAnalysisPyModule.class);
Expand Down Expand Up @@ -252,6 +250,11 @@ Finally, use the setup in your main method:

`Main.java`
```java
private static final String PYTHON_URL = "https://www.graalvm.org/compatibility/module_results/python-module-testing-v241.csv";
private static final String JAVASCRIPT_URL = "https://www.graalvm.org/compatibility/module_results/js-module-testing.csv";
private static final Integer PASSING_RATE_COLUMN_INDEX = 3;


public static void main(String[] args) throws IOException, InterruptedException {
try (Context context = initContext();
BufferAllocator allocator = new RootAllocator();
Expand Down Expand Up @@ -285,7 +288,27 @@ or
./gradlew build
```

To run the application:
To run the application using Maven, first define `exec` plugin:

`pom.xml`
```xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.Main</mainClass>
</configuration>
</plugin>
```
Run the application using:
```bash
./mvnw exec:java -Dexec.mainClass="com.example.Main"
```
Expand Down

0 comments on commit dfaa139

Please sign in to comment.