Skip to content

Commit

Permalink
taskrunner fix (#3882)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbirk authored Jun 14, 2024
1 parent 8a45c9b commit daecbc2
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 36 deletions.
15 changes: 0 additions & 15 deletions containers/scripts/docker-compose-taskrunner.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
---
services:
taskrunner-dev-builder:
build:
context: ../..
dockerfile: ./packages/taskrunner/Dockerfile
target: taskrunner_dev_builder
container_name: taskrunner-dev-builder
volumes:
- ../../packages/taskrunner:/taskrunner

gollm-taskrunner:
build:
context: ../..
Expand All @@ -24,8 +15,6 @@ services:
TERARIUM_TASKRUNNER_REQUEST_TYPE: "gollm"
OPENAI_API_KEY: "${secret_gollm_openai_key}"
depends_on:
taskrunner-dev-builder:
condition: service_started
rabbitmq:
condition: service_healthy
extra_hosts:
Expand All @@ -49,8 +38,6 @@ services:
TERARIUM_MQ_USERNAME: "terarium"
TERARIUM_TASKRUNNER_REQUEST_TYPE: "mira"
depends_on:
taskrunner-dev-builder:
condition: service_started
rabbitmq:
condition: service_healthy
extra_hosts:
Expand All @@ -74,8 +61,6 @@ services:
TERARIUM_MQ_USERNAME: "terarium"
TERARIUM_TASKRUNNER_REQUEST_TYPE: "funman"
depends_on:
taskrunner-dev-builder:
condition: service_started
rabbitmq:
condition: service_healthy
extra_hosts:
Expand Down
1 change: 0 additions & 1 deletion packages/funman/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ RUN pip install --no-cache-dir . && \
pip install --no-cache-dir auxiliary_packages/funman_demo

# Install taskrunner
COPY ./packages/taskrunner/src/test/resources/echo.py /echo.py
COPY ./packages/taskrunner/setup.py /taskrunner/setup.py
COPY ./packages/taskrunner/taskrunner.py /taskrunner/taskrunner.py
WORKDIR /taskrunner
Expand Down
6 changes: 5 additions & 1 deletion packages/funman/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ pip install -e .
# run it
echo "Running taskrunner"
cd /taskrunner
./gradlew --project-cache-dir /tmp/.gradle/$$ bootRun
pip install -e .

BUILD_DIR=/taskrunner-build-funman
mkdir -p $BUILD_DIR
./gradlew --project-cache-dir /tmp/.gradle/$$ -PcustomBuildDir=$BUILD_DIR bootRun
1 change: 0 additions & 1 deletion packages/gollm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ WORKDIR /GoLLM
RUN pip install --no-cache-dir .

# Install taskrunner
COPY ./packages/taskrunner/src/test/resources/echo.py /echo.py
COPY ./packages/taskrunner/setup.py /taskrunner/setup.py
COPY ./packages/taskrunner/taskrunner.py /taskrunner/taskrunner.py
WORKDIR /taskrunner
Expand Down
6 changes: 5 additions & 1 deletion packages/gollm/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ pip install -e .
# run it
echo "Running taskrunner"
cd /taskrunner
./gradlew --project-cache-dir /tmp/.gradle/$$ bootRun
pip install -e .

BUILD_DIR=/taskrunner-build-mira
mkdir -p $BUILD_DIR
./gradlew --project-cache-dir /tmp/.gradle/$$ -PcustomBuildDir=$BUILD_DIR bootRun
1 change: 0 additions & 1 deletion packages/mira/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ WORKDIR /mira
RUN pip install --no-cache-dir .[sbml,biomodels]

# Install taskrunner
COPY ./packages/taskrunner/src/test/resources/echo.py /echo.py
COPY ./packages/taskrunner/setup.py /taskrunner/setup.py
COPY ./packages/taskrunner/taskrunner.py /taskrunner/taskrunner.py
WORKDIR /taskrunner
Expand Down
6 changes: 5 additions & 1 deletion packages/mira/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ pip install -e .
# run it
echo "Running taskrunner"
cd /taskrunner
./gradlew --project-cache-dir /tmp/.gradle/$$ bootRun
pip install -e .

BUILD_DIR=/taskrunner-build-gollm
mkdir -p $BUILD_DIR
./gradlew --project-cache-dir /tmp/.gradle/$$ -PcustomBuildDir=$BUILD_DIR bootRun
8 changes: 0 additions & 8 deletions packages/taskrunner/Dockerfile

This file was deleted.

6 changes: 2 additions & 4 deletions packages/taskrunner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ Use the following as a reference for creating a taskrunner image:

# Local Development:

Everything is setup in the `docker-compose-taskrunner.yml` for local development. The docker-compose entries use the *builder* image and volume mounts the taskrunner directories into the running container. Both the java `taskrunner` package and the python repos will automatically pickup and local changes and hotswap accordingly.
Everything is setup in the `docker-compose-taskrunner.yml` for local development. The docker-compose entries use the *builder* image and volume mounts the taskrunner directories into the running container. The python repos will automatically pickup and local changes and hotswap accordingly.

This also runs an auxiliary container called `taskrunner-dev-builer` which re-builds the java code on changes.

**NOTE: When starting these local images, it takes about a minute or so to build and start the java taskrunner.**
**NOTE: When starting these local images, it takes about a minute or so to setup the python code and start the java taskrunner.**

# Building docker images:

Expand Down
2 changes: 2 additions & 0 deletions packages/taskrunner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ group = 'software.uncharted'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = '17'

buildDir = project.hasProperty('customBuildDir') ? project.getProperty('customBuildDir') : buildDir

configurations {
compileOnly {
extendsFrom annotationProcessor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@PropertySource("classpath:application.properties")
public class TaskRunnerApplication {

public static void main(String[] args) {
public static void main(final String[] args) {
SpringApplication.run(TaskRunnerApplication.class, args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class Task {
private StringBuilder stdout = new StringBuilder();
private StringBuilder stderr = new StringBuilder();

private final String ECHO_SCRIPT_PATH = getClass().getResource("/echo.py").getPath();

private int PROCESS_KILL_TIMEOUT_SECONDS = 10;

private int BYTES_PER_READ = 1024 * 1024;
Expand Down Expand Up @@ -82,13 +84,27 @@ private String getExtension(final String input) {
}

private void setup() throws IOException, InterruptedException {
if (getExtension(req.getScript()).equals("py")) {
if (req.getScript().equals("echo.py")) {

// raw python file, execute it through the runtime
final boolean fileExists = Files.exists(Paths.get(ECHO_SCRIPT_PATH));
if (!fileExists) {
throw new FileNotFoundException("Script file: " + ECHO_SCRIPT_PATH + " not found");
}
processBuilder = new ProcessBuilder("python3", ECHO_SCRIPT_PATH, "--id", req.getId().toString(),
"--input_pipe",
inputPipeName,
"--output_pipe",
outputPipeName,
"--progress_pipe",
progressPipeName);
} else if (getExtension(req.getScript()).equals("py")) {
// raw python file, execute it through the runtime
final boolean fileExists = Files.exists(Paths.get(req.getScript()));
if (!fileExists) {
throw new FileNotFoundException("Script file: " + req.getScript() + " not found");
}
processBuilder = new ProcessBuilder("python", req.getScript(), "--id", req.getId().toString(),
processBuilder = new ProcessBuilder("python3", req.getScript(), "--id", req.getId().toString(),
"--input_pipe",
inputPipeName,
"--output_pipe",
Expand Down

0 comments on commit daecbc2

Please sign in to comment.