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
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ RUN echo "Server" > /app/README.md \
&& chmod +x /app/entrypoint.sh
#
RUN conda update -n base -c conda-forge conda \
&& conda env create -f /app/environment.yml -y \
&& conda run -n server poetry self update \
&& echo "conda activate server" >> /.bashrc \
&& conda run -n server pip install --upgrade pip
# && conda run -n server pip install --no-cache-dir git+https://github.com/vivarium-collective/process-bigraph.git@main
&& conda env create -f /app/env.yml -y \
&& conda update -n compose-server numpy -y \
&& pip install -e .


ENTRYPOINT ["/bin/bash"]

Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,22 @@
![Worker Deployment](https://github.com/biosimulators/compose-server/actions/workflows/deploy-worker.yml/badge.svg)

# BioCompose Server

## *FOR DEVS*:

### _Generate gRPC service stubs:_
```bash
python shared/parse_proto.py
```

### _Generate OpenAPI spec yml:_
```bash
python client/openapi_spec.py
```

### _Apply overlay changes_:
```bash
cd kustomize \
&& kubectl kustomize overlays/compose | kubectl apply -f - \
&& cd ..
```
55 changes: 55 additions & 0 deletions app/DataService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
class VivariumService {
constructor(root= 'http://127.0.0.1:3001') {
this.root = root;
this.testId = 'test';
}

formatUrl(root, duration, id) {
return `${root}/run-vivarium?duration=${duration}&vivarium_id=${id}`;
}

async fetchStream(url) {
const response = await fetch(url);
const reader = response.body.getReader();
const decoder = new TextDecoder();

let jsonData = "";
let isFirstChunk = true;

while (true) {
const {done, value} = await reader.read();
if (done) {
console.log("Stream finished.");
break;
}

jsonData += decoder.decode(value);

try {
if (isFirstChunk) {
jsonData = jsonData.replace('{"updates": [', "["); // ✅ Handle initial chunk
isFirstChunk = false;
}

if (jsonData.endsWith("]}")) {
const parsedData = JSON.parse(jsonData);
console.log("Final JSON:", parsedData);
break;
} else {
console.log("Streaming JSON chunk received:", jsonData);
}
} catch (e) {
console.log("Waiting for more JSON data...");
}
}
}

submitRequest(duration, id) {
const url = this.formatUrl(this.root, duration, id);
return this.fetchStream(url);
}

sendTestRequest(duration) {
return this.submitRequest(duration, this.testId);
}
}
12 changes: 12 additions & 0 deletions assets/deployment/compose.envoy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3"
services:
envoy:
image: envoyproxy/envoy:v1.21.0
ports:
- "9901:9901"
volumes:
- ./envoy.yaml:/etc/envoy/envoy.yaml
grpc_server:
image: my_grpc_service
ports:
- "50051:50051"
60 changes: 60 additions & 0 deletions assets/deployment/envoy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
static_resources:
listeners:
- name: grpc_listener
address:
socket_address:
address: 0.0.0.0
port_value: 9901
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: AUTO
stat_prefix: grpc_proxy
route_config:
name: local_route
virtual_hosts:
- name: grpc_services
domains: ["*"]
routes:
- match: { prefix: "/" }
route:
cluster: grpc_service
timeout: 0s
http_filters:
- name: envoy.filters.http.grpc_json_transcoder
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.grpc_json_transcoder.v3.GrpcJsonTranscoder
proto_descriptor: "/path/to/proto.pb"
services:
- my.grpc.Service
print_options:
add_whitespace: true
always_print_primitive_fields: true
always_print_enums_as_ints: false
- name: envoy.filters.http.router



clusters:
- name: grpc_service
type: STRICT_DNS
connect_timeout: 5s
lb_policy: ROUND_ROBIN
http2_protocol_options: { }
load_assignment:
cluster_name: grpc_service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: grpc_server1
port_value: 50051
- endpoint:
address:
socket_address:
address: grpc_server2
port_value: 50052

87 changes: 87 additions & 0 deletions assets/docker/Dockerfile-base
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# FROM condaforge/miniforge3:24.9.2-0
FROM condaforge/miniforge3:latest

LABEL org.opencontainers.image.title="bio-compose-server-worker" \
org.opencontainers.image.description="Base Docker image for BioCompose REST API management, job processing, and datastorage with MongoDB, ensuring scalable and robust performance." \
org.opencontainers.image.url="https://compose.biosimulators.org/" \
org.opencontainers.image.source="https://github.com/biosimulators/bio-compose-server" \
org.opencontainers.image.authors="Alexander Patrie <[email protected]>, BioSimulators Team <[email protected]>" \
org.opencontainers.image.vendor="BioSimulators Team"

ENV DEBIAN_FRONTEND=noninteractive

ARG INSTALL_WORKER

# RUN apt-get update \
# && apt-get install -y \
# meson \
# g++ \
# gfortran \
# libblas-dev \
# liblapack-dev \
# libgfortran5 \
# libhdf5-dev \
# libhdf5-serial-dev \
# libatlas-base-dev \
# cmake \
# make \
# git \
# build-essential \
# python3-dev \
# swig \
# libc6-dev \
# libx11-dev \
# libc6 \
# libgl1-mesa-dev \
# pkg-config \
# curl \
# tar \
# libgl1-mesa-glx \
# libice6 \
# libsm6 \
# gnupg \
# libstdc++6 \
# && apt-get clean

# copy assets
COPY assets/docker/config/.biosimulations.json /.google/.bio-compose.json
COPY assets/docker/config/.pys_usercfg.ini /Pysces/.pys_usercfg.ini
COPY assets/docker/config/.pys_usercfg.ini /root/Pysces/.pys_usercfg.ini
COPY tests/test_fixtures /test_fixtures

WORKDIR /app

# copy env configs
COPY ./environment.yml /app/environment.yml
COPY ./pyproject.toml /app/pyproject.toml
COPY ./gateway /app/gateway
COPY ./shared /app/shared
COPY ./worker /app/worker
COPY ./common /app/common

RUN echo "Server" > /app/README.md \
&& mkdir /app/config

# create base env
RUN conda install cmake ninja pybind11 scikit-build-core -y
RUN conda run pip install -e . \
&& conda env export --from-history > /app/env-export.yml

# && conda install --file=/app/environment.yml \
# RUN mamba install conda-forge::readdy -y
# RUN mamba create -n server python=3.11 cmake ninja pybind11 scikit-build-core -y
# RUN mamba run -n server pip install -e . \
# && mamba env export -n server --from-history > /app/env-export.yml

# handle worker(simulators)
# RUN if [ "$INSTALL_WORKER" == "1" ]; then \
# mamba install conda-forge::pymem3dg -y conda-forge::readdy \
# fi

# && conda install -n bsp conda-forge::readdy -y


# build alone with:
# docker build -f ./assets/docker/Dockerfile-base -t BASE .


1 change: 1 addition & 0 deletions client/.VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1
41 changes: 41 additions & 0 deletions client/Dockerfile-client
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM condaforge/miniforge3:24.9.2-0

LABEL org.opencontainers.image.title="bio-compose-server-gateway" \
org.opencontainers.image.description="Base Docker image for BioCompose REST API management, job processing, and datastorage with MongoDB, ensuring scalable and robust performance." \
org.opencontainers.image.url="https://compose.biosimulators.org/" \
org.opencontainers.image.source="https://github.com/biosimulators/bio-compose-server" \
org.opencontainers.image.authors="Alexander Patrie <[email protected]>, BioSimulators Team <[email protected]>" \
org.opencontainers.image.vendor="BioSimulators Team"

ENV DEBIAN_FRONTEND=noninteractive

# copy assets
COPY assets/docker/config/.biosimulations.json /.google/.bio-compose.json
COPY assets/docker/config/.pys_usercfg.ini /Pysces/.pys_usercfg.ini
COPY assets/docker/config/.pys_usercfg.ini /root/Pysces/.pys_usercfg.ini
COPY tests/test_fixtures /test_fixtures

WORKDIR /app

# copy env configs
COPY ./environment.yml /app/environment.yml
COPY ./pyproject.toml /app/pyproject.toml
COPY ./gateway /app/gateway
COPY ./shared /app/shared
COPY ./worker /app/worker
COPY ./common /app/common

RUN echo "Server" > /app/README.md \
&& mkdir /app/config
#
RUN conda update -n base -c conda-forge conda \
&& conda env create -f /app/environment.yml -y \
&& conda run -n compose-server pip install -e . \
&& conda run -n compose-server python /app/gateway/openapi_spec.py

# CMD ["conda", "run", "-n", "compose-server", "uvicorn", "gateway.main:app", "--host", "0.0.0.0", "--port", "3001", "--reload"]

# EXPOSE 3001

CMD ["conda", "run", "-n", "compose-server", "uvicorn", "gateway.main:app", "--host", "0.0.0.0", "--port", "3001", "--reload"]

Empty file added client/__init__.py
Empty file.
Loading