Skip to content
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

taskrunner fix #3882

Merged
merged 2 commits into from
Jun 14, 2024
Merged
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
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 @@ -7,10 +7,10 @@
# These deps are installed only for use during local development

# Install Python
RUN apt-get update && apt-get install -y --no-install-recommends \

Check failure on line 10 in packages/funman/Dockerfile

View workflow job for this annotation

GitHub Actions / Lint Docker Files / Lint Docker Files

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && apt-get install -y --no-install-recommends \

Check failure on line 13 in packages/funman/Dockerfile

View workflow job for this annotation

GitHub Actions / Lint Docker Files / Lint Docker Files

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
python3.10 \
wget \
git \
Expand Down Expand Up @@ -42,12 +42,12 @@
# ------------------------------------------------------------------------------

# Funman-base, should contain dreal4, ibex, and python dependencies
FROM ghcr.io/darpa-askem/funman-base:latest

Check failure on line 45 in packages/funman/Dockerfile

View workflow job for this annotation

GitHub Actions / Lint Docker Files / Lint Docker Files

DL3007 warning: Using latest is prone to errors if the image will ever update. Pin the version explicitly to a release tag

WORKDIR /

# Install OpenJDK JRE and wget
RUN apt-get update && \

Check failure on line 50 in packages/funman/Dockerfile

View workflow job for this annotation

GitHub Actions / Lint Docker Files / Lint Docker Files

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
apt-get install -y --no-install-recommends \
openjdk-17-jre-headless && \
rm -rf /var/lib/apt/lists/*
Expand All @@ -63,7 +63,6 @@
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 @@ -7,10 +7,10 @@
# These deps are installed only for use during local development

# Install Python
RUN apt-get update && apt-get install -y --no-install-recommends \

Check failure on line 10 in packages/gollm/Dockerfile

View workflow job for this annotation

GitHub Actions / Lint Docker Files / Lint Docker Files

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && apt-get install -y --no-install-recommends \

Check failure on line 13 in packages/gollm/Dockerfile

View workflow job for this annotation

GitHub Actions / Lint Docker Files / Lint Docker Files

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
python3.10 \
wget \
python3-pip && \
Expand Down Expand Up @@ -46,7 +46,7 @@
WORKDIR /

# Install OpenJDK JRE and wget
RUN apt-get update && \

Check failure on line 49 in packages/gollm/Dockerfile

View workflow job for this annotation

GitHub Actions / Lint Docker Files / Lint Docker Files

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
apt-get install -y --no-install-recommends \
openjdk-17-jre-headless && \
rm -rf /var/lib/apt/lists/*
Expand All @@ -60,7 +60,6 @@
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 @@ -7,10 +7,10 @@
# These deps are installed only for use during local development

# Install Python
RUN apt-get update && apt-get install -y --no-install-recommends \

Check failure on line 10 in packages/mira/Dockerfile

View workflow job for this annotation

GitHub Actions / Lint Docker Files / Lint Docker Files

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && apt-get install -y --no-install-recommends \

Check failure on line 13 in packages/mira/Dockerfile

View workflow job for this annotation

GitHub Actions / Lint Docker Files / Lint Docker Files

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
python3.10 \
wget \
python3-pip && \
Expand All @@ -25,7 +25,7 @@
rm mira.tar.gz && \
mv -v mira-* mira
WORKDIR /mira
RUN pip install --no-cache-dir .[sbml,biomodels]

Check failure on line 28 in packages/mira/Dockerfile

View workflow job for this annotation

GitHub Actions / Lint Docker Files / Lint Docker Files

SC2102 info: Ranges can only match single chars (mentioned due to duplicates).

#^^^^^^^^^^^^^^^^^^^^
######################
Expand Down Expand Up @@ -58,7 +58,6 @@
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
Loading