Skip to content

Commit

Permalink
Backend separation
Browse files Browse the repository at this point in the history
- extract, isolate and package it in a completely independent Python module, versioned and in a way that allows releases on PyPI.org
- fixed error in placeholder for secondary school (data registry defaults)
- added restriction in pytest version to install
- expected number of new cases fix
- data registry update (schema v2.1.1)
- github update
- deprecate ExpertApplication and CO2Application
- changes to reflect schema update 2.0.2
- version update
- Fixed error with f_inf (short-range)
  • Loading branch information
lrdossan committed Jul 15, 2024
1 parent 477e570 commit e5c8ce7
Show file tree
Hide file tree
Showing 188 changed files with 2,683 additions and 1,882 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
env:
PROJECT_ROOT: ./
PROJECT_NAME: caimira
CAIMIRA_TESTS_CALCULATOR_TIMEOUT: 30
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -46,6 +47,7 @@ jobs:
env:
PROJECT_ROOT: ./
PROJECT_NAME: caimira
CAIMIRA_TESTS_CALCULATOR_TIMEOUT: 30
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
18 changes: 3 additions & 15 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,16 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3.9"
# You can also specify other tool versions:
# nodejs: "16"
# rust: "1.55"
# golang: "1.17"
python: "3.11"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: caimira/docs/conf.py

# If using Sphinx, optionally build your docs in additional formats such as PDF
# formats:
# - pdf

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: requirements.txt
- requirements: caimira/docs/requirements.txt
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The information also features a distribution diagram of licenses and a brief des
A risk assessment tool which simulates the airborne spread of the SARS-CoV-2 virus for space managers.


### CAiMIRA Expert App
### CAiMIRA Expert App and CO₂ App

A tool to interact with various parameters of the CAiMIRA model.

Expand Down Expand Up @@ -103,25 +103,25 @@ pip install -e . # At the root of the repository
### Running the Calculator app in development mode

```
python -m caimira.apps.calculator
python -m ui.apps.calculator
```

To run with a specific template theme created:

```
python -m caimira.apps.calculator --theme=caimira/apps/templates/{theme}
python -m ui.apps.calculator --theme=ui/apps/templates/{theme}
```

To run the entire app in a different `APPLICATION_ROOT` path:

```
python -m caimira.apps.calculator --app_root=/myroot
python -m ui.apps.calculator --app_root=/myroot
```

To run the calculator on a different URL path:

```
python -m caimira.apps.calculator --prefix=/mycalc
python -m ui.apps.calculator --prefix=/mycalc
```

Each of these commands will start a local version of CAiMIRA, which can be visited at http://localhost:8080/.
Expand All @@ -139,13 +139,32 @@ If any of the `.rst` files under the `caimira/docs` folder is changed, this comm

Then, right click on `caimira/docs/_build/html/index.html` and select `Open with` your preferred web browser.

### Running the CAiMIRA Expert-App app in development mode
### Running the CAiMIRA Expert-App or CO2-App apps in development mode

#### Disclaimer

The `ExpertApplication` and `CO2Application` are no longer actively maintained but will remain in the codebase for legacy purposes.
Please note that the functionality of these applications might be compromised due to deprecation issues.

#### Running the Applications

These applications only work within Jupyter notebooks. Attempting to run them outside of a Jupyter environment may result in errors or degraded functionality.

##### Prerequisites

Make sure you have the needed dependencies intalled:

```
voila caimira/apps/expert/caimira.ipynb --port=8080
pip install notebook jupyterlab
```

Then visit http://localhost:8080.
Running with Visual Studio Code (VSCode):

1. Ensure you have the following extensions installed in VSCode: `Jupyter` and `Python`.

2. Open VSCode and navigate to the directory containing the notebook.

3. Open the notebook (e.g. `caimira/apps/expert/caimira.ipynb`) and run the cells by clicking the `run` button next to each cell.

### Running the tests

Expand Down
2 changes: 0 additions & 2 deletions app-config/caimira-public-docker-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ COPY ./app-config/caimira-public-docker-image/run_caimira.sh /opt/caimira/start.
# To ensure that we have installed the full requirements, re-run the pip install.
# In the best case this will be a no-op.
RUN cd /opt/caimira/src/ && /opt/caimira/app/bin/pip install -r /opt/caimira/src/requirements.txt
RUN /opt/caimira/app/bin/jupyter trust /opt/caimira/src/caimira/apps/expert/*.ipynb
RUN /opt/caimira/app/bin/jupyter trust /opt/caimira/src/caimira/apps/expert_co2/*.ipynb
COPY ./app-config/caimira-public-docker-image/nginx.conf /opt/caimira/nginx.conf

EXPOSE 8080
Expand Down
12 changes: 0 additions & 12 deletions app-config/caimira-public-docker-image/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,6 @@ http {

large_client_header_buffers 4 16k;

location /voila-server/ {
proxy_pass http://localhost:8082/voila-server/;
}
rewrite ^/expert-app$ /voila-server/ last;
rewrite ^/(files/static)/(.*)$ /voila-server/voila/$1/$2 last;

location /co2-voila-server/ {
proxy_pass http://localhost:8083/co2-voila-server/;
}
rewrite ^/co2-app$ /voila-server/ last;
rewrite ^/(files/static)/(.*)$ /voila-server/voila/$1/$2 last;

location / {
proxy_pass http://localhost:8081;
}
Expand Down
13 changes: 1 addition & 12 deletions app-config/caimira-public-docker-image/run_caimira.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@ echo 'Please see https://gitlab.cern.ch/caimira/caimira for terms of use.'
# Run a proxy for the apps (listening on 8080).
nginx -c /opt/caimira/nginx.conf

# Run the expert app in the background.
cd /opt/caimira/src/caimira
/opt/caimira/app/bin/python -m voila /opt/caimira/src/caimira/apps/expert/caimira.ipynb \
--port=8082 --no-browser --base_url=/voila-server/ \
--Voila.tornado_settings 'allow_origin=*' \
>> /var/log/expert-app.log 2>&1 &

/opt/caimira/app/bin/python -m voila /opt/caimira/src/caimira/apps/expert_co2/caimira.ipynb \
--port=8083 --no-browser --base_url=/co2-voila-server/ \
--Voila.tornado_settings 'allow_origin=*' \
>> /var/log/co2-app.log 2>&1 &

# Run the calculator in the foreground.
/opt/caimira/app/bin/python -m caimira.apps.calculator --port 8081 --no-debug
/opt/caimira/app/bin/python -m ui.apps.calculator --port 8081 --no-debug
11 changes: 3 additions & 8 deletions app-config/calculator-app/app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,9 @@ if [[ "$APP_NAME" == "calculator-app" ]]; then
export "DATA_SERVICE_ENABLED"="${DATA_SERVICE_ENABLED:=0}"
export "CAIMIRA_PROFILER_ENABLED"="${CAIMIRA_PROFILER_ENABLED:=0}"

echo "Starting the caimira webservice with: python -m caimira.apps.calculator ${args[@]}"
python -m caimira.apps.calculator "${args[@]}"
elif [[ "$APP_NAME" == "caimira-voila" ]]; then
echo "Starting the voila service"
voila caimira/apps/expert/ --port=8080 --no-browser --base_url=/voila-server/ --tornado_settings 'allow_origin=*'
elif [[ "$APP_NAME" == "caimira-co2-voila" ]]; then
echo "Starting the CO2 voila service"
voila caimira/apps/expert_co2/ --port=8080 --no-browser --base_url=/co2-voila-server/ --tornado_settings 'allow_origin=*'
echo "Starting the caimira webservice with: python -m ui.apps.calculator ${args[@]}"
python -m ui.apps.calculator "${args[@]}"

else
echo "No APP_NAME specified"
exit 1
Expand Down
18 changes: 1 addition & 17 deletions app-config/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
version: "3.8"
services:
expert-app:
image: calculator-app
environment:
- APP_NAME=caimira-voila
user: ${CURRENT_UID:?"Please run as follows 'CURRENT_UID=$(id -u):$(id -g) docker-compose up'"}

expert-co2-app:
image: calculator-app
environment:
- APP_NAME=caimira-co2-voila
user: ${CURRENT_UID:?"Please run as follows 'CURRENT_UID=$(id -u):$(id -g) docker-compose up'"}

calculator-app:
image: calculator-app
environment:
- COOKIE_SECRET
- APP_NAME=calculator-app
- APPLICATION_ROOT=/
- CAIMIRA_CALCULATOR_PREFIX=/calculator-cern
- CAIMIRA_THEME=caimira/apps/templates/cern
- CAIMIRA_THEME=ui/apps/templates/cern
- DATA_SERVICE_ENABLED=0
- CAIMIRA_PROFILER_ENABLED=0
user: ${CURRENT_UID}
Expand Down Expand Up @@ -54,10 +42,6 @@ services:
condition: service_started
calculator-open-app:
condition: service_started
expert-app:
condition: service_started
expert-co2-app:
condition: service_started
auth-service:
condition: service_started
user: ${CURRENT_UID}
38 changes: 1 addition & 37 deletions app-config/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -73,44 +73,8 @@ http {
proxy_pass http://calculator-app:8080/$request_uri;
}

location /voila-server/ {
proxy_intercept_errors on;

# Anything under voila-server or expert-app is authenticated.
auth_request /auth/probe;
error_page 401 = @error401;
error_page 404 = @proxy_404_error_handler;

# expert-app is the name of the voila server in each of docker-compose,
# caimira-test.web.cern.ch and caimira.web.cern.ch.
proxy_pass http://expert-app:8080/voila-server/;
}
rewrite ^/expert-app$ /voila-server/voila/render/caimira.ipynb last;
rewrite ^/(files/static)/(.*)$ /voila-server/voila/$1/$2 last;

# Before implementing the nginx router we could access /voila/render/caimira.ipynb.
# Redirect this (and all other) URLs to the new scheme.
# Redirect URLs to the new scheme.
absolute_redirect off;
rewrite ^/voila/(.*)$ /voila-server/voila/$1 redirect;

location /co2-voila-server/ {
proxy_intercept_errors on;

# Anything under voila-server or co2-app is authenticated.
auth_request /auth/probe;
error_page 401 = @error401;
error_page 404 = @proxy_404_error_handler;

# expert-co2-app is the name of the voila server in each of docker-compose,
# caimira-test.web.cern.ch and caimira.web.cern.ch.
proxy_pass http://expert-co2-app:8080/co2-voila-server/;
}
rewrite ^/co2-app$ /co2-voila-server/voila/render/caimira.ipynb last;
rewrite ^/(files/static)/(.*)$ /co2-voila-server/voila/$1/$2 last;

# Before implementing the nginx router we could access /voila/render/caimira.ipynb.
# Redirect this (and all other) URLs to the new scheme.
rewrite ^/voila/(.*)$ /co2-voila-server/voila/$1 redirect;

location / {
# By default we have no authentication.
Expand Down
115 changes: 1 addition & 114 deletions app-config/openshift/deploymentconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,120 +68,6 @@
kind: ImageStreamTag
name: 'auth-service:latest'
namespace: ${PROJECT_NAME}
-
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: expert-app
labels: {app: expert-app}
spec:
replicas: 1
template:
metadata:
labels:
app: expert-app
spec:
containers:
- name: calculator-app
env:
- name: APP_NAME
value: caimira-voila
image: '${PROJECT_NAME}/calculator-app'
ports:
- containerPort: 8080
protocol: TCP
imagePullPolicy: Always
resources:
limits: { cpu: '1', memory: 1Gi }
requests: { cpu: 1m, memory: 512Mi }
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: { }
terminationGracePeriodSeconds: 30
strategy:
activeDeadlineSeconds: 21600
resources: { }
rollingParams:
intervalSeconds: 1
maxSurge: 25%
maxUnavailable: 25%
timeoutSeconds: 600
updatePeriodSeconds: 1
type: Rolling
test: false
selector:
app: expert-app
triggers:
- type: ConfigChange
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- calculator-app
from:
kind: ImageStreamTag
name: 'calculator-app:latest'
namespace: ${PROJECT_NAME}
-
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: expert-co2-app
labels: {app: expert-co2-app}
spec:
replicas: 1
template:
metadata:
labels:
app: expert-co2-app
spec:
containers:
- name: calculator-app
env:
- name: APP_NAME
value: caimira-co2-voila
image: '${PROJECT_NAME}/calculator-app'
ports:
- containerPort: 8080
protocol: TCP
imagePullPolicy: Always
resources:
limits: { cpu: '1', memory: 1Gi }
requests: { cpu: 1m, memory: 512Mi }
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: { }
terminationGracePeriodSeconds: 30
strategy:
activeDeadlineSeconds: 21600
resources: { }
rollingParams:
intervalSeconds: 1
maxSurge: 25%
maxUnavailable: 25%
timeoutSeconds: 600
updatePeriodSeconds: 1
type: Rolling
test: false
selector:
app: expert-co2-app
triggers:
- type: ConfigChange
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- calculator-app
from:
kind: ImageStreamTag
name: 'calculator-app:latest'
namespace: ${PROJECT_NAME}
-
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
Expand Down Expand Up @@ -417,3 +303,4 @@
- name: PROJECT_NAME
description: The name of this project, e.g. caimira-test
required: true

Loading

0 comments on commit e5c8ce7

Please sign in to comment.