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

fix for https://github.com/OasisLMF/OasisUI/issues/309 #310

Merged
merged 3 commits into from
Nov 10, 2023
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
compose/OasisPiWind
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,32 @@
[![OasisUI Build](https://github.com/OasisLMF/OasisUI/actions/workflows/build.yml/badge.svg?branch=master&event=push)](https://github.com/OasisLMF/OasisUI/actions/workflows/build.yml)

# Oasis UI

Web-based application client for managing exposure data and operating modelling workflows.There are three components:
* Shiny UI application (This repository)
* Python Django server providing services for interacting with exposure and output data
* PostgreSQL server database

* Shiny UI application (This repository)
* Python Django server providing services for interacting with exposure and output data
* PostgreSQL server database

## Usage and documentation

For a detailed guide on using the OasisUI see

* [Oasis_UI_Guide.pdf](documentation/Oasis_UI_Guide.pdf?raw=true)
* [Oasis UI - Youtube Walkthrough](https://www.youtube.com/watch?v=tHRetuhpQzA)

## Deploying

To try out the OasisUI run the docker installation script `./install.sh` from [OasisEvaluation](https://github.com/OasisLMF/OasisEvaluation).
For tutorials on running the Oasis Stack locally see: (The full stack is required for the UI to work)

* [Windows 10 - Installation Guide](https://www.youtube.com/watch?v=SxRt5E-Y5Sw)
* [Linux - Installation Guide](https://www.youtube.com/watch?v=OFLTpGGEM10)


## Testing and development

The script `./run_rstudio.sh` deploys and runs a development version of OasisUI, it runs using an [RStudio Server](https://documentation.dnanexus.com/getting-started/developer-tutorials/web-app-let-tutorials/running-rstudio-server).

1. run the script open the url [http://localhost:8787/](http://localhost:8787/) in a browser.
2. Load the project file
![Load Project](.img/dev_load_project.png?raw=true "Load RStudio Project")
Expand All @@ -33,6 +38,28 @@ The script `./run_rstudio.sh` deploys and runs a development version of OasisUI,
4. In the R console enter `> oasisui::runOasisui()`, this will run the OasisUI in a new window
![Run App](.img/dev_run_oasisui.png?raw=true "Run Application")

## Running with Docker compose

1. build the R Studio container

```bash
./rstudio build
```

2. bring up the stack

```bash
./rstudio start
```

open the url [http://localhost:8787/](http://localhost:8787/) in a browser.

3. bring down the stack

```bash
./rstudio stop
```

## License
The code in this project is licensed under BSD 3-clause license.

The code in this project is licensed under BSD 3-clause license.
141 changes: 141 additions & 0 deletions compose/oasis-platform-ui-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
version: "3.8"
volumes:
server-db-OasisData:
celery-db-OasisData:
filestore-OasisData:
services:
server:
restart: always
image: ${SERVER_IMG:-coreoasis/api_server}:${VERS_API:-latest}
ports:
- 8000:8000
links:
- server-db
- celery-db
- rabbit
environment:
- OASIS_ADMIN_USER=admin
- OASIS_ADMIN_PASS=password
- OASIS_DEBUG=1
- OASIS_RABBIT_HOST=rabbit
- OASIS_RABBIT_PORT=5672
- OASIS_RABBIT_USER=rabbit
- OASIS_RABBIT_PASS=rabbit
- OASIS_SERVER_DB_HOST=server-db
- OASIS_SERVER_DB_PASS=oasis
- OASIS_SERVER_DB_USER=oasis
- OASIS_SERVER_DB_NAME=oasis
- OASIS_SERVER_DB_PORT=5432
- OASIS_SERVER_DB_ENGINE=django.db.backends.postgresql_psycopg2
- OASIS_CELERY_DB_ENGINE=db+postgresql+psycopg2
- OASIS_CELERY_DB_HOST=celery-db
- OASIS_CELERY_DB_PASS=password
- OASIS_CELERY_DB_USER=celery
- OASIS_CELERY_DB_NAME=celery
- OASIS_CELERY_DB_PORT=5432
- STARTUP_RUN_MIGRATIONS=true
volumes:
- filestore-OasisData:/shared-fs:rw
worker-monitor:
restart: always
image: ${SERVER_IMG:-coreoasis/api_server}:${VERS_API:-latest}
command:
[
wait-for-server,
"server:8000",
celery,
-A,
src.server.oasisapi,
worker,
--loglevel=INFO,
]
links:
- server-db
- celery-db
- rabbit
environment:
- OASIS_DEBUG=1
- OASIS_RABBIT_HOST=rabbit
- OASIS_RABBIT_PORT=5672
- OASIS_RABBIT_USER=rabbit
- OASIS_RABBIT_PASS=rabbit
- OASIS_SERVER_DB_HOST=server-db
- OASIS_SERVER_DB_PASS=oasis
- OASIS_SERVER_DB_USER=oasis
- OASIS_SERVER_DB_NAME=oasis
- OASIS_SERVER_DB_PORT=5432
- OASIS_SERVER_DB_ENGINE=django.db.backends.postgresql_psycopg2
- OASIS_CELERY_DB_ENGINE=db+postgresql+psycopg2
- OASIS_CELERY_DB_HOST=celery-db
- OASIS_CELERY_DB_PASS=password
- OASIS_CELERY_DB_USER=celery
- OASIS_CELERY_DB_NAME=celery
- OASIS_CELERY_DB_PORT=5432
volumes:
- filestore-OasisData:/shared-fs:rw
worker:
restart: always
image: ${WORKER_IMG:-coreoasis/model_worker}:${VERS_WORKER:-latest}
links:
- celery-db
- rabbit:myrabbit
environment:
- OASIS_MODEL_SUPPLIER_ID=OasisLMF
- OASIS_MODEL_ID=PiWind
- OASIS_MODEL_VERSION_ID=1
- OASIS_RABBIT_HOST=rabbit
- OASIS_RABBIT_PORT=5672
- OASIS_RABBIT_USER=rabbit
- OASIS_RABBIT_PASS=rabbit
- OASIS_SERVER_DB_ENGINE=django.db.backends.postgresql_psycopg2
- OASIS_CELERY_DB_ENGINE=db+postgresql+psycopg2
- OASIS_CELERY_DB_HOST=celery-db
- OASIS_CELERY_DB_PASS=password
- OASIS_CELERY_DB_USER=celery
- OASIS_CELERY_DB_NAME=celery
- OASIS_CELERY_DB_PORT=5432
- OASIS_MODEL_DATA_DIRECTORY=/home/worker/model
volumes:
- ./OasisPiWind/:/home/worker/model
- filestore-OasisData:/shared-fs:rw
server-db:
restart: always
image: postgres
environment:
- POSTGRES_DB=oasis
- POSTGRES_USER=oasis
- POSTGRES_PASSWORD=oasis
volumes:
- server-db-OasisData:/var/lib/postgresql/data:rw
celery-db:
restart: always
image: postgres
environment:
- POSTGRES_DB=celery
- POSTGRES_USER=celery
- POSTGRES_PASSWORD=password
volumes:
- celery-db-OasisData:/var/lib/postgresql/data:rw
rabbit:
restart: always
image: rabbitmq:3.8.14-management
environment:
- RABBITMQ_DEFAULT_USER=rabbit
- RABBITMQ_DEFAULT_PASS=rabbit
ports:
- 5672:5672
- 15672:15672
rstudio:
image: oasisui_dev:latest
restart: always
environment:
- DISABLE_AUTH=true
- USERID=${UID:-1000}
- DISPLAY=${DISPLAY:-:0}
volumes:
- ${SHARED_DIR}:/home/rstudio/oasisui
- /tmp/.X11-unix:/tmp/.X11-unix:ro
ports:
- 8787:8787
networks:
- default
2 changes: 1 addition & 1 deletion docker/Dockerfile.oasisui_development
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN R -e 'devtools::install(pkg = "./BFE_RShiny/oasisui", dependencies = TRUE)'
# Create .Rprofile and set default values
RUN echo 'message("Run app with: oasisui::runOasisui()")' >> /home/rstudio/.Rprofile

ENV API_IP="127.0.0.1"
ENV API_IP="server"
ENV API_PORT="8000"
ENV API_VERSION="v1"
ENV API_SHARE_FILEPATH="./downloads"
Expand Down
83 changes: 83 additions & 0 deletions rstudio
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash

SHARED_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
R_PROJECT_FILE="$SHARED_DIR/oasisui_dev.Rproj"
R_CONTAINER_NAME='rstudio_oasisui'
DOCKERFILE_PATH="$SHARED_DIR/docker/Dockerfile.oasisui_development"
IMAGE_NAME="oasisui_dev:latest"
COMPOSE_FILE="$SHARED_DIR/compose/oasis-platform-ui-dev.yml"

export SHARED_DIR
export UID=${UID:-1000}
export DISPLAY=${DISPLAY:-:0}

function build() {
echo "Creating a new R project file with default configurations..."
{
echo "Version: 1.0"
echo "RestoreWorkspace: Default"
echo "SaveWorkspace: Default"
echo "AlwaysSaveHistory: Default"
echo "EnableCodeIndexing: Yes"
echo "UseSpacesForTab: Yes"
echo "NumSpacesForTab: 2"
echo "Encoding: UTF-8"
echo "RnwWeave: Sweave"
echo "LaTeX: pdfLaTeX"
echo "BuildType: Package"
echo "PackageUseDevtools: Yes"
echo "PackagePath: BFE_RShiny/oasisui"
echo "PackageInstallArgs: --no-multiarch --with-keep.source"
} > "$R_PROJECT_FILE"

if [ -s "$R_PROJECT_FILE" ]; then
echo "R project file created successfully with content."
else
echo "R project file is empty or could not be created."
return 1 # Exit the function with an error status
fi

echo "Building UI Docker image..."
docker build -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" .
}





function stop() {
echo "Stopping and removing containers..."
docker-compose -f "$COMPOSE_FILE" down
}

function start() {
echo "Starting services..."
docker-compose -f "$COMPOSE_FILE" up -d
echo "connect using: http://localhost:8787/"
}

# Check and create the R project file if it doesn't exist.
if [ ! -f "$R_PROJECT_FILE" ]; then
cat >> "$R_PROJECT_FILE" <<EOL
# ... your existing R project configuration ...
EOL
fi

# Parse command line argument.
case "$1" in
build)
build
;;
stop)
stop
;;
start)
start
;;
*)
echo "Usage: $0 {build|stop|start}"
exit 1
;;
esac

echo "Done."