Skip to content
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
26 changes: 26 additions & 0 deletions biosimulators/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.9-slim-bullseye

# Install OpenJDK 11
RUN apt-get update && \
apt-get install -y --no-install-recommends openjdk-11-jre-headless && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy and install Python dependencies
COPY biosimulators/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the dependencies folder and the compiled Java engine
COPY target/dependency /app/lib
COPY target/sbscl-2.1.1.jar /app/sbscl.jar

# Copy the Python CLI and Entrypoint script
COPY biosimulators/main.py .
COPY biosimulators/entrypoint.sh .

# Make the entrypoint script executable
RUN chmod +x /app/entrypoint.sh

ENTRYPOINT ["/app/entrypoint.sh"]
11 changes: 11 additions & 0 deletions biosimulators/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Start the Java Gateway Server in the background.
# We include the main jar AND all dependency jars in the classpath.
java -cp "/app/sbscl.jar:/app/lib/*" org.simulator.biosimulators.BioSimulatorsGateway &

# Give the Java server 2 seconds to initialize
sleep 2

# Execute the Python CLI, passing along any arguments provided to Docker
python /app/main.py "$@"
27 changes: 27 additions & 0 deletions biosimulators/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import argparse
from py4j.java_gateway import JavaGateway
from biosimulators_utils.combine.exec import exec_sedml_docs_in_archive

def exec_sed_doc(doc, working_dir, base_out_path, rel_out_path=None, apply_xml_model_changes=False, log=None, indent=0, out_dir=None, config=None):
pass

def exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None):
gateway = JavaGateway()
sbscl_engine = gateway.entry_point
return {}, log

def main():
parser = argparse.ArgumentParser(description="SBSCL BioSimulators interface")
parser.add_argument("-i", "--archive", required=True, type=str)
parser.add_argument("-o", "--out-dir", required=True, type=str)
args = parser.parse_args()

exec_sedml_docs_in_archive(
exec_sed_doc,
args.archive,
args.out_dir,
apply_xml_model_changes=True,
)

if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions biosimulators/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
biosimulators-utils
py4j
numpy
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sf.py4j</groupId>
<artifactId>py4j</artifactId>
<version>0.10.9.7</version>
</dependency>
</dependencies>


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.simulator.biosimulators;

import py4j.GatewayServer;

public class BioSimulatorsGateway {

public BioSimulatorsGateway() {
}

public static void main(String[] args) {
BioSimulatorsGateway app = new BioSimulatorsGateway();
// Starts the server on the default port (25333)
GatewayServer server = new GatewayServer(app);
server.start();
System.out.println("SBSCL Gateway Server Started");
}
}