diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5c41b8ea..20a79941 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -# This module is part of CARA. Please see the repository at +# This module is part of CAiMIRA. Please see the repository at # https://gitlab.cern.ch/cara/cara for details of the license and terms of use. name: CI @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest env: PROJECT_ROOT: ./ - PROJECT_NAME: cara + PROJECT_NAME: caimira steps: - name: Checkout uses: actions/checkout@v2 @@ -45,7 +45,7 @@ jobs: runs-on: ubuntu-20.04 env: PROJECT_ROOT: ./ - PROJECT_NAME: cara + PROJECT_NAME: caimira steps: - name: Checkout uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index 40759e9f..5ba02f52 100644 --- a/.gitignore +++ b/.gitignore @@ -14,8 +14,8 @@ venv support # openshift config check folder -app-config/openshift/test-cara -app-config/openshift/cara-prod +app-config/openshift/caimira-test +app-config/openshift/caimira-prod # documentation build folder -cara/docs/_build \ No newline at end of file +caimira/docs/_build \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f57bc054..ccc4e3a2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,24 +11,24 @@ include: file: acc_py_devtools/templates/gitlab-ci/python.yml variables: - project_name: cara + project_name: caimira PY_VERSION: "3.9" # ################################################################################################### # Test code -# A full installation of CARA, tested with pytest. +# A full installation of CAiMIRA, tested with pytest. test_install: extends: .acc_py_full_test -# A development installation of CARA tested with pytest. +# A development installation of CAiMIRA tested with pytest. test_dev: extends: .acc_py_dev_test -# A development installation of CARA tested with pytest. +# A development installation of CAiMIRA tested with pytest. test_dev-39: variables: PY_VERSION: "3.9" @@ -55,33 +55,41 @@ test_dev-39: script: - cd ./app-config/openshift - oc login ${OC_SERVER} --token="${OC_TOKEN}" - - python ./config-fetch.py ${CARA_INSTANCE} --output-directory ./${CARA_INSTANCE}/actual - - python ./config-generate.py ${CARA_INSTANCE} --output-directory ./${CARA_INSTANCE}/expected - - python ./config-normalise.py ./${CARA_INSTANCE}/actual ./${CARA_INSTANCE}/actual-normed - - python ./config-normalise.py ./${CARA_INSTANCE}/expected ./${CARA_INSTANCE}/expected-normed - - diff -u ./${CARA_INSTANCE}/actual-normed/ ./${CARA_INSTANCE}/expected-normed/ + - python ./config-fetch.py ${CAIMIRA_INSTANCE} --output-directory ./${CAIMIRA_INSTANCE}/actual + - python ./config-generate.py ${CAIMIRA_INSTANCE} --output-directory ./${CAIMIRA_INSTANCE}/expected + - python ./config-normalise.py ./${CAIMIRA_INSTANCE}/actual ./${CAIMIRA_INSTANCE}/actual-normed + - python ./config-normalise.py ./${CAIMIRA_INSTANCE}/expected ./${CAIMIRA_INSTANCE}/expected-normed + - diff -u ./${CAIMIRA_INSTANCE}/actual-normed/ ./${CAIMIRA_INSTANCE}/expected-normed/ artifacts: paths: - - ./app-config/openshift/${CARA_INSTANCE}/actual - - ./app-config/openshift/${CARA_INSTANCE}/expected + - ./app-config/openshift/${CAIMIRA_INSTANCE}/actual + - ./app-config/openshift/${CAIMIRA_INSTANCE}/expected check_openshift_config_test: extends: .test_openshift_config variables: - CARA_INSTANCE: 'test-cara' - BRANCH: 'live/test-cara' + CAIMIRA_INSTANCE: 'caimira-test' + BRANCH: 'live/caimira-test' OC_SERVER: https://api.paas.okd.cern.ch - OC_TOKEN: "${OPENSHIFT_TEST_CONFIG_CHECKER_TOKEN}" + OC_TOKEN: "${OPENSHIFT_CAIMIRA_TEST_CONFIG_CHECKER_TOKEN}" check_openshift_config_prod: extends: .test_openshift_config variables: - CARA_INSTANCE: 'cara-prod' + CAIMIRA_INSTANCE: 'caimira-prod' BRANCH: 'master' OC_SERVER: https://api.paas.okd.cern.ch - OC_TOKEN: "${OPENSHIFT_PROD_CONFIG_CHECKER_TOKEN}" + OC_TOKEN: "${OPENSHIFT_CAIMIRA_PROD_CONFIG_CHECKER_TOKEN}" + + +oci_calculator: + extends: .image_builder + variables: + IMAGE_NAME: calculator + DOCKERFILE_DIRECTORY: app-config/caimira-public-docker-image + DOCKER_CONTEXT_DIRECTORY: "" # ################################################################################################### @@ -91,12 +99,12 @@ check_openshift_config_prod: # Build and push images to the openshift instance, which automatically triggers an application re-deployment. stage: docker-build rules: - - if: '$CI_COMMIT_BRANCH == "live/test-cara"' + - if: '$CI_COMMIT_BRANCH == "live/caimira-test"' variables: - IMAGE_TAG: test-cara-latest + IMAGE_TAG: caimira-test-latest - if: '$CI_COMMIT_BRANCH == "master"' variables: - IMAGE_TAG: cara-prod-latest + IMAGE_TAG: caimira-prod-latest image: # Based on guidance at https://gitlab.cern.ch/gitlabci-examples/build_docker_image. name: gitlab-registry.cern.ch/ci-tools/docker-image-builder @@ -116,21 +124,12 @@ auth-service-image_builder: DOCKER_CONTEXT_DIRECTORY: app-config/auth-service -cara-webservice-image_builder: +caimira-webservice-image_builder: extends: - .image_builder variables: - IMAGE_NAME: cara-webservice - DOCKERFILE_DIRECTORY: app-config/cara-webservice - DOCKER_CONTEXT_DIRECTORY: "" - - -oci_calculator: - extends: - - .image_builder - variables: - IMAGE_NAME: calculator - DOCKERFILE_DIRECTORY: app-config/cara-public-docker-image + IMAGE_NAME: caimira-webservice + DOCKERFILE_DIRECTORY: app-config/caimira-webservice DOCKER_CONTEXT_DIRECTORY: "" @@ -141,16 +140,16 @@ oci_calculator: stage: oc-tag image: gitlab-registry.cern.ch/paas-tools/openshift-client:latest rules: - - if: '$CI_COMMIT_BRANCH == "live/test-cara"' + - if: '$CI_COMMIT_BRANCH == "live/caimira-test"' variables: - OC_PROJECT: "test-cara" - OC_TOKEN: ${OPENSHIFT_TEST_DEPLOY_TOKEN} - IMAGE_TAG: test-cara-latest + OC_PROJECT: "caimira-test" + OC_TOKEN: ${OPENSHIFT_CAIMIRA_TEST_DEPLOY_TOKEN} + IMAGE_TAG: caimira-test-latest - if: '$CI_COMMIT_BRANCH == "master"' variables: - OC_PROJECT: "cara-prod" - OC_TOKEN: ${OPENSHIFT_PROD_DEPLOY_TOKEN} - IMAGE_TAG: cara-prod-latest + OC_PROJECT: "caimira-prod" + OC_TOKEN: ${OPENSHIFT_CAIMIRA_PROD_DEPLOY_TOKEN} + IMAGE_TAG: caimira-prod-latest script: - oc tag --source=docker ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_TAG} ${IMAGE_NAME}:latest --token ${OC_TOKEN} --server=https://api.paas.okd.cern.ch -n ${OC_PROJECT} @@ -160,11 +159,11 @@ link_auth-service_with_gitlab_registry: variables: IMAGE_NAME: auth-service -link_cara-webservice_with_gitlab_registry: +link_caimira-webservice_with_gitlab_registry: extends: - .link_docker_images_with_gitlab_registry variables: - IMAGE_NAME: cara-webservice + IMAGE_NAME: caimira-webservice link_calculator_with_gitlab_registry: extends: @@ -174,18 +173,18 @@ link_calculator_with_gitlab_registry: # ################################################################################################### -# Trigger build of CARA router on OpenShift +# Trigger build of CAiMIRA router on OpenShift -trigger_cara-router_build_on_openshift: +trigger_caimira-router_build_on_openshift: stage: deploy rules: - - if: '$CI_COMMIT_BRANCH == "live/test-cara"' + - if: '$CI_COMMIT_BRANCH == "live/caimira-test"' variables: - OC_PROJECT: "test-cara" - BUILD_WEBHOOK_SECRET: ${OPENSHIFT_TEST_BUILD_WEBHOOK_SECRET} + OC_PROJECT: "caimira-test" + BUILD_WEBHOOK_SECRET: ${OPENSHIFT_CAIMIRA_TEST_BUILD_WEBHOOK_SECRET} - if: '$CI_COMMIT_BRANCH == "master"' variables: - OC_PROJECT: "cara-prod" - BUILD_WEBHOOK_SECRET: ${OPENSHIFT_PROD_BUILD_WEBHOOK_SECRET} + OC_PROJECT: "caimira-prod" + BUILD_WEBHOOK_SECRET: ${OPENSHIFT_CAIMIRA_PROD_BUILD_WEBHOOK_SECRET} script: - - curl -X POST -k https://api.paas.okd.cern.ch/apis/build.openshift.io/v1/namespaces/${OC_PROJECT}/buildconfigs/cara-router/webhooks/${BUILD_WEBHOOK_SECRET}/generic + - curl -X POST -k https://api.paas.okd.cern.ch/apis/build.openshift.io/v1/namespaces/${OC_PROJECT}/buildconfigs/caimira-router/webhooks/${BUILD_WEBHOOK_SECRET}/generic diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 44aa3959..8a50de4c 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -17,7 +17,7 @@ build: # Build documentation in the docs/ directory with Sphinx sphinx: - configuration: cara/docs/conf.py + configuration: caimira/docs/conf.py # If using Sphinx, optionally build your docs in additional formats such as PDF # formats: diff --git a/README.md b/README.md index 6833ad36..db51d327 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ This will start a local version of CAiMIRA, which can be visited at http://local ## Development guide -CAiMIRA is also mirrored to Github if you wish to collaborate on development and can be found at: https://github.com/CERN/cara +CAiMIRA is also mirrored to Github if you wish to collaborate on development and can be found at: https://github.com/CERN/caimira ### Installing CAiMIRA in editable mode @@ -97,19 +97,19 @@ pip install -e . # At the root of the repository ### Running the Calculator app in development mode ``` -python -m cara.apps.calculator +python -m caimira.apps.calculator ``` To run with the CERN theme: ``` -python -m cara.apps.calculator --theme=cara/apps/templates/cern +python -m caimira.apps.calculator --theme=caimira/apps/templates/cern ``` To run the calculator on a different URL path: ``` -python -m cara.apps.calculator --prefix=/mycalc +python -m caimira.apps.calculator --prefix=/mycalc ``` ### How to compile and read the documentation @@ -120,15 +120,15 @@ In order to generate the documentation, CAiMIRA must be installed first with the pip install -e .[doc] ``` -To generate the HTML documentation page, the command `make html` should be executed in the `cara/docs` directory. -If any of the `.rst` files under the `cara/docs` folder is changed, this command should be executed again. +To generate the HTML documentation page, the command `make html` should be executed in the `caimira/docs` directory. +If any of the `.rst` files under the `caimira/docs` folder is changed, this command should be executed again. -Then, right click on `cara/docs/_build/html/index.html` and select `Open with` your preferred web browser. +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 ``` -voila cara/apps/expert/cara.ipynb --port=8080 +voila caimira/apps/expert/caimira.ipynb --port=8080 ``` Then visit http://localhost:8080. @@ -138,7 +138,7 @@ Then visit http://localhost:8080. ``` pip install -e .[test] -pytest ./cara +pytest ./caimira ``` ### Building the whole environment for local development @@ -146,12 +146,12 @@ pytest ./cara **Simulate the docker build that takes place on openshift with:** ``` -s2i build file://$(pwd) --copy --keep-symlinks --context-dir ./app-config/nginx/ centos/nginx-112-centos7 cara-nginx-app -docker build . -f ./app-config/cara-webservice/Dockerfile -t cara-webservice +s2i build file://$(pwd) --copy --keep-symlinks --context-dir ./app-config/nginx/ centos/nginx-112-centos7 caimira-nginx-app +docker build . -f ./app-config/caimira-webservice/Dockerfile -t caimira-webservice docker build ./app-config/auth-service -t auth-service ``` -Get the client secret from the CERN Application portal for the `cara-test` app. See [CERN-SSO-integration](#CERN-SSO-integration) for more info. +Get the client secret from the CERN Application portal for the `caimira-test` app. See [CERN-SSO-integration](#CERN-SSO-integration) for more info. ``` read CLIENT_SECRET ``` @@ -161,7 +161,7 @@ Define some env vars (copy/paste): export COOKIE_SECRET=$(openssl rand -hex 50) export OIDC_SERVER=https://auth.cern.ch/auth export OIDC_REALM=CERN -export CLIENT_ID=cara-test +export CLIENT_ID=caimira-test export CLIENT_SECRET ``` @@ -175,21 +175,21 @@ Then visit http://localhost:8080/. ### Setting up the application on openshift -The https://cern.ch/cara application is running on CERN's OpenShift platform. In order to set it up for the first time, we followed the documentation at https://cern.service-now.com/service-portal?id=kb_article&n=KB0004498. In particular we: +The https://cern.ch/caimira application is running on CERN's OpenShift platform. In order to set it up for the first time, we followed the documentation at https://cern.service-now.com/service-portal?id=kb_article&n=KB0004498. In particular we: * Added the OpenShift application deploy key to the GitLab repository * Created a Python 3.6 (the highest possible at the time of writing) application in OpenShift * Configured a generic webhook on OpenShift, and call that from the CI of the GitLab repository -### Updating the test-cara.web.cern.ch instance +### Updating the caimira-test.web.cern.ch instance -We have a replica of https://cara.web.cern.ch running on http://test-cara.web.cern.ch. Its purpose is to simulate what will happen when -a feature is merged. To push your changes to test-cara, simply push your branch to `live/test-cara` and the CI pipeline will trigger the +We have a replica of https://caimira.web.cern.ch running on http://caimira-test.web.cern.ch. Its purpose is to simulate what will happen when +a feature is merged. To push your changes to caimira-test, simply push your branch to `live/caimira-test` and the CI pipeline will trigger the deployment. To push to this branch, there is a good chance that you will need to force push - you should always force push with care and understanding why you are doing it. Syntactically, it will look something like (assuming that you have "upstream" as your remote name, but it may be origin if you haven't configured it differently): - git push --force upstream name-of-local-branch:live/test-cara + git push --force upstream name-of-local-branch:live/caimira-test ## OpenShift templates @@ -205,7 +205,7 @@ $ oc login https://api.paas.okd.cern.ch Then, switch to the project that you want to update: ```console -$ oc project cara-test +$ oc project caimira-test ``` Create a new service account in OpenShift to use GitLab container registry: @@ -221,17 +221,17 @@ $ oc serviceaccounts get-token gitlabci-deployer <...test-token...> ``` -Add the token to GitLab to allow GitLab to access OpenShift and define/change image stream tags. Go to `Settings` -> `CI / CD` -> `Variables` -> click on `Expand` button and create the variable `OPENSHIFT_TEST_DEPLOY_TOKEN`: insert the token `<...test-token...>`. +Add the token to GitLab to allow GitLab to access OpenShift and define/change image stream tags. Go to `Settings` -> `CI / CD` -> `Variables` -> click on `Expand` button and create the variable `OPENSHIFT_CAIMIRA_TEST_DEPLOY_TOKEN`: insert the token `<...test-token...>`. Then, create the webhook secret to be able to trigger automatic builds from GitLab. -Create and store the secret. Copy the secret above and add it to the GitLab project under `CI /CD` -> `Variables` with the name `OPENSHIFT_TEST_WEBHOOK_SECRET`. +Create and store the secret. Copy the secret above and add it to the GitLab project under `CI /CD` -> `Variables` with the name `OPENSHIFT_CAIMIRA_TEST_WEBHOOK_SECRET`. ```console $ WEBHOOKSECRET=$(openssl rand -hex 50) $ oc create secret generic \ --from-literal="WebHookSecretKey=$WEBHOOKSECRET" \ - gitlab-cara-webhook-secret + gitlab-caimira-webhook-secret ``` For CI usage, we also suggest creating a service account: @@ -256,8 +256,8 @@ $ cd app-config/openshift $ oc process -f configmap.yaml | oc create -f - $ oc process -f services.yaml | oc create -f - $ oc process -f imagestreams.yaml | oc create -f - -$ oc process -f buildconfig.yaml --param GIT_BRANCH='live/test-cara' | oc create -f - -$ oc process -f deploymentconfig.yaml --param PROJECT_NAME='cara-test' | oc create -f - +$ oc process -f buildconfig.yaml --param GIT_BRANCH='live/caimira-test' | oc create -f - +$ oc process -f deploymentconfig.yaml --param PROJECT_NAME='caimira-test' | oc create -f - ``` ### CERN SSO integration @@ -265,12 +265,12 @@ $ oc process -f deploymentconfig.yaml --param PROJECT_NAME='cara-test' | oc cre The SSO integration uses OpenID credentials configured in [CERN Applications portal](https://application-portal.web.cern.ch/). How to configure the application: -* Application Identifier: `cara-test` -* Homepage: `https://test-cara.web.cern.ch` -* Administrators: `cara-dev` +* Application Identifier: `caimira-test` +* Homepage: `https://caimira-test.web.cern.ch` +* Administrators: `caimira-dev` * SSO Registration: * Protocol: `OpenID (OIDC)` - * Redirect URI: `https://test-cara.web.cern.ch/auth/authorize` + * Redirect URI: `https://caimira-test.web.cern.ch/auth/authorize` * Leave unchecked all the other checkboxes * Define new roles: * Name: `CERN Users` @@ -282,12 +282,12 @@ How to configure the application: * Role Identifier: `admin` * Leave unchecked checkboxes * Minimum Level Of Assurance: `Any (no restrictions)` - * Assign role to groups: `cara-app-external-access` e-group + * Assign role to groups: `caimira-app-external-access` e-group * Name: `Allowed users` * Role Identifier: `allowed-users` * Check `This role is required to access my application` * Minimum Level Of Assurance:`Any (no restrictions)` - * Assign role to groups: `cern-accounts-primary` and `cara-app-external-access` e-groups + * Assign role to groups: `cern-accounts-primary` and `caimira-app-external-access` e-groups Copy the client id and client secret and use it below. @@ -318,8 +318,8 @@ $ cd app-config/openshift $ oc process -f configmap.yaml | oc replace -f - $ oc process -f services.yaml | oc replace -f - $ oc process -f imagestreams.yaml | oc replace -f - -$ oc process -f buildconfig.yaml --param GIT_BRANCH='live/test-cara' | oc replace -f - -$ oc process -f deploymentconfig.yaml --param PROJECT_NAME='cara-test' | oc replace -f - +$ oc process -f buildconfig.yaml --param GIT_BRANCH='live/caimira-test' | oc replace -f - +$ oc process -f deploymentconfig.yaml --param PROJECT_NAME='caimira-test' | oc replace -f - ``` Be aware that if you create/recreate the environment you must manually create a **route** in OpenShift, diff --git a/app-config/caimira-public-docker-image/Dockerfile b/app-config/caimira-public-docker-image/Dockerfile new file mode 100644 index 00000000..ee69552b --- /dev/null +++ b/app-config/caimira-public-docker-image/Dockerfile @@ -0,0 +1,21 @@ +FROM registry.cern.ch/docker.io/library/python:3.9 + +# Copy just the requirements.txt initially, allowing Docker effectively to cache the build (good for dev). +COPY ./requirements.txt /tmp/requirements.txt + +RUN python -m venv /opt/caimira/app +RUN sed '/\.\[/d' -i /tmp/requirements.txt && /opt/caimira/app/bin/pip install -r /tmp/requirements.txt +RUN apt-get update && apt-get install -y nginx + +# Now that we have done the installation of the dependencies, copy the caimira source. +COPY ./ /opt/caimira/src +COPY ./app-config/caimira-public-docker-image/run_caimira.sh /opt/caimira/start.sh + +# 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 +COPY ./app-config/caimira-public-docker-image/nginx.conf /opt/caimira/nginx.conf + +EXPOSE 8080 +ENTRYPOINT ["/bin/sh", "-c", "/opt/caimira/start.sh"] diff --git a/app-config/cara-public-docker-image/nginx.conf b/app-config/caimira-public-docker-image/nginx.conf similarity index 97% rename from app-config/cara-public-docker-image/nginx.conf rename to app-config/caimira-public-docker-image/nginx.conf index b873a7d2..88cd8e2b 100644 --- a/app-config/cara-public-docker-image/nginx.conf +++ b/app-config/caimira-public-docker-image/nginx.conf @@ -37,7 +37,7 @@ http { listen 8080 default_server; listen [::]:8080 default_server; server_name _; - root /opt/cara/src; + root /opt/caimira/src; # Load configuration files for the default server block. include /opt/app-root/etc/nginx.default.d/*.conf; diff --git a/app-config/cara-public-docker-image/run_cara.sh b/app-config/caimira-public-docker-image/run_caimira.sh similarity index 54% rename from app-config/cara-public-docker-image/run_cara.sh rename to app-config/caimira-public-docker-image/run_caimira.sh index 43d963b2..bfaa57ab 100755 --- a/app-config/cara-public-docker-image/run_cara.sh +++ b/app-config/caimira-public-docker-image/run_caimira.sh @@ -1,16 +1,16 @@ -echo 'CARA is running on http://localhost:8080' +echo 'CAiMIRA is running on http://localhost:8080' echo 'Please see https://gitlab.cern.ch/cara/cara for terms of use.' # Run a proxy for the apps (listening on 8080). -nginx -c /opt/cara/nginx.conf +nginx -c /opt/caimira/nginx.conf # Run the expert app in the background. -cd /opt/cara/src/cara -/opt/cara/app/bin/python -m voila /opt/cara/src/cara/apps/expert/cara.ipynb \ +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 & # Run the calculator in the foreground. -/opt/cara/app/bin/python -m cara.apps.calculator --port 8081 --no-debug +/opt/caimira/app/bin/python -m caimira.apps.calculator --port 8081 --no-debug diff --git a/app-config/cara-webservice/Dockerfile b/app-config/caimira-webservice/Dockerfile similarity index 77% rename from app-config/cara-webservice/Dockerfile rename to app-config/caimira-webservice/Dockerfile index a1a0ba1d..0a652800 100644 --- a/app-config/cara-webservice/Dockerfile +++ b/app-config/caimira-webservice/Dockerfile @@ -3,7 +3,7 @@ FROM registry.cern.ch/docker.io/condaforge/mambaforge as conda RUN mamba create --yes -p /opt/app python=3.9 COPY . /opt/app-source RUN cd /opt/app-source && conda run -p /opt/app python -m pip install -r ./requirements.txt .[app] -COPY app-config/cara-webservice/app.sh /opt/app/bin/cara-app.sh +COPY app-config/caimira-webservice/app.sh /opt/app/bin/caimira-app.sh RUN cd /opt/app \ && find -name '*.a' -delete \ && rm -rf /opt/app/conda-meta \ @@ -22,15 +22,15 @@ FROM registry.cern.ch/docker.io/library/debian COPY --from=conda /opt/app /opt/app ENV PATH=/opt/app/bin/:$PATH -# Make a convenient location to the installed CARA package (i.e. a directory called cara in the CWD). +# Make a convenient location to the installed CAiMIRA package (i.e. a directory called caimira in the CWD). # It is important that this directory is also writable by a non-root user. RUN mkdir -p /scratch \ && chmod a+wx /scratch # Set the HOME directory to something that anybody can write to (to support non root users, such as on openshift). ENV HOME=/scratch WORKDIR /scratch -RUN CARA_INIT_FILE=$(/opt/app/bin/python -c "import cara; print(cara.__file__)") \ - && ln -s $(dirname ${CARA_INIT_FILE}) /scratch/cara +RUN CAIMIRA_INIT_FILE=$(/opt/app/bin/python -c "import caimira; print(caimira.__file__)") \ + && ln -s $(dirname ${CAIMIRA_INIT_FILE}) /scratch/caimira CMD [ \ - "cara-app.sh" \ + "caimira-app.sh" \ ] diff --git a/app-config/caimira-webservice/app.sh b/app-config/caimira-webservice/app.sh new file mode 100755 index 00000000..9ea2862a --- /dev/null +++ b/app-config/caimira-webservice/app.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +if [[ "$APP_NAME" == "caimira-webservice" ]]; then + args=("$@") + if [ "$DEBUG" != "true" ] && [[ ! "${args[@]}" =~ "--no-debug" ]]; then + args+=("--no-debug") + fi + + if [ ! -z "$CAIMIRA_THEME" ]; then + args+=("--theme=${CAIMIRA_THEME}") + fi + + if [ ! -z "$CAIMIRA_CALCULATOR_PREFIX" ]; then + args+=("--prefix=${CAIMIRA_CALCULATOR_PREFIX}") + fi + + 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=*' +else + echo "No APP_NAME specified" + exit 1 +fi + diff --git a/app-config/cara-public-docker-image/Dockerfile b/app-config/cara-public-docker-image/Dockerfile deleted file mode 100644 index b4a01695..00000000 --- a/app-config/cara-public-docker-image/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM registry.cern.ch/docker.io/library/python:3.9 - -# Copy just the requirements.txt initially, allowing Docker effectively to cache the build (good for dev). -COPY ./requirements.txt /tmp/requirements.txt - -RUN python -m venv /opt/cara/app -RUN sed '/\.\[/d' -i /tmp/requirements.txt && /opt/cara/app/bin/pip install -r /tmp/requirements.txt -RUN apt-get update && apt-get install -y nginx - -# Now that we have done the installation of the dependencies, copy the cara source. -COPY ./ /opt/cara/src -COPY ./app-config/cara-public-docker-image/run_cara.sh /opt/cara/start.sh - -# 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/cara/src/ && /opt/cara/app/bin/pip install -r /opt/cara/src/requirements.txt -RUN /opt/cara/app/bin/jupyter trust /opt/cara/src/cara/apps/expert/*.ipynb -COPY ./app-config/cara-public-docker-image/nginx.conf /opt/cara/nginx.conf - -EXPOSE 8080 -ENTRYPOINT ["/bin/sh", "-c", "/opt/cara/start.sh"] diff --git a/app-config/cara-webservice/app.sh b/app-config/cara-webservice/app.sh deleted file mode 100755 index 879a8571..00000000 --- a/app-config/cara-webservice/app.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -if [[ "$APP_NAME" == "cara-webservice" ]]; then - args=("$@") - if [ "$DEBUG" != "true" ] && [[ ! "${args[@]}" =~ "--no-debug" ]]; then - args+=("--no-debug") - fi - - if [ ! -z "$CARA_THEME" ]; then - args+=("--theme=${CARA_THEME}") - fi - - if [ ! -z "$CARA_CALCULATOR_PREFIX" ]; then - args+=("--prefix=${CARA_CALCULATOR_PREFIX}") - fi - - echo "Starting the cara webservice with: python -m cara.apps.calculator ${args[@]}" - python -m cara.apps.calculator "${args[@]}" -elif [[ "$APP_NAME" == "cara-voila" ]]; then - echo "Starting the voila service" - voila cara/apps/expert/ --port=8080 --no-browser --base_url=/voila-server/ --tornado_settings 'allow_origin=*' -else - echo "No APP_NAME specified" - exit 1 -fi - diff --git a/app-config/docker-compose.yml b/app-config/docker-compose.yml index e96da5fd..cb9d3958 100644 --- a/app-config/docker-compose.yml +++ b/app-config/docker-compose.yml @@ -1,26 +1,26 @@ version: "3.8" services: - cara-app: - image: cara-webservice + caimira-app: + image: caimira-webservice environment: - - APP_NAME=cara-voila + - APP_NAME=caimira-voila user: ${CURRENT_UID:?"Please run as follows 'CURRENT_UID=$(id -u):$(id -g) docker-compose up'"} - cara-webservice: - image: cara-webservice + caimira-webservice: + image: caimira-webservice environment: - COOKIE_SECRET - - APP_NAME=cara-webservice - - CARA_CALCULATOR_PREFIX=/calculator-cern - - CARA_THEME=cara/apps/templates/cern + - APP_NAME=caimira-webservice + - CAIMIRA_CALCULATOR_PREFIX=/calculator-cern + - CAIMIRA_THEME=caimira/apps/templates/cern user: ${CURRENT_UID} - cara-calculator-open: - image: cara-webservice + caimira-calculator-open: + image: caimira-webservice environment: - COOKIE_SECRET - - APP_NAME=cara-webservice - - CARA_CALCULATOR_PREFIX=/calculator-open + - APP_NAME=caimira-webservice + - CAIMIRA_CALCULATOR_PREFIX=/calculator-open user: ${CURRENT_UID} auth-service: @@ -33,16 +33,16 @@ services: - CLIENT_SECRET user: ${CURRENT_UID} - cara-router: - image: cara-nginx-app + caimira-router: + image: caimira-nginx-app ports: - "8080:8080" depends_on: - cara-webservice: + caimira-webservice: condition: service_started - cara-calculator-open: + caimira-calculator-open: condition: service_started - cara-app: + caimira-app: condition: service_started auth-service: condition: service_started diff --git a/app-config/nginx/nginx.conf b/app-config/nginx/nginx.conf index fb69f77a..2fef5b56 100644 --- a/app-config/nginx/nginx.conf +++ b/app-config/nginx/nginx.conf @@ -70,7 +70,7 @@ http { # Pass the request on to the webservice. Most likely the URI won't # exist so we get a 404 from that service instead (good as the 404 # pages are consistent). - proxy_pass http://cara-webservice:8080/$request_uri; + proxy_pass http://caimira-webservice:8080/$request_uri; } location /voila-server/ { @@ -81,21 +81,21 @@ http { error_page 401 = @error401; error_page 404 = @proxy_404_error_handler; - # cara-app is the name of the voila server in each of docker-compose, - # test-cara.web.cern.ch and cara.web.cern.ch. - proxy_pass http://cara-app:8080/voila-server/; + # caimira-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://caimira-app:8080/voila-server/; } - rewrite ^/expert-app$ /voila-server/voila/render/cara.ipynb last; + 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/cara.ipynb. + # Before implementing the nginx router we could access /voila/render/caimira.ipynb. # Redirect this (and all other) URLs to the new scheme. absolute_redirect off; rewrite ^/voila/(.*)$ /voila-server/voila/$1 redirect; location / { # By default we have no authentication. - proxy_pass http://cara-webservice:8080; + proxy_pass http://caimira-webservice:8080; } location /calculator { @@ -107,14 +107,14 @@ http { auth_request /auth/probe; error_page 401 = @error401; - # cara-webservice is the name of the tornado server (for the calculator) - # in each of docker-compose, test-cara.web.cern.ch and cara.web.cern.ch. - proxy_pass http://cara-webservice:8080/calculator-cern; + # caimira-webservice is the name of the tornado server (for the calculator) + # in each of docker-compose, caimira-test.web.cern.ch and caimira.web.cern.ch. + proxy_pass http://caimira-webservice:8080/calculator-cern; } location /calculator-open { # Public open calculator - proxy_pass http://cara-calculator-open:8080/calculator-open; + proxy_pass http://caimira-calculator-open:8080/calculator-open; } } } diff --git a/app-config/openshift/buildconfig.yaml b/app-config/openshift/buildconfig.yaml index 9bcbc165..3fa3bcdb 100644 --- a/app-config/openshift/buildconfig.yaml +++ b/app-config/openshift/buildconfig.yaml @@ -2,21 +2,21 @@ kind: "Template" apiVersion: template.openshift.io/v1 metadata: - name: "cara-application" + name: "caimira-application" creationTimestamp: null annotations: - description: "CARA build config OpenShift template." - tags: "cara-application" + description: "CAiMIRA build config OpenShift template." + tags: "caimira-application" labels: - template: "cara-application" + template: "caimira-application" objects: - kind: BuildConfig apiVersion: build.openshift.io/v1 metadata: - name: cara-router + name: caimira-router labels: - template: "cara-application" + template: "caimira-application" spec: source: type: Git @@ -24,15 +24,13 @@ ref: ${GIT_BRANCH} uri: ${GIT_REPO} contextDir: app-config/nginx - sourceSecret: - name: sshdeploykey postCommit: {} resources: {} runPolicy: Serial output: to: kind: ImageStreamTag - name: 'cara-router:latest' + name: 'caimira-router:latest' strategy: sourceStrategy: from: @@ -46,13 +44,13 @@ - type: ConfigChange - generic: secretReference: - name: gitlab-cara-webhook-secret + name: gitlab-caimira-webhook-secret type: Generic nodeSelector: null parameters: - name: GIT_REPO description: The GIT repo URL - value: 'ssh://git@gitlab.cern.ch:7999/cara/cara.git' + value: 'https://gitlab.cern.ch/cara/cara.git' - name: GIT_BRANCH - description: The name of the GIT branch to use when building the app, e.g. `live/test-cara` in TEST, `master` in prod + description: The name of the GIT branch to use when building the app, e.g. `live/caimira-test` in TEST, `master` in prod required: true diff --git a/app-config/openshift/config-fetch.py b/app-config/openshift/config-fetch.py index c596c31c..ee737b0d 100644 --- a/app-config/openshift/config-fetch.py +++ b/app-config/openshift/config-fetch.py @@ -6,10 +6,10 @@ import typing def configure_parser(parser: argparse.ArgumentParser) -> None: - parser.description = "Fetch the openshift config for CARA" + parser.description = "Fetch the openshift config for CAiMIRA" parser.set_defaults(handler=handler) parser.add_argument( - "instance", choices=['cara-prod', 'test-cara'], + "instance", choices=['caimira-prod', 'caimira-test'], help="Pick the instance for which you want to fetch the config", ) parser.add_argument( @@ -53,10 +53,10 @@ def fetch_config(output_directory: pathlib.Path): def handler(args: argparse.ArgumentParser) -> None: login_server = 'https://api.paas.okd.cern.ch:443' - if args.instance == 'cara-prod': - project_name = 'cara-prod' - elif args.instance == 'test-cara': - project_name = 'test-cara' + if args.instance == 'caimira-prod': + project_name = 'caimira-prod' + elif args.instance == 'caimira-test': + project_name = 'caimira-test' actual_login_server = get_oc_server() if actual_login_server != login_server: diff --git a/app-config/openshift/config-generate.py b/app-config/openshift/config-generate.py index 3a33db5b..e8a0eec8 100644 --- a/app-config/openshift/config-generate.py +++ b/app-config/openshift/config-generate.py @@ -8,7 +8,7 @@ def configure_parser(parser: argparse.ArgumentParser) -> None: parser.description = "Generate the config files which can be later submitted to openshift" parser.set_defaults(handler=handler) parser.add_argument( - "instance", choices=['cara-prod', 'test-cara'], + "instance", choices=['caimira-prod', 'caimira-test'], help="Pick the instance for which you want to generate the config", ) parser.add_argument( @@ -38,14 +38,14 @@ def generate_config(output_directory: pathlib.Path, project_name: str, hostname: def handler(args: argparse.ArgumentParser) -> None: - if args.instance == 'cara-prod': - project_name = 'cara-prod' + if args.instance == 'caimira-prod': + project_name = 'caimira-prod' branch = 'master' - hostname = 'cara.web.cern.ch' - elif args.instance == 'test-cara': - project_name = 'test-cara' - branch = 'live/test-cara' - hostname = 'test-cara.web.cern.ch' + hostname = 'caimira.web.cern.ch' + elif args.instance == 'caimira-test': + project_name = 'caimira-test' + branch = 'live/caimira-test' + hostname = 'caimira-test.web.cern.ch' generate_config(pathlib.Path(args.output_directory), project_name, hostname, branch) diff --git a/app-config/openshift/configmap.yaml b/app-config/openshift/configmap.yaml index 9b6e2cbf..383e7456 100644 --- a/app-config/openshift/configmap.yaml +++ b/app-config/openshift/configmap.yaml @@ -2,12 +2,12 @@ kind: "Template" apiVersion: template.openshift.io/v1 metadata: - name: "cara-configuration" + name: "caimira-configuration" annotations: - description: "CARA configuration OpenShift template." - tags: "cara-configuration" + description: "CAiMIRA configuration OpenShift template." + tags: "caimira-configuration" labels: - template: "cara-configuration" + template: "caimira-configuration" objects: - apiVersion: v1 diff --git a/app-config/openshift/deploymentconfig.yaml b/app-config/openshift/deploymentconfig.yaml index 67d9e6e5..520fa088 100644 --- a/app-config/openshift/deploymentconfig.yaml +++ b/app-config/openshift/deploymentconfig.yaml @@ -2,12 +2,12 @@ kind: "Template" apiVersion: template.openshift.io/v1 metadata: - name: "cara-application" + name: "caimira-application" annotations: - description: "CARA application OpenShift template." - tags: "cara-application" + description: "CAiMIRA application OpenShift template." + tags: "caimira-application" labels: - template: "cara-application" + template: "caimira-application" objects: - apiVersion: apps.openshift.io/v1 @@ -72,21 +72,21 @@ apiVersion: apps.openshift.io/v1 kind: DeploymentConfig metadata: - name: cara-app - labels: {app: cara-app} + name: caimira-app + labels: {app: caimira-app} spec: replicas: 1 template: metadata: labels: - app: cara-app + app: caimira-app spec: containers: - - name: cara-webservice + - name: caimira-webservice env: - name: APP_NAME - value: cara-voila - image: '${PROJECT_NAME}/cara-webservice' + value: caimira-voila + image: '${PROJECT_NAME}/caimira-webservice' ports: - containerPort: 8080 protocol: TCP @@ -113,33 +113,33 @@ type: Rolling test: false selector: - app: cara-app + app: caimira-app triggers: - type: ConfigChange - type: ImageChange imageChangeParams: automatic: true containerNames: - - cara-webservice + - caimira-webservice from: kind: ImageStreamTag - name: 'cara-webservice:latest' + name: 'caimira-webservice:latest' namespace: ${PROJECT_NAME} - apiVersion: apps.openshift.io/v1 kind: DeploymentConfig metadata: - name: cara-router + name: caimira-router spec: replicas: 1 template: metadata: labels: - app: cara-router + app: caimira-router spec: containers: - - name: cara-router - image: '${PROJECT_NAME}/cara-router' + - name: caimira-router + image: '${PROJECT_NAME}/caimira-router' ports: - containerPort: 8080 protocol: TCP @@ -166,35 +166,35 @@ type: Rolling test: false selector: - app: cara-router + app: caimira-router triggers: - type: ImageChange imageChangeParams: automatic: true containerNames: - - cara-router + - caimira-router from: kind: ImageStreamTag - name: 'cara-router:latest' + name: 'caimira-router:latest' namespace: ${PROJECT_NAME} - type: ConfigChange - apiVersion: apps.openshift.io/v1 kind: DeploymentConfig metadata: - name: cara-webservice + name: caimira-webservice labels: - image: cara-webservice - app: cara-webservice + image: caimira-webservice + app: caimira-webservice spec: replicas: 1 template: metadata: labels: - app: cara-webservice + app: caimira-webservice spec: containers: - - name: cara-webservice + - name: caimira-webservice env: - name: COOKIE_SECRET valueFrom: @@ -204,12 +204,12 @@ - name: REPORT_PARALLELISM value: '3' - name: APP_NAME - value: cara-webservice - - name: CARA_CALCULATOR_PREFIX + value: caimira-webservice + - name: CAIMIRA_CALCULATOR_PREFIX value: /calculator-cern - - name: CARA_THEME - value: cara/apps/templates/cern - image: '${PROJECT_NAME}/cara-webservice' + - name: CAIMIRA_THEME + value: caimira/apps/templates/cern + image: '${PROJECT_NAME}/caimira-webservice' ports: - containerPort: 8080 protocol: TCP @@ -250,41 +250,41 @@ type: Rolling test: false selector: - app: cara-webservice + app: caimira-webservice triggers: - type: ImageChange imageChangeParams: automatic: true containerNames: - - cara-webservice + - caimira-webservice from: kind: ImageStreamTag - name: 'cara-webservice:latest' + name: 'caimira-webservice:latest' namespace: ${PROJECT_NAME} - type: ConfigChange - apiVersion: apps.openshift.io/v1 kind: DeploymentConfig metadata: - name: cara-calculator-open + name: caimira-calculator-open labels: - image: cara-webservice - app: cara-calculator-open + image: caimira-webservice + app: caimira-calculator-open spec: replicas: 1 template: metadata: labels: - app: cara-calculator-open + app: caimira-calculator-open spec: containers: - - name: cara-calculator-open + - name: caimira-calculator-open env: - name: APP_NAME - value: cara-webservice - - name: CARA_CALCULATOR_PREFIX + value: caimira-webservice + - name: CAIMIRA_CALCULATOR_PREFIX value: /calculator-open - image: '${PROJECT_NAME}/cara-webservice' + image: '${PROJECT_NAME}/caimira-webservice' ports: - containerPort: 8080 protocol: TCP @@ -315,21 +315,21 @@ type: Rolling test: false selector: - app: cara-calculator-open + app: caimira-calculator-open triggers: - type: ConfigChange - type: ImageChange imageChangeParams: automatic: true containerNames: - - cara-calculator-open + - caimira-calculator-open from: kind: ImageStreamTag - name: 'cara-webservice:latest' + name: 'caimira-webservice:latest' namespace: ${PROJECT_NAME} - type: ConfigChange parameters: - name: PROJECT_NAME - description: The name of this project, e.g. test-cara + description: The name of this project, e.g. caimira-test required: true diff --git a/app-config/openshift/imagestreams.yaml b/app-config/openshift/imagestreams.yaml index 5a3205c5..86a4780d 100644 --- a/app-config/openshift/imagestreams.yaml +++ b/app-config/openshift/imagestreams.yaml @@ -2,13 +2,13 @@ kind: "Template" apiVersion: template.openshift.io/v1 metadata: - name: "cara-imagestreams" + name: "caimira-imagestreams" creationTimestamp: null annotations: - description: "CARA imagestreams OpenShift template." - tags: "cara-imagestreams" + description: "CAiMIRA imagestreams OpenShift template." + tags: "caimira-imagestreams" labels: - template: "cara-application" + template: "caimira-application" objects: - kind: ImageStream @@ -22,7 +22,7 @@ kind: ImageStream apiVersion: image.openshift.io/v1 metadata: - name: cara-router + name: caimira-router spec: lookupPolicy: local: False @@ -30,7 +30,15 @@ kind: ImageStream apiVersion: image.openshift.io/v1 metadata: - name: cara-webservice + name: caimira-webservice + spec: + lookupPolicy: + local: False + - + kind: ImageStream + apiVersion: image.openshift.io/v1 + metadata: + name: calculator spec: lookupPolicy: local: False diff --git a/app-config/openshift/routes.example.yaml b/app-config/openshift/routes.example.yaml index a7f0f0e1..262b73cc 100644 --- a/app-config/openshift/routes.example.yaml +++ b/app-config/openshift/routes.example.yaml @@ -2,21 +2,21 @@ kind: "Template" apiVersion: template.openshift.io/v1 metadata: - name: "cara-route" + name: "caimira-route" creationTimestamp: null annotations: - description: "CARA route OpenShift template." - tags: "cara-route" + description: "CAiMIRA route OpenShift template." + tags: "caimira-route" labels: - template: "cara-route" + template: "caimira-route" objects: - apiVersion: route.openshift.io/v1 kind: Route metadata: - name: cara-route + name: caimira-route labels: - app: "cara-route" + app: "caimira-route" spec: host: ${HOST} port: @@ -26,12 +26,12 @@ termination: edge to: kind: Service - name: cara-router + name: caimira-router weight: 100 wildcardPolicy: None parameters: - name: HOST - description: The hostname of the site, e.g. test-cara.web.cern.ch + description: The hostname of the site, e.g. caimira-test.web.cern.ch required: true diff --git a/app-config/openshift/services.yaml b/app-config/openshift/services.yaml index d5de132e..d6aaf814 100644 --- a/app-config/openshift/services.yaml +++ b/app-config/openshift/services.yaml @@ -2,13 +2,13 @@ kind: "Template" apiVersion: template.openshift.io/v1 metadata: - name: "cara-services" + name: "caimira-services" creationTimestamp: null annotations: - description: "CARA services OpenShift template." - tags: "cara-services" + description: "CAiMIRA services OpenShift template." + tags: "caimira-services" labels: - template: "cara-services" + template: "caimira-services" objects: - apiVersion: v1 @@ -32,8 +32,8 @@ kind: Service metadata: labels: - app: cara-app - name: cara-app + app: caimira-app + name: caimira-app spec: ports: - name: 8080-tcp @@ -41,7 +41,7 @@ protocol: TCP targetPort: 8080 selector: - deploymentconfig: cara-app + deploymentconfig: caimira-app sessionAffinity: 'None' type: 'ClusterIP' - @@ -49,8 +49,8 @@ kind: Service metadata: labels: - app: cara-router - name: cara-router + app: caimira-router + name: caimira-router spec: ports: - name: 8080-tcp @@ -58,7 +58,7 @@ protocol: TCP targetPort: 8080 selector: - deploymentconfig: cara-router + deploymentconfig: caimira-router sessionAffinity: 'None' type: 'ClusterIP' - @@ -66,8 +66,8 @@ kind: Service metadata: labels: - app: cara-webservice - name: cara-webservice + app: caimira-webservice + name: caimira-webservice spec: ports: - name: 8080-tcp @@ -75,7 +75,7 @@ protocol: TCP targetPort: 8080 selector: - deploymentconfig: cara-webservice + deploymentconfig: caimira-webservice sessionAffinity: 'None' type: 'ClusterIP' - @@ -83,8 +83,8 @@ kind: Service metadata: labels: - app: cara-calculator-open - name: cara-calculator-open + app: caimira-calculator-open + name: caimira-calculator-open spec: ports: - name: 8080-tcp @@ -92,6 +92,6 @@ protocol: TCP targetPort: 8080 selector: - deploymentconfig: cara-calculator-open + deploymentconfig: caimira-calculator-open sessionAffinity: 'None' type: 'ClusterIP' diff --git a/cara/__init__.py b/caimira/__init__.py similarity index 52% rename from cara/__init__.py rename to caimira/__init__.py index 0561df4a..cf04da3a 100644 --- a/cara/__init__.py +++ b/caimira/__init__.py @@ -1,7 +1,7 @@ -# This module is part of CARA. Please see the repository at +# This module is part of CAiMIRA. Please see the repository at # https://gitlab.cern.ch/cara/cara for details of the license and terms of use. """ -Documentation for the CARA package +Documentation for the CAiMIRA package """ diff --git a/cara/apps/__init__.py b/caimira/apps/__init__.py similarity index 100% rename from cara/apps/__init__.py rename to caimira/apps/__init__.py diff --git a/cara/apps/calculator/__init__.py b/caimira/apps/calculator/__init__.py similarity index 96% rename from cara/apps/calculator/__init__.py rename to caimira/apps/calculator/__init__.py index 40a13f1a..2010a624 100644 --- a/cara/apps/calculator/__init__.py +++ b/caimira/apps/calculator/__init__.py @@ -1,4 +1,4 @@ -# This module is part of CARA. Please see the repository at +# This module is part of CAiMIRA. Please see the repository at # https://gitlab.cern.ch/cara/cara for details of the license and terms of use. import asyncio @@ -31,7 +31,7 @@ from .user import AuthenticatedUser, AnonymousUser # Effectively, if the model increases its MAJOR version then so too should this # calculator version. If the calculator needs to make breaking changes (e.g. change # form attributes) then it can also increase its MAJOR version without needing to -# increase the overall CARA version (found at ``cara.__version__``). +# increase the overall CAiMIRA version (found at ``caimira.__version__``). __version__ = "4.2" @@ -40,7 +40,7 @@ class BaseRequestHandler(RequestHandler): """Called at the beginning of a request before `get`/`post`/etc.""" # Read the secure cookie which exists if we are in an authenticated - # context (though not if the cara webservice is running standalone). + # context (though not if the caimira webservice is running standalone). session = json.loads(self.get_secure_cookie('session') or 'null') if session: @@ -60,7 +60,7 @@ class BaseRequestHandler(RequestHandler): contents = ( f'Unfortunately an error occurred when processing your request. ' f'Please let us know about this issue with as much detail as possible at ' - f'CARA-dev@cern.ch, reporting status ' + f'CAiMIRA-dev@cern.ch, reporting status ' f'code {status_code}, the error id of "{error_id}" and the time of the ' f'request ({datetime.datetime.utcnow()}).



' ) @@ -269,9 +269,9 @@ def make_app( (calculator_prefix + r'/static/(.*)', StaticFileHandler, {'path': calculator_static_dir}), ] - cara_templates = Path(__file__).parent.parent / "templates" + caimira_templates = Path(__file__).parent.parent / "templates" calculator_templates = Path(__file__).parent / "templates" - templates_directories = [cara_templates, calculator_templates] + templates_directories = [caimira_templates, calculator_templates] if theme_dir: templates_directories.insert(0, theme_dir) loader = jinja2.FileSystemLoader([str(path) for path in templates_directories]) diff --git a/cara/apps/calculator/__main__.py b/caimira/apps/calculator/__main__.py similarity index 100% rename from cara/apps/calculator/__main__.py rename to caimira/apps/calculator/__main__.py diff --git a/cara/apps/calculator/markdown_tools.py b/caimira/apps/calculator/markdown_tools.py similarity index 100% rename from cara/apps/calculator/markdown_tools.py rename to caimira/apps/calculator/markdown_tools.py diff --git a/cara/apps/calculator/model_generator.py b/caimira/apps/calculator/model_generator.py similarity index 98% rename from cara/apps/calculator/model_generator.py rename to caimira/apps/calculator/model_generator.py index 9f9dbce3..254ae02c 100644 --- a/cara/apps/calculator/model_generator.py +++ b/caimira/apps/calculator/model_generator.py @@ -8,13 +8,13 @@ import json import numpy as np -from cara import models -from cara import data -import cara.data.weather -import cara.monte_carlo as mc +from caimira import models +from caimira import data +import caimira.data.weather +import caimira.monte_carlo as mc from .. import calculator -from cara.monte_carlo.data import activity_distributions, virus_distributions, mask_distributions, short_range_distances -from cara.monte_carlo.data import expiration_distribution, expiration_BLO_factors, expiration_distributions, short_range_expiration_distributions +from caimira.monte_carlo.data import activity_distributions, virus_distributions, mask_distributions, short_range_distances +from caimira.monte_carlo.data import expiration_distribution, expiration_BLO_factors, expiration_distributions, short_range_expiration_distributions LOG = logging.getLogger(__name__) @@ -330,7 +330,7 @@ class FormData: """ month = MONTH_NAMES.index(self.event_month) + 1 - timezone = cara.data.weather.timezone_at( + timezone = caimira.data.weather.timezone_at( latitude=self.location_latitude, longitude=self.location_longitude, ) # We choose the first of the month for the current year. @@ -351,7 +351,7 @@ class FormData: month = MONTH_NAMES.index(self.event_month) + 1 wx_station = self.nearest_weather_station() - temp_profile = cara.data.weather.mean_hourly_temperatures(wx_station[0], month) + temp_profile = caimira.data.weather.mean_hourly_temperatures(wx_station[0], month) _, utc_offset = self.tz_name_and_utc_offset() @@ -359,7 +359,7 @@ class FormData: # result the first data value may no longer be a midnight, and the hours # no longer ordered modulo 24). source_times = np.arange(24) + utc_offset - times, temp_profile = cara.data.weather.refine_hourly_data( + times, temp_profile = caimira.data.weather.refine_hourly_data( source_times, temp_profile, npts=24*10, # 10 steps per hour => 6 min steps @@ -418,9 +418,9 @@ class FormData: else: return models.MultipleVentilation((ventilation, infiltration_ventilation)) - def nearest_weather_station(self) -> cara.data.weather.WxStationRecordType: + def nearest_weather_station(self) -> caimira.data.weather.WxStationRecordType: """Return the nearest weather station (which has valid data) for this form""" - return cara.data.weather.nearest_wx_station( + return caimira.data.weather.nearest_wx_station( longitude=self.location_longitude, latitude=self.location_latitude ) diff --git a/cara/apps/calculator/report_generator.py b/caimira/apps/calculator/report_generator.py similarity index 99% rename from cara/apps/calculator/report_generator.py rename to caimira/apps/calculator/report_generator.py index 7ed38634..1a7cdf02 100644 --- a/cara/apps/calculator/report_generator.py +++ b/caimira/apps/calculator/report_generator.py @@ -11,8 +11,8 @@ import zlib import jinja2 import numpy as np -from cara import models -from cara.apps.calculator import markdown_tools +from caimira import models +from caimira.apps.calculator import markdown_tools from ... import monte_carlo as mc from .model_generator import FormData, _DEFAULT_MC_SAMPLE_SIZE from ... import dataclass_utils diff --git a/cara/apps/calculator/static/css/form.css b/caimira/apps/calculator/static/css/form.css similarity index 100% rename from cara/apps/calculator/static/css/form.css rename to caimira/apps/calculator/static/css/form.css diff --git a/cara/apps/calculator/static/css/report.css b/caimira/apps/calculator/static/css/report.css similarity index 100% rename from cara/apps/calculator/static/css/report.css rename to caimira/apps/calculator/static/css/report.css diff --git a/cara/apps/calculator/static/images/disclaimer.jpg b/caimira/apps/calculator/static/images/disclaimer.jpg similarity index 100% rename from cara/apps/calculator/static/images/disclaimer.jpg rename to caimira/apps/calculator/static/images/disclaimer.jpg diff --git a/cara/apps/calculator/static/images/warning_scale/green-1.png b/caimira/apps/calculator/static/images/warning_scale/green-1.png similarity index 100% rename from cara/apps/calculator/static/images/warning_scale/green-1.png rename to caimira/apps/calculator/static/images/warning_scale/green-1.png diff --git a/cara/apps/calculator/static/images/warning_scale/orange-3.png b/caimira/apps/calculator/static/images/warning_scale/orange-3.png similarity index 100% rename from cara/apps/calculator/static/images/warning_scale/orange-3.png rename to caimira/apps/calculator/static/images/warning_scale/orange-3.png diff --git a/cara/apps/calculator/static/images/warning_scale/red-4.png b/caimira/apps/calculator/static/images/warning_scale/red-4.png similarity index 100% rename from cara/apps/calculator/static/images/warning_scale/red-4.png rename to caimira/apps/calculator/static/images/warning_scale/red-4.png diff --git a/cara/apps/calculator/static/images/warning_scale/yellow-2.png b/caimira/apps/calculator/static/images/warning_scale/yellow-2.png similarity index 100% rename from cara/apps/calculator/static/images/warning_scale/yellow-2.png rename to caimira/apps/calculator/static/images/warning_scale/yellow-2.png diff --git a/cara/apps/calculator/static/images/window_opening.png b/caimira/apps/calculator/static/images/window_opening.png similarity index 100% rename from cara/apps/calculator/static/images/window_opening.png rename to caimira/apps/calculator/static/images/window_opening.png diff --git a/cara/apps/calculator/static/images/window_type.PNG b/caimira/apps/calculator/static/images/window_type.PNG similarity index 100% rename from cara/apps/calculator/static/images/window_type.PNG rename to caimira/apps/calculator/static/images/window_type.PNG diff --git a/cara/apps/calculator/static/js/form.js b/caimira/apps/calculator/static/js/form.js similarity index 100% rename from cara/apps/calculator/static/js/form.js rename to caimira/apps/calculator/static/js/form.js diff --git a/cara/apps/calculator/static/js/report.js b/caimira/apps/calculator/static/js/report.js similarity index 100% rename from cara/apps/calculator/static/js/report.js rename to caimira/apps/calculator/static/js/report.js diff --git a/cara/apps/calculator/user.py b/caimira/apps/calculator/user.py similarity index 100% rename from cara/apps/calculator/user.py rename to caimira/apps/calculator/user.py diff --git a/cara/apps/expert.py b/caimira/apps/expert.py similarity index 99% rename from cara/apps/expert.py rename to caimira/apps/expert.py index d61365d5..d3740bbf 100644 --- a/cara/apps/expert.py +++ b/caimira/apps/expert.py @@ -11,7 +11,7 @@ import matplotlib.patches as patches from matplotlib import pyplot as plt import numpy as np -from cara import data, models, state +from caimira import data, models, state def collapsible(widgets_to_collapse: typing.List, title: str, start_collapsed=False): @@ -850,7 +850,7 @@ baseline_model = models.ExposureModel( ) -class CARAStateBuilder(state.StateBuilder): +class CAIMIRAStateBuilder(state.StateBuilder): # Note: The methods in this class must correspond to the *type* of the data classes. # For example, build_type__VentilationBase is called when dealing with ConcentrationModel # types as it has a ventilation: _VentilationBase field. @@ -928,7 +928,7 @@ class ExpertApplication(Controller): def build_new_model(self) -> state.DataclassInstanceState[models.ExposureModel]: default_model = state.DataclassInstanceState( models.ExposureModel, - state_builder=CARAStateBuilder(), + state_builder=CAIMIRAStateBuilder(), ) default_model.dcs_update_from(baseline_model) # For the time-being, we have to initialise the select states. Careful diff --git a/cara/apps/expert/cara.ipynb b/caimira/apps/expert/caimira.ipynb similarity index 79% rename from cara/apps/expert/cara.ipynb rename to caimira/apps/expert/caimira.ipynb index 2c624082..747ab1e9 100644 --- a/cara/apps/expert/cara.ipynb +++ b/caimira/apps/expert/caimira.ipynb @@ -7,7 +7,7 @@ "
\n", "
\n", "

\n", - "Please see the CAiMIRA homepage for details on the methodology, assumptions and limitations of CAiMIRA.

" + "Please see the CAiMIRA homepage for details on the methodology, assumptions and limitations of CAiMIRA.

" ] }, { @@ -21,9 +21,9 @@ }, "outputs": [], "source": [ - "import cara.apps\n", + "import caimira.apps\n", "\n", - "app = cara.apps.ExpertApplication()\n", + "app = caimira.apps.ExpertApplication()\n", "app.widget" ] } diff --git a/cara/apps/expert/static/images/header_image.png b/caimira/apps/expert/static/images/header_image.png similarity index 100% rename from cara/apps/expert/static/images/header_image.png rename to caimira/apps/expert/static/images/header_image.png diff --git a/cara/apps/static/css/style.css b/caimira/apps/static/css/style.css similarity index 98% rename from cara/apps/static/css/style.css rename to caimira/apps/static/css/style.css index fb6e2939..fa7d0d11 100644 --- a/cara/apps/static/css/style.css +++ b/caimira/apps/static/css/style.css @@ -92,7 +92,7 @@ body { height: 10em; } -.cara_home_image { +.caimira_home_image { height: 18rem; padding: 1rem; border-radius: 1.25rem!important; @@ -258,11 +258,11 @@ footer img { font-size:1rem; font-weight:bold; } - .cara_version { + .caimira_version { float:left; font-size:1rem; } - .cara_home_image { + .caimira_home_image { float: right; } @@ -314,7 +314,7 @@ footer img { font-size:.75rem; font-weight:bold; } - .cara_version { + .caimira_version { float:left; font-size:.75rem; } diff --git a/cara/apps/static/icons/calculator.svg b/caimira/apps/static/icons/calculator.svg similarity index 100% rename from cara/apps/static/icons/calculator.svg rename to caimira/apps/static/icons/calculator.svg diff --git a/cara/apps/static/icons/expert.svg b/caimira/apps/static/icons/expert.svg similarity index 100% rename from cara/apps/static/icons/expert.svg rename to caimira/apps/static/icons/expert.svg diff --git a/cara/apps/static/images/CAiMIRA_1_Vs3_Colour.jpg b/caimira/apps/static/images/CAiMIRA_1_Vs3_Colour.jpg similarity index 100% rename from cara/apps/static/images/CAiMIRA_1_Vs3_Colour.jpg rename to caimira/apps/static/images/CAiMIRA_1_Vs3_Colour.jpg diff --git a/cara/apps/static/images/caimira_full_logo.png b/caimira/apps/static/images/caimira_full_logo.png similarity index 100% rename from cara/apps/static/images/caimira_full_logo.png rename to caimira/apps/static/images/caimira_full_logo.png diff --git a/cara/apps/static/images/caimira_full_text.png b/caimira/apps/static/images/caimira_full_text.png similarity index 100% rename from cara/apps/static/images/caimira_full_text.png rename to caimira/apps/static/images/caimira_full_text.png diff --git a/cara/apps/static/images/caimira_logo.200x200.png b/caimira/apps/static/images/caimira_logo.200x200.png similarity index 100% rename from cara/apps/static/images/caimira_logo.200x200.png rename to caimira/apps/static/images/caimira_logo.200x200.png diff --git a/cara/apps/static/images/caimira_logo_white_text.png b/caimira/apps/static/images/caimira_logo_white_text.png similarity index 100% rename from cara/apps/static/images/caimira_logo_white_text.png rename to caimira/apps/static/images/caimira_logo_white_text.png diff --git a/cara/apps/static/images/long_range_anim.png b/caimira/apps/static/images/long_range_anim.png similarity index 100% rename from cara/apps/static/images/long_range_anim.png rename to caimira/apps/static/images/long_range_anim.png diff --git a/cara/apps/static/images/masks/ffp2.png b/caimira/apps/static/images/masks/ffp2.png similarity index 100% rename from cara/apps/static/images/masks/ffp2.png rename to caimira/apps/static/images/masks/ffp2.png diff --git a/cara/apps/static/images/masks/t1.png b/caimira/apps/static/images/masks/t1.png similarity index 100% rename from cara/apps/static/images/masks/t1.png rename to caimira/apps/static/images/masks/t1.png diff --git a/cara/apps/static/images/nat_vent_dimensions.png b/caimira/apps/static/images/nat_vent_dimensions.png similarity index 100% rename from cara/apps/static/images/nat_vent_dimensions.png rename to caimira/apps/static/images/nat_vent_dimensions.png diff --git a/cara/apps/static/images/short_range_anim.png b/caimira/apps/static/images/short_range_anim.png similarity index 100% rename from cara/apps/static/images/short_range_anim.png rename to caimira/apps/static/images/short_range_anim.png diff --git a/cara/apps/static/js/ScrollMagic.min.js b/caimira/apps/static/js/ScrollMagic.min.js similarity index 100% rename from cara/apps/static/js/ScrollMagic.min.js rename to caimira/apps/static/js/ScrollMagic.min.js diff --git a/cara/apps/static/js/jquery.colorbox-min.js b/caimira/apps/static/js/jquery.colorbox-min.js similarity index 100% rename from cara/apps/static/js/jquery.colorbox-min.js rename to caimira/apps/static/js/jquery.colorbox-min.js diff --git a/cara/apps/static/js/js_packaged_for_theme.js b/caimira/apps/static/js/js_packaged_for_theme.js similarity index 100% rename from cara/apps/static/js/js_packaged_for_theme.js rename to caimira/apps/static/js/js_packaged_for_theme.js diff --git a/cara/apps/static/js/usage-tracking.js b/caimira/apps/static/js/usage-tracking.js similarity index 91% rename from cara/apps/static/js/usage-tracking.js rename to caimira/apps/static/js/usage-tracking.js index 60ac23c5..830b9894 100644 --- a/cara/apps/static/js/usage-tracking.js +++ b/caimira/apps/static/js/usage-tracking.js @@ -1,4 +1,4 @@ -if (document.location.hostname == "test-cara.web.cern.ch") { +if (document.location.hostname == "caimira-test.web.cern.ch") { var _paq = _paq || []; if (typeof AuthUserDomain !== 'undefined') { _paq.push(["setCustomVariable", 1, "AuthUserDomain", AuthUserDomain, "visit"]); @@ -18,7 +18,7 @@ if (document.location.hostname == "test-cara.web.cern.ch") { g.src = u + "piwik.js"; s.parentNode.insertBefore(g, s); })(); -} else if (document.location.hostname == "cara.web.cern.ch") { +} else if (document.location.hostname == "caimira.web.cern.ch") { var _paq = _paq || []; if (typeof AuthUserDomain !== 'undefined') { _paq.push(["setCustomVariable", 1, "AuthUserDomain", AuthUserDomain, "visit"]); diff --git a/cara/apps/templates/about.html.j2 b/caimira/apps/templates/about.html.j2 similarity index 100% rename from cara/apps/templates/about.html.j2 rename to caimira/apps/templates/about.html.j2 diff --git a/cara/apps/templates/base/calculator.form.html.j2 b/caimira/apps/templates/base/calculator.form.html.j2 similarity index 99% rename from cara/apps/templates/base/calculator.form.html.j2 rename to caimira/apps/templates/base/calculator.form.html.j2 index dc177114..37699a44 100644 --- a/cara/apps/templates/base/calculator.form.html.j2 +++ b/caimira/apps/templates/base/calculator.form.html.j2 @@ -18,7 +18,7 @@ {% block main %} -v{{ calculator_version }} +v{{ calculator_version }} Please send feedback to CAiMIRA-dev@cern.ch
diff --git a/cara/apps/templates/base/calculator.report.html.j2 b/caimira/apps/templates/base/calculator.report.html.j2 similarity index 100% rename from cara/apps/templates/base/calculator.report.html.j2 rename to caimira/apps/templates/base/calculator.report.html.j2 diff --git a/cara/apps/templates/base/index.html.j2 b/caimira/apps/templates/base/index.html.j2 similarity index 98% rename from cara/apps/templates/base/index.html.j2 rename to caimira/apps/templates/base/index.html.j2 index a7d5d020..68727548 100644 --- a/cara/apps/templates/base/index.html.j2 +++ b/caimira/apps/templates/base/index.html.j2 @@ -30,7 +30,7 @@
- +

@@ -46,8 +46,8 @@
- {% block cara_at_cern %} - {% endblock cara_at_cern %} + {% block caimira_at_cern %} + {% endblock caimira_at_cern %}
diff --git a/cara/apps/templates/base/layout.html.j2 b/caimira/apps/templates/base/layout.html.j2 similarity index 100% rename from cara/apps/templates/base/layout.html.j2 rename to caimira/apps/templates/base/layout.html.j2 diff --git a/cara/apps/templates/base/userguide.html.j2 b/caimira/apps/templates/base/userguide.html.j2 similarity index 100% rename from cara/apps/templates/base/userguide.html.j2 rename to caimira/apps/templates/base/userguide.html.j2 diff --git a/cara/apps/templates/calculator.form.html.j2 b/caimira/apps/templates/calculator.form.html.j2 similarity index 100% rename from cara/apps/templates/calculator.form.html.j2 rename to caimira/apps/templates/calculator.form.html.j2 diff --git a/cara/apps/templates/calculator.report.html.j2 b/caimira/apps/templates/calculator.report.html.j2 similarity index 100% rename from cara/apps/templates/calculator.report.html.j2 rename to caimira/apps/templates/calculator.report.html.j2 diff --git a/cara/apps/templates/cern/calculator.form.html.j2 b/caimira/apps/templates/cern/calculator.form.html.j2 similarity index 100% rename from cara/apps/templates/cern/calculator.form.html.j2 rename to caimira/apps/templates/cern/calculator.form.html.j2 diff --git a/cara/apps/templates/cern/calculator.report.html.j2 b/caimira/apps/templates/cern/calculator.report.html.j2 similarity index 100% rename from cara/apps/templates/cern/calculator.report.html.j2 rename to caimira/apps/templates/cern/calculator.report.html.j2 diff --git a/cara/apps/templates/cern/index.html.j2 b/caimira/apps/templates/cern/index.html.j2 similarity index 89% rename from cara/apps/templates/cern/index.html.j2 rename to caimira/apps/templates/cern/index.html.j2 index 28c4b1ef..1dba0804 100644 --- a/cara/apps/templates/cern/index.html.j2 +++ b/caimira/apps/templates/cern/index.html.j2 @@ -1,6 +1,6 @@ {% extends "base/index.html.j2" %} -{% block cara_at_cern %} +{% block caimira_at_cern %}

CAiMIRA @ CERN


@@ -8,4 +8,4 @@ A hosted CERN version of the CAiMIRA Calculator is available on this site to members of the CERN personnel.

-{% endblock cara_at_cern %} \ No newline at end of file +{% endblock caimira_at_cern %} \ No newline at end of file diff --git a/cara/apps/templates/cern/layout.html.j2 b/caimira/apps/templates/cern/layout.html.j2 similarity index 100% rename from cara/apps/templates/cern/layout.html.j2 rename to caimira/apps/templates/cern/layout.html.j2 diff --git a/cara/apps/templates/cern/userguide.html.j2 b/caimira/apps/templates/cern/userguide.html.j2 similarity index 100% rename from cara/apps/templates/cern/userguide.html.j2 rename to caimira/apps/templates/cern/userguide.html.j2 diff --git a/cara/apps/templates/common_text.md.j2 b/caimira/apps/templates/common_text.md.j2 similarity index 100% rename from cara/apps/templates/common_text.md.j2 rename to caimira/apps/templates/common_text.md.j2 diff --git a/cara/apps/templates/index.html.j2 b/caimira/apps/templates/index.html.j2 similarity index 100% rename from cara/apps/templates/index.html.j2 rename to caimira/apps/templates/index.html.j2 diff --git a/cara/apps/templates/layout.html.j2 b/caimira/apps/templates/layout.html.j2 similarity index 100% rename from cara/apps/templates/layout.html.j2 rename to caimira/apps/templates/layout.html.j2 diff --git a/cara/apps/templates/page.html.j2 b/caimira/apps/templates/page.html.j2 similarity index 100% rename from cara/apps/templates/page.html.j2 rename to caimira/apps/templates/page.html.j2 diff --git a/cara/apps/templates/userguide.html.j2 b/caimira/apps/templates/userguide.html.j2 similarity index 100% rename from cara/apps/templates/userguide.html.j2 rename to caimira/apps/templates/userguide.html.j2 diff --git a/cara/data/__init__.py b/caimira/data/__init__.py similarity index 94% rename from cara/data/__init__.py rename to caimira/data/__init__.py index 9e6a523f..23dab962 100644 --- a/cara/data/__init__.py +++ b/caimira/data/__init__.py @@ -1,6 +1,6 @@ import numpy as np -from cara import models -from cara.data.weather import wx_data, nearest_wx_station +from caimira import models +from caimira.data.weather import wx_data, nearest_wx_station MONTH_NAMES = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', diff --git a/cara/data/global_weather_set.json b/caimira/data/global_weather_set.json similarity index 100% rename from cara/data/global_weather_set.json rename to caimira/data/global_weather_set.json diff --git a/cara/data/hadisd_station_fullinfo_v311_202001p.txt b/caimira/data/hadisd_station_fullinfo_v311_202001p.txt similarity index 100% rename from cara/data/hadisd_station_fullinfo_v311_202001p.txt rename to caimira/data/hadisd_station_fullinfo_v311_202001p.txt diff --git a/cara/data/weather.py b/caimira/data/weather.py similarity index 100% rename from cara/data/weather.py rename to caimira/data/weather.py diff --git a/cara/dataclass_utils.py b/caimira/dataclass_utils.py similarity index 100% rename from cara/dataclass_utils.py rename to caimira/dataclass_utils.py diff --git a/cara/docs/Makefile b/caimira/docs/Makefile similarity index 100% rename from cara/docs/Makefile rename to caimira/docs/Makefile diff --git a/cara/docs/UML-CARA.png b/caimira/docs/UML-CAiMIRA.png similarity index 100% rename from cara/docs/UML-CARA.png rename to caimira/docs/UML-CAiMIRA.png diff --git a/caimira/docs/caimira.apps.calculator.rst b/caimira/docs/caimira.apps.calculator.rst new file mode 100644 index 00000000..e1b10080 --- /dev/null +++ b/caimira/docs/caimira.apps.calculator.rst @@ -0,0 +1,45 @@ +caimira.apps.calculator package +=============================== + +Submodules +---------- + +caimira.apps.calculator.markdown\_tools module +---------------------------------------------- + +.. automodule:: caimira.apps.calculator.markdown_tools + :members: + :undoc-members: + :show-inheritance: + +caimira.apps.calculator.model\_generator module +----------------------------------------------- + +.. automodule:: caimira.apps.calculator.model_generator + :members: + :undoc-members: + :show-inheritance: + +caimira.apps.calculator.report\_generator module +------------------------------------------------ + +.. automodule:: caimira.apps.calculator.report_generator + :members: + :undoc-members: + :show-inheritance: + +caimira.apps.calculator.user module +----------------------------------- + +.. automodule:: caimira.apps.calculator.user + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: caimira.apps.calculator + :members: + :undoc-members: + :show-inheritance: diff --git a/cara/docs/cara.apps.rst b/caimira/docs/caimira.apps.rst similarity index 54% rename from cara/docs/cara.apps.rst rename to caimira/docs/caimira.apps.rst index be1ce1ed..24013a5c 100644 --- a/cara/docs/cara.apps.rst +++ b/caimira/docs/caimira.apps.rst @@ -1,5 +1,5 @@ -cara.apps package -================= +caimira.apps package +==================== Subpackages ----------- @@ -7,15 +7,15 @@ Subpackages .. toctree:: :maxdepth: 4 - cara.apps.calculator + caimira.apps.calculator Submodules ---------- -cara.apps.expert module ------------------------ +caimira.apps.expert module +-------------------------- -.. automodule:: cara.apps.expert +.. automodule:: caimira.apps.expert :members: :undoc-members: :show-inheritance: @@ -23,7 +23,7 @@ cara.apps.expert module Module contents --------------- -.. automodule:: cara.apps +.. automodule:: caimira.apps :members: :undoc-members: :show-inheritance: diff --git a/cara/docs/cara.data.rst b/caimira/docs/caimira.data.rst similarity index 50% rename from cara/docs/cara.data.rst rename to caimira/docs/caimira.data.rst index 144b4c62..4a011f08 100644 --- a/cara/docs/cara.data.rst +++ b/caimira/docs/caimira.data.rst @@ -1,13 +1,13 @@ -cara.data package -================= +caimira.data package +==================== Submodules ---------- -cara.data.weather module ------------------------- +caimira.data.weather module +--------------------------- -.. automodule:: cara.data.weather +.. automodule:: caimira.data.weather :members: :undoc-members: :show-inheritance: @@ -15,7 +15,7 @@ cara.data.weather module Module contents --------------- -.. automodule:: cara.data +.. automodule:: caimira.data :members: :undoc-members: :show-inheritance: diff --git a/caimira/docs/caimira.monte_carlo.rst b/caimira/docs/caimira.monte_carlo.rst new file mode 100644 index 00000000..38f81dd4 --- /dev/null +++ b/caimira/docs/caimira.monte_carlo.rst @@ -0,0 +1,37 @@ +caimira.monte\_carlo package +============================ + +Submodules +---------- + +caimira.monte\_carlo.data module +-------------------------------- + +.. automodule:: caimira.monte_carlo.data + :members: + :undoc-members: + :show-inheritance: + +caimira.monte\_carlo.models module +---------------------------------- + +.. automodule:: caimira.monte_carlo.models + :members: + :undoc-members: + :show-inheritance: + +caimira.monte\_carlo.sampleable module +-------------------------------------- + +.. automodule:: caimira.monte_carlo.sampleable + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: caimira.monte_carlo + :members: + :undoc-members: + :show-inheritance: diff --git a/caimira/docs/caimira.rst b/caimira/docs/caimira.rst new file mode 100644 index 00000000..0cfac4ec --- /dev/null +++ b/caimira/docs/caimira.rst @@ -0,0 +1,56 @@ +CAiMIRA source code +=================== + +Subpackages +----------- + +.. toctree:: + :maxdepth: 4 + + caimira.apps + caimira.data + caimira.monte_carlo + caimira.tests + +Submodules +---------- + +caimira.dataclass\_utils module +------------------------------- + +.. automodule:: caimira.dataclass_utils + :members: + :undoc-members: + :show-inheritance: + +caimira.models module +--------------------- + +.. automodule:: caimira.models + :members: + :undoc-members: + :show-inheritance: + +caimira.state module +-------------------- + +.. automodule:: caimira.state + :members: + :undoc-members: + :show-inheritance: + +caimira.utils module +-------------------- + +.. automodule:: caimira.utils + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: caimira + :members: + :undoc-members: + :show-inheritance: diff --git a/caimira/docs/caimira.tests.apps.calculator.rst b/caimira/docs/caimira.tests.apps.calculator.rst new file mode 100644 index 00000000..c5f7eb4e --- /dev/null +++ b/caimira/docs/caimira.tests.apps.calculator.rst @@ -0,0 +1,53 @@ +caimira.tests.apps.calculator package +===================================== + +Submodules +---------- + +caimira.tests.apps.calculator.conftest module +--------------------------------------------- + +.. automodule:: caimira.tests.apps.calculator.conftest + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.apps.calculator.test\_markdown\_tools module +---------------------------------------------------------- + +.. automodule:: caimira.tests.apps.calculator.test_markdown_tools + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.apps.calculator.test\_model\_generator module +----------------------------------------------------------- + +.. automodule:: caimira.tests.apps.calculator.test_model_generator + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.apps.calculator.test\_report\_generator module +------------------------------------------------------------ + +.. automodule:: caimira.tests.apps.calculator.test_report_generator + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.apps.calculator.test\_webapp module +------------------------------------------------- + +.. automodule:: caimira.tests.apps.calculator.test_webapp + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: caimira.tests.apps.calculator + :members: + :undoc-members: + :show-inheritance: diff --git a/caimira/docs/caimira.tests.apps.rst b/caimira/docs/caimira.tests.apps.rst new file mode 100644 index 00000000..a5f80cbc --- /dev/null +++ b/caimira/docs/caimira.tests.apps.rst @@ -0,0 +1,29 @@ +caimira.tests.apps package +========================== + +Subpackages +----------- + +.. toctree:: + :maxdepth: 4 + + caimira.tests.apps.calculator + +Submodules +---------- + +caimira.tests.apps.test\_expert\_app module +------------------------------------------- + +.. automodule:: caimira.tests.apps.test_expert_app + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: caimira.tests.apps + :members: + :undoc-members: + :show-inheritance: diff --git a/caimira/docs/caimira.tests.data.rst b/caimira/docs/caimira.tests.data.rst new file mode 100644 index 00000000..3ff1c2fc --- /dev/null +++ b/caimira/docs/caimira.tests.data.rst @@ -0,0 +1,21 @@ +caimira.tests.data package +========================== + +Submodules +---------- + +caimira.tests.data.test\_weather module +--------------------------------------- + +.. automodule:: caimira.tests.data.test_weather + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: caimira.tests.data + :members: + :undoc-members: + :show-inheritance: diff --git a/caimira/docs/caimira.tests.models.rst b/caimira/docs/caimira.tests.models.rst new file mode 100644 index 00000000..f70f7b25 --- /dev/null +++ b/caimira/docs/caimira.tests.models.rst @@ -0,0 +1,53 @@ +caimira.tests.models package +============================ + +Submodules +---------- + +caimira.tests.models.test\_concentration\_model module +------------------------------------------------------ + +.. automodule:: caimira.tests.models.test_concentration_model + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.models.test\_exposure\_model module +------------------------------------------------- + +.. automodule:: caimira.tests.models.test_exposure_model + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.models.test\_mask module +-------------------------------------- + +.. automodule:: caimira.tests.models.test_mask + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.models.test\_piecewiseconstant module +--------------------------------------------------- + +.. automodule:: caimira.tests.models.test_piecewiseconstant + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.models.test\_short\_range\_model module +----------------------------------------------------- + +.. automodule:: caimira.tests.models.test_short_range_model + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: caimira.tests.models + :members: + :undoc-members: + :show-inheritance: diff --git a/caimira/docs/caimira.tests.rst b/caimira/docs/caimira.tests.rst new file mode 100644 index 00000000..51c8c86f --- /dev/null +++ b/caimira/docs/caimira.tests.rst @@ -0,0 +1,135 @@ +caimira.tests package +===================== + +Subpackages +----------- + +.. toctree:: + :maxdepth: 4 + + caimira.tests.apps + caimira.tests.data + caimira.tests.models + +Submodules +---------- + +caimira.tests.conftest module +----------------------------- + +.. automodule:: caimira.tests.conftest + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.test\_caimira module +---------------------------------- + +.. automodule:: caimira.tests.test_caimira + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.test\_dataclass\_utils module +------------------------------------------- + +.. automodule:: caimira.tests.test_dataclass_utils + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.test\_expiration module +------------------------------------- + +.. automodule:: caimira.tests.test_expiration + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.test\_full\_algorithm module +------------------------------------------ + +.. automodule:: caimira.tests.test_full_algorithm + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.test\_infected\_population module +----------------------------------------------- + +.. automodule:: caimira.tests.test_infected_population + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.test\_known\_quantities module +-------------------------------------------- + +.. automodule:: caimira.tests.test_known_quantities + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.test\_model module +-------------------------------- + +.. automodule:: caimira.tests.test_model + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.test\_monte\_carlo module +--------------------------------------- + +.. automodule:: caimira.tests.test_monte_carlo + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.test\_monte\_carlo\_full\_models module +----------------------------------------------------- + +.. automodule:: caimira.tests.test_monte_carlo_full_models + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.test\_predefined\_distributions module +---------------------------------------------------- + +.. automodule:: caimira.tests.test_predefined_distributions + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.test\_sampleable\_distribution module +--------------------------------------------------- + +.. automodule:: caimira.tests.test_sampleable_distribution + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.test\_state module +-------------------------------- + +.. automodule:: caimira.tests.test_state + :members: + :undoc-members: + :show-inheritance: + +caimira.tests.test\_ventilation module +-------------------------------------- + +.. automodule:: caimira.tests.test_ventilation + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: caimira.tests + :members: + :undoc-members: + :show-inheritance: diff --git a/cara/docs/conf.py b/caimira/docs/conf.py similarity index 99% rename from cara/docs/conf.py rename to caimira/docs/conf.py index 472456ed..2b9f7aaf 100644 --- a/cara/docs/conf.py +++ b/caimira/docs/conf.py @@ -17,7 +17,7 @@ sys.path.insert(0, os.path.abspath('..')) # -- Project information ----------------------------------------------------- -project = 'CARA' +project = 'CAiMIRA' copyright = '2022, Andre Henriques et al.' author = 'Andre Henriques et al.' diff --git a/cara/docs/full_diameter_dependence.rst b/caimira/docs/full_diameter_dependence.rst similarity index 73% rename from cara/docs/full_diameter_dependence.rst rename to caimira/docs/full_diameter_dependence.rst index f951615b..09461003 100644 --- a/cara/docs/full_diameter_dependence.rst +++ b/caimira/docs/full_diameter_dependence.rst @@ -2,21 +2,21 @@ Diameter-dependent model ************************* -This section describes the model and its dependence on the Particles diameter. A Unified Modeling Language (UML) diagram describing all the data classes and their relations can be found :ref:`here`, at the bottom of the document. +This section describes the model and its dependence on the Particles diameter. A Unified Modeling Language (UML) diagram describing all the data classes and their relations can be found :ref:`here`, at the bottom of the document. Context ======= -The :mod:`cara.apps.calculator.model_generator` module is responsible to bind all the inputs defined in the user interface into the respective model variables. -The :py:mod:`cara.apps.calculator.report_generator` module is responsible to bind the results from the model calculations into the respective output variables presented in the CARA report. -The :mod:`cara.models` module itself implements the core CARA methods. A useful feature of the implementation is that we can benefit from vectorisation, which allows running multiple parameterizations of the model at the same time. +The :mod:`caimira.apps.calculator.model_generator` module is responsible to bind all the inputs defined in the user interface into the respective model variables. +The :py:mod:`caimira.apps.calculator.report_generator` module is responsible to bind the results from the model calculations into the respective output variables presented in the CAiMIRA report. +The :mod:`caimira.models` module itself implements the core CAiMIRA methods. A useful feature of the implementation is that we can benefit from vectorisation, which allows running multiple parameterizations of the model at the same time. -Unlike other similar models, some of the CARA variables are considered for a given aerosol diameter :math:`D`, +Unlike other similar models, some of the CAiMIRA variables are considered for a given aerosol diameter :math:`D`, as the behavior of the virus-laden particles in the room environment and inside the susceptible host (once inhaled) are diameter-dependent. Here, these variables are identified by their functional dependency on :math:`D`, as for the **emission rate** -- :math:`\mathrm{vR}(D)`, **removal rate** -- :math:`\mathrm{vRR}(D)`, and **concentration** -- :math:`C(t, D)`. -Despite the outcome of the CARA results include the entire range of diameters, throughout the model, +Despite the outcome of the CAiMIRA results include the entire range of diameters, throughout the model, most of the variables and parameters are kept in their diameter-dependent form for any possible detailed analysis of intermediate results. Only the final quantities shown in output, such as the concentration and the dose, are integrated over the diameter distribution. This is performed thanks to a Monte-Carlo (MC) integration at the level of the dose (:math:`\mathrm{vD^{total}}`) which is computed over a distribution of particle diameters, @@ -26,25 +26,25 @@ provided the sample size is large enough. Example of the MC integration over the It is important to distinguish between 1) Monte-Carlo random variables (which are vectorised independently on its diameter-dependence) and 2) numerical Monte-Carlo integration for the diameter-dependence. Since the integral of the diameter-dependent variables are solved when computing the dose -- :math:`\mathrm{vD^{total}}` -- while performing some of the intermediate calculations, -we normalize the results by *dividing* by the Monte-Carlo variables that are diameter-independent, so that they are not considered in the Monte-Carlo integration (e.g. the **viral load** parameter, or the result of the :meth:`cara.models.InfectedPopulation.emission_rate_per_aerosol_when_present` method). +we normalize the results by *dividing* by the Monte-Carlo variables that are diameter-independent, so that they are not considered in the Monte-Carlo integration (e.g. the **viral load** parameter, or the result of the :meth:`caimira.models.InfectedPopulation.emission_rate_per_aerosol_when_present` method). Expiration ========== -The **Expiration** class (representing the expiration of aerosols by an infected person) has the `Particle` -- :attr:`cara.models.Expiration.particle` -- as one of its properties, +The **Expiration** class (representing the expiration of aerosols by an infected person) has the `Particle` -- :attr:`caimira.models.Expiration.particle` -- as one of its properties, which represents the virus-laden aerosol with a vectorised parameter: the particle `diameter` (assuming a perfect sphere). -For a given aerosol diameter, one :class:`cara.models.Expiration` object provides the aerosol **volume** - :math:`V_p(D)`, multiplied by the **mask outward efficiency** - :math:`η_\mathrm{out}(D)` to include the filtration capacity, when applicable. +For a given aerosol diameter, one :class:`caimira.models.Expiration` object provides the aerosol **volume** - :math:`V_p(D)`, multiplied by the **mask outward efficiency** - :math:`η_\mathrm{out}(D)` to include the filtration capacity, when applicable. The BLO model represents the distribution of diameters used in the model. It corresponds to the sum of three log-normal distributions, weighted by the **B**, **L** and **O** modes. -The aerosol diameter distributions are given by the :meth:`cara.monte_carlo.data.BLOmodel.distribution` method. +The aerosol diameter distributions are given by the :meth:`caimira.monte_carlo.data.BLOmodel.distribution` method. -The :class:`cara.monte_carlo.data.BLOmodel` class itself contains the method to return the mathematical values of the probability distribution for a given diameter (in microns), +The :class:`caimira.monte_carlo.data.BLOmodel` class itself contains the method to return the mathematical values of the probability distribution for a given diameter (in microns), as well as the method to return its integral between the **min** and **max** diameters. -The BLO model is used to provide the probability density function (PDF) of the aerosol diameters for a given **Expiration** type defined in :meth:`cara.monte_carlo.data.expiration_distribution`. +The BLO model is used to provide the probability density function (PDF) of the aerosol diameters for a given **Expiration** type defined in :meth:`caimira.monte_carlo.data.expiration_distribution`. To compute the total number concentration of particles per mode (B, L and O), :math:`cn` in particles/cm\ :sup:`3`\, in other words, the total concentration of aerosols per unit volume of expired air, -an integration of the log-normal distributions is performed over all aerosol diameters. In the code it is used as a scaling factor in the :class:`cara.models.Expiration` class. +an integration of the log-normal distributions is performed over all aerosol diameters. In the code it is used as a scaling factor in the :class:`caimira.models.Expiration` class. -Under the :mod:`cara.apps.calculator.model_generator`, when it comes to generate the Expiration model, the `diameter` property is sampled through the BLO :meth:`cara.monte_carlo.data.BLOmodel.distribution` method, while the value for the :math:`cn` is given by the :meth:`cara.monte_carlo.data.BLOmodel.integrate` method. +Under the :mod:`caimira.apps.calculator.model_generator`, when it comes to generate the Expiration model, the `diameter` property is sampled through the BLO :meth:`caimira.monte_carlo.data.BLOmodel.distribution` method, while the value for the :math:`cn` is given by the :meth:`caimira.monte_carlo.data.BLOmodel.integrate` method. To summarize, the Expiration object contains, as a vectorised float, a sample of diameters following the BLO distribution. Depending on different expiratory types, the contributions from each mode will be different, therefore the resulting distribution also differs from model to model. Emission Rate - vR(D) @@ -62,9 +62,9 @@ Note that :math:`D_{\mathrm{max}}` value will differ, depending on the type of e In the code, for a given Expiration, we use different methods to perform the calculations *step-by-step*: -1. Calculate the non aerosol-dependent quantities in the emission rate, which is the multiplication of the diameter-**independent** variables: :meth:`cara.models.InfectedPopulation.emission_rate_per_aerosol_when_present`. This corresponds to the :math:`\mathrm{vl_{in}} \cdot \mathrm{BR_{k}}` part of the :math:`\mathrm{vR}(D)` equation. -2. Calculate the diameter-**dependent** variable :meth:`cara.models.InfectedPopulation.aerosols`, which is the result of :math:`E_{c,j}(D) = N_p(D) \cdot V_p(D) \cdot (1 − η_\mathrm{out}(D))` (in mL/(m\ :sup:`3` \.µm)), with :math:`N_p(D)` being the product of the BLO distribution by the scaling factor :math:`cn`. Note that this result is not integrated over the diameters at this stage, thus the units are still *'per aerosol diameter'*. -3. Calculate the full emission rate, which is the multiplication of the two previous methods, and corresponds to :math:`\mathrm{vR(D)}`: :meth:`cara.models._PopulationWithVirus.emission_rate_when_present`. +1. Calculate the non aerosol-dependent quantities in the emission rate, which is the multiplication of the diameter-**independent** variables: :meth:`caimira.models.InfectedPopulation.emission_rate_per_aerosol_when_present`. This corresponds to the :math:`\mathrm{vl_{in}} \cdot \mathrm{BR_{k}}` part of the :math:`\mathrm{vR}(D)` equation. +2. Calculate the diameter-**dependent** variable :meth:`caimira.models.InfectedPopulation.aerosols`, which is the result of :math:`E_{c,j}(D) = N_p(D) \cdot V_p(D) \cdot (1 − η_\mathrm{out}(D))` (in mL/(m\ :sup:`3` \.µm)), with :math:`N_p(D)` being the product of the BLO distribution by the scaling factor :math:`cn`. Note that this result is not integrated over the diameters at this stage, thus the units are still *'per aerosol diameter'*. +3. Calculate the full emission rate, which is the multiplication of the two previous methods, and corresponds to :math:`\mathrm{vR(D)}`: :meth:`caimira.models._PopulationWithVirus.emission_rate_when_present`. Note that the diameter-dependence is kept at this stage. Since other parameters downstream in code are also diameter-dependent, the Monte-Carlo integration over the aerosol sizes is computed at the level of the dose :math:`\mathrm{vD^{total}}`. In case one would like to have intermediate results for emission rate, perform the Monte-Carlo integration of :math:`E_{c, j}^{\mathrm{total}}` and compute :math:`\mathrm{vR^{total}} =\mathrm{vl_{in}} \cdot E_{c, j}^{\mathrm{total}} \cdot \mathrm{BR_k}`. @@ -84,26 +84,26 @@ The long-range concentration of virus-laden aerosols of a given size :math:`D`, :math:`C_{\mathrm{LR}}(t, D)=\frac{\mathrm{vR}(D) \cdot N_{\mathrm{inf}}}{\lambda_{\mathrm{vRR}}(D) \cdot V_r}-\left (\frac{\mathrm{vR}(D) \cdot N_{\mathrm{inf}}}{\lambda_{\mathrm{vRR}}(D) \cdot V_r}-C_0(D) \right )e^{-\lambda_{\mathrm{vRR}}(D)t}` , -and computed, as a function of the exposure time and particle diameter, in the :meth:`cara.models.ConcentrationModel.concentration` method. -The long-range concentration, integrated over the exposure time (in piecewise constant steps), :math:`C(D)`, is given by :meth:`cara.models.ConcentrationModel.integrated_concentration`. +and computed, as a function of the exposure time and particle diameter, in the :meth:`caimira.models.ConcentrationModel.concentration` method. +The long-range concentration, integrated over the exposure time (in piecewise constant steps), :math:`C(D)`, is given by :meth:`caimira.models.ConcentrationModel.integrated_concentration`. -In the :math:`C_{\mathrm{LR}}(t, D)` equation above, the **emission rate** - :math:`\mathrm{vR}(D)` - and the **viral removal rate** - :math:`\lambda_{\mathrm{vRR}}(D)`, :meth:`cara.models.ConcentrationModel.infectious_virus_removal_rate` - are both diameter-dependent. +In the :math:`C_{\mathrm{LR}}(t, D)` equation above, the **emission rate** - :math:`\mathrm{vR}(D)` - and the **viral removal rate** - :math:`\lambda_{\mathrm{vRR}}(D)`, :meth:`caimira.models.ConcentrationModel.infectious_virus_removal_rate` - are both diameter-dependent. One can show that the resulting concentration is always proportional to the emission rate :math:`\mathrm{vR}(D)`. Hence, for computational speed-up purposes the code computes first a normalized version of the concentration, i.e. divided by the emission rate, before multiplying by :math:`\mathrm{vR}(D)`. To summarize, we can split the concentration in two different formulations: -* Normalized concentration :meth:`cara.models.ConcentrationModel._normed_concentration`: :math:`\mathrm{C_\mathrm{LR, normed}}(t, D)` that computes the concentration without including the emission rate. -* Concentration :meth:`cara.models.ConcentrationModel.concentration` : :math:`C_{\mathrm{LR}}(t, D) = \mathrm{C_\mathrm{LR, normed}}(t, D) \cdot \mathrm{vR}(D)`, where :math:`\mathrm{vR}(D)` is the result of the :meth:`cara.models._PopulationWithVirus.emission_rate_when_present` method. +* Normalized concentration :meth:`caimira.models.ConcentrationModel._normed_concentration`: :math:`\mathrm{C_\mathrm{LR, normed}}(t, D)` that computes the concentration without including the emission rate. +* Concentration :meth:`caimira.models.ConcentrationModel.concentration` : :math:`C_{\mathrm{LR}}(t, D) = \mathrm{C_\mathrm{LR, normed}}(t, D) \cdot \mathrm{vR}(D)`, where :math:`\mathrm{vR}(D)` is the result of the :meth:`caimira.models._PopulationWithVirus.emission_rate_when_present` method. Note that in order to get the total concentration value in this stage, the final result should be averaged over the particle diameters (i.e. Monte-Carlo integration over diameters, see above). For the calculator app report, the total concentration (MC integral over the diameter) is performed only when generating the plot. -Otherwise, the diameter-dependence continues until we compute the inhaled dose in the :class:`cara.models.ExposureModel` class. +Otherwise, the diameter-dependence continues until we compute the inhaled dose in the :class:`caimira.models.ExposureModel` class. The following methods calculate the integrated concentration between two times. They are mostly used when calculating the **dose**: -* :meth:`cara.models.ConcentrationModel.normed_integrated_concentration`, :math:`\mathrm{C_\mathrm{normed}}(D)` that returns the integrated long-range concentration of viruses in the air, between any two times, normalized by the emission rate. Note that this method performs the integral between any two times of the previously mentioned :meth:`cara.models.ConcentrationModel._normed_concentration` method. -* :meth:`cara.models.ConcentrationModel.integrated_concentration`, :math:`C(D)`, that returns the same result as the previous one, but multiplied by the emission rate. +* :meth:`caimira.models.ConcentrationModel.normed_integrated_concentration`, :math:`\mathrm{C_\mathrm{normed}}(D)` that returns the integrated long-range concentration of viruses in the air, between any two times, normalized by the emission rate. Note that this method performs the integral between any two times of the previously mentioned :meth:`caimira.models.ConcentrationModel._normed_concentration` method. +* :meth:`caimira.models.ConcentrationModel.integrated_concentration`, :math:`C(D)`, that returns the same result as the previous one, but multiplied by the emission rate. The integral over the exposure times is calculated directly in the class (integrated methods). @@ -115,15 +115,15 @@ The short-range concentration is the result of a two-stage exhaled jet model dev :math:`C_{\mathrm{SR}}(t, D) = C_{\mathrm{LR}} (t, D) + \frac{1}{S({x})} \cdot (C_{0, \mathrm{SR}}(D) - C_{\mathrm{LR}, 100μm}(t, D))` , where :math:`S(x)` is the dilution factor due to jet dynamics, as a function of the interpersonal distance :math:`x` and :math:`C_{0, \mathrm{SR}}(D)` corresponds to the initial concentration of virions at the mouth/nose outlet during exhalation. -:math:`C_{\mathrm{LR}, 100μm}(t, D)` is the long-range concentration, calculated in :meth:`cara.models.ConcentrationModel.concentration` method but **interpolated** to the diameter range used for close-proximity (from 0 to 100μm). +:math:`C_{\mathrm{LR}, 100μm}(t, D)` is the long-range concentration, calculated in :meth:`caimira.models.ConcentrationModel.concentration` method but **interpolated** to the diameter range used for close-proximity (from 0 to 100μm). Note that :math:`C_{0, \mathrm{SR}}(D)` is constant over time, hence only dependent on the particle diameter distribution. For code simplification, we split the :math:`C_{\mathrm{SR}}(t, D)` equation into two components: -* short-range component: :math:`\frac{1}{S({x})} \cdot (C_{0, \mathrm{SR}}(D) - C_{\mathrm{LR}, 100μm}(t, D))`, dealt with in the dataclass :class:`cara.models.ShortRangeModel`. +* short-range component: :math:`\frac{1}{S({x})} \cdot (C_{0, \mathrm{SR}}(D) - C_{\mathrm{LR}, 100μm}(t, D))`, dealt with in the dataclass :class:`caimira.models.ShortRangeModel`. * long-range component: :math:`C_{\mathrm{LR}} (t, D)`. -The short-range data class (:class:`cara.models.ShortRangeModel`) models the short-range component of a close-range interaction **concentration** and the respective **dilution_factor**. +The short-range data class (:class:`caimira.models.ShortRangeModel`) models the short-range component of a close-range interaction **concentration** and the respective **dilution_factor**. Its inputs are the **expiration** definition, the **activity type**, the **presence time**, and the **interpersonal distance** between any two individuals. When generating a full model, the short-range class is defined with a new **Expiration** distribution, given that the **min** and **max** diameters for the short-range interactions are different from those used in the long-range concentration (the idea is that very large particles should not be considered in the long-range case as they fall rapidly on the floor, @@ -143,15 +143,15 @@ To calculate the short-range component, we first need to calculate what is the * The initial concentration of virions at the mouth/nose, :math:`C_{0, \mathrm{SR}}(D)` is calculated as follows: :math:`C_{0, \mathrm{SR}}(D) = N_p(D) \cdot V_p(D) \cdot \mathrm{vl_{in}} \cdot 10^{-6}`, -given by :meth:`cara.models.Expiration.jet_origin_concentration`. It computes the same quantity as :meth:`cara.models.Expiration.aerosols`, except for the mask inclusion. As previously mentioned, it is normalized by the **viral load**, which is a diameter-independent property. +given by :meth:`caimira.models.Expiration.jet_origin_concentration`. It computes the same quantity as :meth:`caimira.models.Expiration.aerosols`, except for the mask inclusion. As previously mentioned, it is normalized by the **viral load**, which is a diameter-independent property. Note, the :math:`10^{-6}` factor corresponds to the conversion from :math:`\mathrm{μm}^{3} \cdot \mathrm{cm}^{-3}` to :math:`\mathrm{mL} \cdot m^{3}`. Note that similarly to the `long-range` approach, the MC integral over the diameters is not calculated at this stage. -For consistency, the long-range concentration parameter, :math:`C_{\mathrm{LR}, 100\mathrm{μm}}(t, D)` in the :class:`cara.models.ShortRangeModel` class **only**, +For consistency, the long-range concentration parameter, :math:`C_{\mathrm{LR}, 100\mathrm{μm}}(t, D)` in the :class:`caimira.models.ShortRangeModel` class **only**, shall also be normalized by the **viral load** and, since in the short-range model the diameter range is different than at long-range (as mentioned above), we need to account for that difference. -The former operation is given in method :meth:`cara.models.ShortRangeModel._long_range_normed_concentration`. For the diameter range difference, there are a few options: +The former operation is given in method :meth:`caimira.models.ShortRangeModel._long_range_normed_concentration`. For the diameter range difference, there are a few options: one solution would be to recompute the values a second time using :math:`D_{\mathrm{max}} = 100\mathrm{μm}`; or perform a approximation using linear interpolation, which is possible and more effective in terms of performance. We decided to adopt the interpolation solution. The set of points with a known value are given by the default expiration particle diameters for long-range, i.e. from 0 to 30 :math:`\mathrm{μm}`. @@ -159,15 +159,15 @@ The set of points we want the interpolated values are given by the short-range e To summarize, in the code, :math:`C_{\mathrm{SR}}(t, D)` is computed as follows: -* calculate the `dilution_factor` - :math:`S({x})` - in the method :meth:`cara.models.ShortRangeModel.dilution_factor`, with the distance :math:`x` as a random variable (log normal distribution in :meth:`cara.monte_carlo.data.short_range_distances`) -* compute :math:`\frac{1}{S({x})} \cdot (C_{0, \mathrm{SR}}(D) - C_{\mathrm{LR}, 100\mathrm{μm}}(t, D))` in method :meth:`cara.models.ShortRangeModel.normed_concentration`, -* multiply by the diameter-independent parameter, viral load, in method :meth:`cara.models.ShortRangeModel.short_range_concentration` -* complete the equation of :math:`C_{\mathrm{SR}}(t, D)` by adding the long-range concentration from the :meth:`cara.models.ConcentrationModel.concentration` (all integrated over :math:`D`), returning the final short-range concentration value for a given time and expiration activity. This is done at the level of the Exposure Model (:meth:`cara.models.ExposureModel.concentration`). +* calculate the `dilution_factor` - :math:`S({x})` - in the method :meth:`caimira.models.ShortRangeModel.dilution_factor`, with the distance :math:`x` as a random variable (log normal distribution in :meth:`caimira.monte_carlo.data.short_range_distances`) +* compute :math:`\frac{1}{S({x})} \cdot (C_{0, \mathrm{SR}}(D) - C_{\mathrm{LR}, 100\mathrm{μm}}(t, D))` in method :meth:`caimira.models.ShortRangeModel.normed_concentration`, +* multiply by the diameter-independent parameter, viral load, in method :meth:`caimira.models.ShortRangeModel.short_range_concentration` +* complete the equation of :math:`C_{\mathrm{SR}}(t, D)` by adding the long-range concentration from the :meth:`caimira.models.ConcentrationModel.concentration` (all integrated over :math:`D`), returning the final short-range concentration value for a given time and expiration activity. This is done at the level of the Exposure Model (:meth:`caimira.models.ExposureModel.concentration`). -Note that :meth:`cara.models.ShortRangeModel._normed_concentration` method is different from :meth:`cara.models.ConcentrationModel._normed_concentration` and :meth:`cara.models.ConcentrationModel.concentration` differs from :meth:`cara.models.ExposureModel.concentration`. +Note that :meth:`caimira.models.ShortRangeModel._normed_concentration` method is different from :meth:`caimira.models.ConcentrationModel._normed_concentration` and :meth:`caimira.models.ConcentrationModel.concentration` differs from :meth:`caimira.models.ExposureModel.concentration`. Unless one is computing the mean concentration values (e.g. for the plots in the report), the diameter-dependence is kept at this stage. Since other parameters downstream in the code are also diameter-dependent, the Monte-Carlo integration over the particle sizes is computed at the level of the dose :math:`\mathrm{vD^{total}}`. -In case one would like to have intermediate results for the initial short-range concentration, this is done at the :class:`cara.models.ExposureModel` class level. +In case one would like to have intermediate results for the initial short-range concentration, this is done at the :class:`caimira.models.ExposureModel` class level. Dose - vD @@ -196,28 +196,28 @@ The dose for each of them is then computed, and their **average** value over all Long-range approach ******************* -Regarding the concentration part of the long-range exposure (concentration integrated over time, :math:`\int_{t1}^{t2}C_{\mathrm{LR}}(t, D)\;\mathrm{d}t`), the respective method is :meth:`cara.models.ExposureModel._long_range_normed_exposure_between_bounds`, -which uses the long-range exposure (concentration) between two bounds (time1 and time2), normalized by the emission rate of the infected population, calculated from :meth:`cara.models.ConcentrationModel.normed_integrated_concentration`. +Regarding the concentration part of the long-range exposure (concentration integrated over time, :math:`\int_{t1}^{t2}C_{\mathrm{LR}}(t, D)\;\mathrm{d}t`), the respective method is :meth:`caimira.models.ExposureModel._long_range_normed_exposure_between_bounds`, +which uses the long-range exposure (concentration) between two bounds (time1 and time2), normalized by the emission rate of the infected population, calculated from :meth:`caimira.models.ConcentrationModel.normed_integrated_concentration`. The former method filters out the given bounds considering the breaks through the day (i.e. the time intervals during which there is no exposition to the virus) and retrieves the integrated long-range concentration of viruses in the air between any two times. After the calculations of the integrated concentration over the time, in order to calculate the final dose, we have to compute the remaining factors in the above equation. Note that the **Monte-Carlo integration over the diameters is performed at this stage**, where all the diameter-dependent parameters are grouped together to calculate the final average (:code:`np.mean()`). Since, in the previous chapters, the quantities where normalised by the emission rate, one will need to re-incorporate it in the equations before performing the MC integrations over :math:`D`. -For that we need to split :math:`\mathrm{vR}(D)` (:meth:`cara.models._PopulationWithVirus.emission_rate_when_present`) in diameter-dependent and diameter-independent quantities: +For that we need to split :math:`\mathrm{vR}(D)` (:meth:`caimira.models._PopulationWithVirus.emission_rate_when_present`) in diameter-dependent and diameter-independent quantities: :math:`\mathrm{vR}(D) = \mathrm{vR}(D-\mathrm{dependent}) \times \mathrm{vR}(D-\mathrm{independent})` with -:math:`\mathrm{vR}(D-\mathrm{dependent}) = \mathrm{cn} \cdot V_p(D) \cdot (1 − \mathrm{η_{out}}(D))` - :meth:`cara.models.InfectedPopulation.aerosols` +:math:`\mathrm{vR}(D-\mathrm{dependent}) = \mathrm{cn} \cdot V_p(D) \cdot (1 − \mathrm{η_{out}}(D))` - :meth:`caimira.models.InfectedPopulation.aerosols` -:math:`\mathrm{vR}(D-\mathrm{independent}) = \mathrm{vl_{in}} \cdot \mathrm{BR_{k}}` - :meth:`cara.models.InfectedPopulation.emission_rate_per_aerosol_when_present` +:math:`\mathrm{vR}(D-\mathrm{independent}) = \mathrm{vl_{in}} \cdot \mathrm{BR_{k}}` - :meth:`caimira.models.InfectedPopulation.emission_rate_per_aerosol_when_present` -In other words, in the code the procedure is the following (all performed in :meth:`cara.models.ExposureModel.long_range_deposited_exposure_between_bounds` method): +In other words, in the code the procedure is the following (all performed in :meth:`caimira.models.ExposureModel.long_range_deposited_exposure_between_bounds` method): -* start re-incorporating the emission rate by first multiplying by the diameter-dependent quantities: :math:`\mathrm{vD_{aerosol}}(D) = (\int_{t1}^{t2}C_{\mathrm{LR}}(t, D)\;\mathrm{d}t \cdot \mathrm{vR}(D-\mathrm{dependent}) \cdot f_{\mathrm{dep}}(D))`, in :meth:`cara.models.ExposureModel.long_range_deposited_exposure_between_bounds` method; +* start re-incorporating the emission rate by first multiplying by the diameter-dependent quantities: :math:`\mathrm{vD_{aerosol}}(D) = (\int_{t1}^{t2}C_{\mathrm{LR}}(t, D)\;\mathrm{d}t \cdot \mathrm{vR}(D-\mathrm{dependent}) \cdot f_{\mathrm{dep}}(D))`, in :meth:`caimira.models.ExposureModel.long_range_deposited_exposure_between_bounds` method; * perform the **MC integration over the diameters**, which is considered equivalent as the mean of the distribution if the sample size is large enough: :math:`\mathrm{vD_{aerosol}} = \mathrm{np.mean}(\mathrm{vD_{aerosol}}(D))`; * multiply the result with the remaining diameter-independent quantities of the emission rate used previously to normalize: :math:`\mathrm{vD_{emission-rate}} = \mathrm{vD_{aerosol}} \cdot \mathrm{vR}(D-\mathrm{independent})`; @@ -232,7 +232,7 @@ The :math:`\mathrm{cn}` factor, which represents the total number of aerosols em **Note**: for simplification of the notations, here the dose corresponding exclusively to the long-range contribution is written as :math:`\mathrm{vD_{LR}}(D)= \mathrm{vD}(D)`. -In the end, the governing method is :meth:`cara.models.ExposureModel.deposited_exposure_between_bounds`, in which the `deposited_exposure` is equal to `long_range_deposited_exposure_between_bounds` in the absence of short-range interactions. +In the end, the governing method is :meth:`caimira.models.ExposureModel.deposited_exposure_between_bounds`, in which the `deposited_exposure` is equal to `long_range_deposited_exposure_between_bounds` in the absence of short-range interactions. Short-range approach ******************** @@ -246,18 +246,18 @@ From above, the short-range concentration: :math:`C_{\mathrm{SR}}(t, D) = C_{\mathrm{LR}, 100μm} (t, D) + \frac{1}{S({x})} \cdot (C_{0, \mathrm{SR}}(D) - C_{\mathrm{LR}, 100μm}(t, D))` , -In the code, the method that returns the value for the total dose (independently if it is short- or long-range) is given by :meth:`cara.models.ExposureModel.deposited_exposure_between_bounds`. +In the code, the method that returns the value for the total dose (independently if it is short- or long-range) is given by :meth:`caimira.models.ExposureModel.deposited_exposure_between_bounds`. For code simplification, we split the :math:`C_{\mathrm{SR}}(t, D)` equation into two components: * short-range component: :math:`\frac{1}{S({x})} \cdot (C_{0, \mathrm{SR}}(D) - C_{\mathrm{LR}, 100μm}(t, D))`; * long-range component: :math:`C_{\mathrm{LR}} (t, D)`. Similarly as above, first we perform the multiplications by the diameter-dependent variables so that we can profit from the Monte-Carlo integration. Then we multiply the final value by the diameter-independent variables. -The method :meth:`cara.models.ShortRangeModel._normed_jet_exposure_between_bounds` gets the integrated short-range concentration of viruses in the air between the times start and stop, normalized by the **viral load**, +The method :meth:`caimira.models.ShortRangeModel._normed_jet_exposure_between_bounds` gets the integrated short-range concentration of viruses in the air between the times start and stop, normalized by the **viral load**, and excluding the **jet dilution** since it is also diameter-independent. This corresponds to :math:`C_{0, \mathrm{SR}}(D)`. -The method :meth:`cara.models.ShortRangeModel._normed_interpolated_longrange_exposure_between_bounds` retrieves the integrated short-range concentration due to the background concentration, +The method :meth:`caimira.models.ShortRangeModel._normed_interpolated_longrange_exposure_between_bounds` retrieves the integrated short-range concentration due to the background concentration, normalized by the **viral load** and the **breathing rate**, and excluding the jet **dilution**. The result is then interpolated to the particle diameter range used in the short-range model (i.e. 100 μm). This corresponds to :math:`\int_{t1}^{t2} C_{\mathrm{LR}, 100\mathrm{μm}} (t, D)\mathrm{d}t`. @@ -278,24 +278,24 @@ Then, we add the contribution to the result of the diameter-**independent** vect * multiply by the diameter-independent properties that are dependent on the **activity type** of the different short-range interactions: **breathing rate** and **dilution factor** - within the *for* cycle; * multiply by the other properties that are **not** dependent on the type of short-range interactions: **viral load**, **fraction of infectious virus** and **inwards mask efficiency**. -The final operation in the :meth:`cara.models.ExposureModel.deposited_exposure_between_bounds` accounts for the addition of the long-range component of the dose. +The final operation in the :meth:`caimira.models.ExposureModel.deposited_exposure_between_bounds` accounts for the addition of the long-range component of the dose. If short-range interactions exist: the long-range component is added to the already calculated short-range component (`deposited_exposure`), hence completing :math:`C_{\mathrm{SR}}`. If the are no short-range interactions: the short-range component (`deposited_exposure`) is zero, hence the result is equal solely to the long-range component :math:`C_{\mathrm{LR}}`. -.. _cara-uml-diagram: +.. _caimira-uml-diagram: -CARA UML Diagram -================ +CAiMIRA UML Diagram +=================== The following diagram describes all the data classes and their relations under the `models.py` file. Click the diagram to zoom-in. -.. figure:: ./UML-CARA.png +.. figure:: ./UML-CAiMIRA.png :scale: 20 % :align: center - CARA `models.py` file UML diagram. + CAiMIRA `models.py` file UML diagram. REFERENCES ========== diff --git a/cara/docs/index.rst b/caimira/docs/index.rst similarity index 72% rename from cara/docs/index.rst rename to caimira/docs/index.rst index 3b5a57cc..a1fcc2f1 100644 --- a/cara/docs/index.rst +++ b/caimira/docs/index.rst @@ -1,17 +1,17 @@ -.. CARA documentation master file, created by +.. CAiMIRA documentation master file, created by sphinx-quickstart on Fri Apr 8 10:26:24 2022. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to CARA's documentation! -================================ +Welcome to CAiMIRA's documentation! +=================================== .. toctree:: :maxdepth: 2 :caption: Contents: full_diameter_dependence - cara + caimira Indices and tables diff --git a/cara/docs/make.bat b/caimira/docs/make.bat similarity index 100% rename from cara/docs/make.bat rename to caimira/docs/make.bat diff --git a/cara/models.py b/caimira/models.py similarity index 99% rename from cara/models.py rename to caimira/models.py index 9506b126..d517116b 100644 --- a/cara/models.py +++ b/caimira/models.py @@ -1,9 +1,9 @@ -# This module is part of CARA. Please see the repository at +# This module is part of CAiMIRA. Please see the repository at # https://gitlab.cern.ch/cara/cara for details of the license and terms of use. """ -This module implements the core CARA models. +This module implements the core CAiMIRA models. -The CARA model is a flexible, object-oriented numerical model. It is designed +The CAiMIRA model is a flexible, object-oriented numerical model. It is designed to allow the user to swap-out and extend its various components. One of the major abstractions of the model is the distinction between virus concentration (:class:`ConcentrationModel`) and virus exposure (:class:`ExposureModel`). @@ -15,10 +15,10 @@ deterministic (i.e. running the same model twice will result in the same answer) In order to apply stochastic / non-deterministic analyses therefore you must introduce the randomness before constructing the models themselves; the -:mod:`cara.monte_carlo` module is a good example of doing this - that module uses +:mod:`caimira.monte_carlo` module is a good example of doing this - that module uses the models defined here to allow you to construct a ConcentrationModel containing parameters which are expressed as probability distributions. Under the hood the -``cara.monte_carlo.ConcentrationModel`` implementation simply samples all of those +``caimira.monte_carlo.ConcentrationModel`` implementation simply samples all of those probability distributions to produce many instances of the deterministic model. The models in this module have been designed for flexibility above performance, diff --git a/cara/monte_carlo/__init__.py b/caimira/monte_carlo/__init__.py similarity index 100% rename from cara/monte_carlo/__init__.py rename to caimira/monte_carlo/__init__.py diff --git a/cara/monte_carlo/__init__.pyi b/caimira/monte_carlo/__init__.pyi similarity index 100% rename from cara/monte_carlo/__init__.pyi rename to caimira/monte_carlo/__init__.pyi diff --git a/cara/monte_carlo/data.py b/caimira/monte_carlo/data.py similarity index 98% rename from cara/monte_carlo/data.py rename to caimira/monte_carlo/data.py index b4f047c4..8ad2fcfc 100644 --- a/cara/monte_carlo/data.py +++ b/caimira/monte_carlo/data.py @@ -5,8 +5,8 @@ import numpy as np from scipy import special as sp from scipy.stats import weibull_min -import cara.monte_carlo as mc -from cara.monte_carlo.sampleable import LogCustom, LogNormal,LogCustomKernel,CustomKernel,Uniform, Custom +import caimira.monte_carlo as mc +from caimira.monte_carlo.sampleable import LogCustom, LogNormal,LogCustomKernel,CustomKernel,Uniform, Custom sqrt2pi = np.sqrt(2.*np.pi) sqrt2 = np.sqrt(2.) diff --git a/cara/monte_carlo/models.py b/caimira/monte_carlo/models.py similarity index 78% rename from cara/monte_carlo/models.py rename to caimira/monte_carlo/models.py index 4ab55363..dfa446bd 100644 --- a/cara/monte_carlo/models.py +++ b/caimira/monte_carlo/models.py @@ -3,7 +3,7 @@ import dataclasses import sys import typing -import cara.models +import caimira.models from .sampleable import SampleableDistribution, _VectorisedFloatOrSampleable @@ -14,9 +14,9 @@ class MCModelBase(typing.Generic[_ModelType]): """ A model base class for monte carlo types. - This base class is essentially a declarative description of a cara.models + This base class is essentially a declarative description of a caimira.models model with a :meth:`.build_model` method to generate an appropriate - ``cara.models` model instance on demand. + ``caimira.models` model instance on demand. """ _base_cls: typing.Type[_ModelType] @@ -36,7 +36,7 @@ class MCModelBase(typing.Generic[_ModelType]): def build_model(self, size: int) -> _ModelType: """ - Turn this MCModelBase subclass into a cara.model Model instance + Turn this MCModelBase subclass into a caimira.model Model instance from which you can then run the model. """ @@ -49,7 +49,7 @@ class MCModelBase(typing.Generic[_ModelType]): def _build_mc_model(model: _ModelType) -> typing.Type[MCModelBase[_ModelType]]: """ - Generate a new MCModelBase subclass for the given cara.models model. + Generate a new MCModelBase subclass for the given caimira.models model. """ fields = [] @@ -57,7 +57,7 @@ def _build_mc_model(model: _ModelType) -> typing.Type[MCModelBase[_ModelType]]: # Note: deepcopy not needed here as we aren't mutating entities beyond # the top level. new_field = copy.copy(field) - if field.type is cara.models._VectorisedFloat: # noqa + if field.type is caimira.models._VectorisedFloat: # noqa new_field.type = _VectorisedFloatOrSampleable # type: ignore field_type: typing.Any = new_field.type @@ -65,29 +65,29 @@ def _build_mc_model(model: _ModelType) -> typing.Type[MCModelBase[_ModelType]]: if getattr(field_type, '__origin__', None) in [typing.Union, typing.Tuple]: # It is challenging to generalise this code, so we provide specific transformations, # and raise for unforseen cases. - if new_field.type == typing.Tuple[cara.models._VentilationBase, ...]: + if new_field.type == typing.Tuple[caimira.models._VentilationBase, ...]: VB = getattr(sys.modules[__name__], "_VentilationBase") - field_type = typing.Tuple[typing.Union[cara.models._VentilationBase, VB], ...] - elif new_field.type == typing.Tuple[cara.models._ExpirationBase, ...]: + field_type = typing.Tuple[typing.Union[caimira.models._VentilationBase, VB], ...] + elif new_field.type == typing.Tuple[caimira.models._ExpirationBase, ...]: EB = getattr(sys.modules[__name__], "_ExpirationBase") - field_type = typing.Tuple[typing.Union[cara.models._ExpirationBase, EB], ...] - elif new_field.type == typing.Tuple[cara.models.SpecificInterval, ...]: + field_type = typing.Tuple[typing.Union[caimira.models._ExpirationBase, EB], ...] + elif new_field.type == typing.Tuple[caimira.models.SpecificInterval, ...]: SI = getattr(sys.modules[__name__], "SpecificInterval") - field_type = typing.Tuple[typing.Union[cara.models.SpecificInterval, SI], ...] + field_type = typing.Tuple[typing.Union[caimira.models.SpecificInterval, SI], ...] else: # Check that we don't need to do anything with this type. for item in new_field.type.__args__: - if getattr(item, '__module__', None) == 'cara.models': + if getattr(item, '__module__', None) == 'caimira.models': raise ValueError( f"unsupported type annotation transformation required for {new_field.type}") - elif field_type.__module__ == 'cara.models': + elif field_type.__module__ == 'caimira.models': mc_model = getattr(sys.modules[__name__], new_field.type.__name__) field_type = typing.Union[new_field.type, mc_model] fields.append((new_field.name, field_type, new_field)) bases = [] - # Update the inheritance/based to use the new MC classes, rather than the cara.models ones. + # Update the inheritance/based to use the new MC classes, rather than the caimira.models ones. for model_base in model.__bases__: # type: ignore if model_base is object: bases.append(MCModelBase) @@ -111,7 +111,7 @@ def _build_mc_model(model: _ModelType) -> typing.Type[MCModelBase[_ModelType]]: _MODEL_CLASSES = [ - cls for cls in vars(cara.models).values() + cls for cls in vars(caimira.models).values() if dataclasses.is_dataclass(cls) ] diff --git a/cara/monte_carlo/sampleable.py b/caimira/monte_carlo/sampleable.py similarity index 98% rename from cara/monte_carlo/sampleable.py rename to caimira/monte_carlo/sampleable.py index 1d887f12..479b91cf 100644 --- a/cara/monte_carlo/sampleable.py +++ b/caimira/monte_carlo/sampleable.py @@ -3,7 +3,7 @@ import typing import numpy as np from sklearn.neighbors import KernelDensity # type: ignore -import cara.models +import caimira.models # Declare a float array type of a given size. # There is no better way to declare this currently, unfortunately. @@ -158,5 +158,5 @@ class LogCustomKernel(SampleableDistribution): _VectorisedFloatOrSampleable = typing.Union[ - SampleableDistribution, cara.models._VectorisedFloat, + SampleableDistribution, caimira.models._VectorisedFloat, ] diff --git a/cara/scripts/themes/base/cara_script.command b/caimira/scripts/themes/base/caimira_script.command similarity index 78% rename from cara/scripts/themes/base/cara_script.command rename to caimira/scripts/themes/base/caimira_script.command index 77b0b4d5..49b418e4 100755 --- a/cara/scripts/themes/base/cara_script.command +++ b/caimira/scripts/themes/base/caimira_script.command @@ -1,6 +1,6 @@ cd Downloads git clone https://gitlab.cern.ch/cara/cara.git -cd cara +cd caimira if [[ `uname -m` == 'arm64' ]]; then pip3 install scipy --index-url=https://pypi.anaconda.org/scipy-wheels-nightly/simple pip3 install Cython @@ -8,7 +8,7 @@ if [[ `uname -m` == 'arm64' ]]; then fi pip3 install -e . echo "############################################" -echo "CARA is now running at http://localhost:8080" +echo "CAiMIRA is now running at http://localhost:8080" echo "############################################" -python3 -m cara.apps.calculator +python3 -m caimira.apps.calculator diff --git a/cara/scripts/themes/base/cara_script.sh b/caimira/scripts/themes/base/caimira_script.sh similarity index 62% rename from cara/scripts/themes/base/cara_script.sh rename to caimira/scripts/themes/base/caimira_script.sh index 60f4aa52..8d0d15de 100755 --- a/cara/scripts/themes/base/cara_script.sh +++ b/caimira/scripts/themes/base/caimira_script.sh @@ -1,8 +1,8 @@ git clone https://gitlab.cern.ch/cara/cara.git -cd cara +cd caimira pip install -e . echo "############################################" -echo "CARA is now running at http://localhost:8080" +echo "CAiMIRA is now running at http://localhost:8080" echo "############################################" -python -m cara.apps.calculator +python -m caimira.apps.calculator diff --git a/cara/scripts/themes/cern/cara_script.command b/caimira/scripts/themes/cern/caimira_script.command similarity index 73% rename from cara/scripts/themes/cern/cara_script.command rename to caimira/scripts/themes/cern/caimira_script.command index 0c244541..277fc3d1 100755 --- a/cara/scripts/themes/cern/cara_script.command +++ b/caimira/scripts/themes/cern/caimira_script.command @@ -1,6 +1,6 @@ cd Downloads git clone https://gitlab.cern.ch/cara/cara.git -cd cara +cd caimira if [[ `uname -m` == 'arm64' ]]; then pip3 install scipy --index-url=https://pypi.anaconda.org/scipy-wheels-nightly/simple pip3 install Cython @@ -8,7 +8,7 @@ if [[ `uname -m` == 'arm64' ]]; then fi pip3 install -e . echo "############################################" -echo "CARA is now running at http://localhost:8080" +echo "CAiMIRA is now running at http://localhost:8080" echo "############################################" -python3 -m cara.apps.calculator --theme=cara/apps/templates/cern +python3 -m caimira.apps.calculator --theme=caimira/apps/templates/cern diff --git a/cara/scripts/themes/cern/cara_script.sh b/caimira/scripts/themes/cern/caimira_script.sh similarity index 55% rename from cara/scripts/themes/cern/cara_script.sh rename to caimira/scripts/themes/cern/caimira_script.sh index 9861ef74..306b94c9 100755 --- a/cara/scripts/themes/cern/cara_script.sh +++ b/caimira/scripts/themes/cern/caimira_script.sh @@ -1,8 +1,8 @@ git clone https://gitlab.cern.ch/cara/cara.git -cd cara +cd caimira pip install -e . echo "############################################" -echo "CARA is now running at http://localhost:8080" +echo "CAiMIRA is now running at http://localhost:8080" echo "############################################" -python -m cara.apps.calculator --theme=cara/apps/templates/cern +python -m caimira.apps.calculator --theme=caimira/apps/templates/cern diff --git a/cara/state.py b/caimira/state.py similarity index 99% rename from cara/state.py rename to caimira/state.py index ddbd73a3..d65fe2c5 100644 --- a/cara/state.py +++ b/caimira/state.py @@ -5,7 +5,7 @@ for this purpose, but the need to define class-level attributes proved to be a limitation that meant we could not mutate the state from one subclass to another after the state was instantiated. -This module MUST not import other parts of cara as this would point at a +This module MUST not import other parts of caimira as this would point at a leaky abstraction. """ diff --git a/cara/tests/__init__.py b/caimira/tests/__init__.py similarity index 100% rename from cara/tests/__init__.py rename to caimira/tests/__init__.py diff --git a/cara/tests/apps/__init__.py b/caimira/tests/apps/__init__.py similarity index 100% rename from cara/tests/apps/__init__.py rename to caimira/tests/apps/__init__.py diff --git a/cara/tests/apps/calculator/__init__.py b/caimira/tests/apps/calculator/__init__.py similarity index 100% rename from cara/tests/apps/calculator/__init__.py rename to caimira/tests/apps/calculator/__init__.py diff --git a/cara/tests/apps/calculator/conftest.py b/caimira/tests/apps/calculator/conftest.py similarity index 81% rename from cara/tests/apps/calculator/conftest.py rename to caimira/tests/apps/calculator/conftest.py index 6e9c4074..7e46d0cf 100644 --- a/cara/tests/apps/calculator/conftest.py +++ b/caimira/tests/apps/calculator/conftest.py @@ -1,6 +1,6 @@ import pytest -from cara.apps.calculator import model_generator +from caimira.apps.calculator import model_generator @pytest.fixture diff --git a/cara/tests/apps/calculator/test_markdown_tools.py b/caimira/tests/apps/calculator/test_markdown_tools.py similarity index 91% rename from cara/tests/apps/calculator/test_markdown_tools.py rename to caimira/tests/apps/calculator/test_markdown_tools.py index 8b913067..9dfe0781 100644 --- a/cara/tests/apps/calculator/test_markdown_tools.py +++ b/caimira/tests/apps/calculator/test_markdown_tools.py @@ -3,7 +3,7 @@ import textwrap import jinja2 import pytest -import cara.apps.calculator.markdown_tools as md_tools +import caimira.apps.calculator.markdown_tools as md_tools @pytest.fixture diff --git a/cara/tests/apps/calculator/test_model_generator.py b/caimira/tests/apps/calculator/test_model_generator.py similarity index 98% rename from cara/tests/apps/calculator/test_model_generator.py rename to caimira/tests/apps/calculator/test_model_generator.py index 2ebd9ced..43c1a657 100644 --- a/cara/tests/apps/calculator/test_model_generator.py +++ b/caimira/tests/apps/calculator/test_model_generator.py @@ -6,11 +6,11 @@ import numpy.testing as npt import pytest from retry import retry -from cara.apps.calculator import model_generator -from cara.apps.calculator.model_generator import _hours2timestring -from cara.apps.calculator.model_generator import minutes_since_midnight -from cara import models -from cara.monte_carlo.data import expiration_distributions +from caimira.apps.calculator import model_generator +from caimira.apps.calculator.model_generator import _hours2timestring +from caimira.apps.calculator.model_generator import minutes_since_midnight +from caimira import models +from caimira.monte_carlo.data import expiration_distributions def test_model_from_dict(baseline_form_data): diff --git a/cara/tests/apps/calculator/test_report_generator.py b/caimira/tests/apps/calculator/test_report_generator.py similarity index 93% rename from cara/tests/apps/calculator/test_report_generator.py rename to caimira/tests/apps/calculator/test_report_generator.py index c18fdd45..4dcba65c 100644 --- a/cara/tests/apps/calculator/test_report_generator.py +++ b/caimira/tests/apps/calculator/test_report_generator.py @@ -6,14 +6,14 @@ import numpy.testing import numpy as np import pytest -from cara.apps.calculator import make_app -from cara.apps.calculator.report_generator import ReportGenerator, readable_minutes -import cara.apps.calculator.report_generator as rep_gen +from caimira.apps.calculator import make_app +from caimira.apps.calculator.report_generator import ReportGenerator, readable_minutes +import caimira.apps.calculator.report_generator as rep_gen def test_generate_report(baseline_form): # This is a simple test that confirms that given a model, we can actually - # generate a report for it. Because this is what happens in the cara + # generate a report for it. Because this is what happens in the caimira # calculator, we confirm that the generation happens within a reasonable # time threshold. time_limit: float = 20.0 # seconds diff --git a/cara/tests/apps/calculator/test_report_json.py b/caimira/tests/apps/calculator/test_report_json.py similarity index 85% rename from cara/tests/apps/calculator/test_report_json.py rename to caimira/tests/apps/calculator/test_report_json.py index a15983df..95cb60a1 100644 --- a/cara/tests/apps/calculator/test_report_json.py +++ b/caimira/tests/apps/calculator/test_report_json.py @@ -2,8 +2,8 @@ import json import tornado.testing -import cara.apps.calculator -from cara.apps.calculator import model_generator +import caimira.apps.calculator +from caimira.apps.calculator import model_generator _TIMEOUT = 40. @@ -14,7 +14,7 @@ class TestCalculatorJsonResponse(tornado.testing.AsyncHTTPTestCase): self.http_client.defaults['request_timeout'] = _TIMEOUT def get_app(self): - return cara.apps.calculator.make_app() + return caimira.apps.calculator.make_app() @tornado.testing.gen_test(timeout=_TIMEOUT) def test_json_response(self): @@ -29,3 +29,4 @@ class TestCalculatorJsonResponse(tornado.testing.AsyncHTTPTestCase): data = json.loads(response.body) self.assertIsInstance(data['prob_inf'], float) self.assertIsInstance(data['expected_new_cases'], float) + diff --git a/cara/tests/apps/calculator/test_webapp.py b/caimira/tests/apps/calculator/test_webapp.py similarity index 89% rename from cara/tests/apps/calculator/test_webapp.py rename to caimira/tests/apps/calculator/test_webapp.py index 65ae284d..be604f0a 100644 --- a/cara/tests/apps/calculator/test_webapp.py +++ b/caimira/tests/apps/calculator/test_webapp.py @@ -4,15 +4,15 @@ import pytest import tornado.testing from retry import retry -import cara.apps.calculator -from cara.apps.calculator.report_generator import generate_permalink +import caimira.apps.calculator +from caimira.apps.calculator.report_generator import generate_permalink _TIMEOUT = 20. @pytest.fixture def app(): - return cara.apps.calculator.make_app() + return caimira.apps.calculator.make_app() async def test_homepage(http_server_client): @@ -47,7 +47,7 @@ async def test_404(http_server_client): @retry(tries=10) class TestBasicApp(tornado.testing.AsyncHTTPTestCase): def get_app(self): - return cara.apps.calculator.make_app() + return caimira.apps.calculator.make_app() @tornado.testing.gen_test(timeout=_TIMEOUT) def test_report(self): @@ -76,8 +76,8 @@ class TestBasicApp(tornado.testing.AsyncHTTPTestCase): @retry(tries=10) class TestCernApp(tornado.testing.AsyncHTTPTestCase): def get_app(self): - cern_theme = Path(cara.apps.calculator.__file__).parent.parent / 'themes' / 'cern' - return cara.apps.calculator.make_app(theme_dir=cern_theme) + cern_theme = Path(caimira.apps.calculator.__file__).parent.parent / 'themes' / 'cern' + return caimira.apps.calculator.make_app(theme_dir=cern_theme) @tornado.testing.gen_test(timeout=_TIMEOUT) def test_report(self): @@ -89,7 +89,7 @@ class TestCernApp(tornado.testing.AsyncHTTPTestCase): retry(tries=10) class TestOpenApp(tornado.testing.AsyncHTTPTestCase): def get_app(self): - return cara.apps.calculator.make_app(calculator_prefix="/mycalc") + return caimira.apps.calculator.make_app(calculator_prefix="/mycalc") @tornado.testing.gen_test(timeout=_TIMEOUT) def test_report(self): @@ -134,10 +134,10 @@ async def test_invalid_compressed_url(http_server_client, baseline_form): class TestError500(tornado.testing.AsyncHTTPTestCase): def get_app(self): - class ProcessingErrorPage(cara.apps.calculator.BaseRequestHandler): + class ProcessingErrorPage(caimira.apps.calculator.BaseRequestHandler): def get(self): raise ValueError('some unexpected error') - app = cara.apps.calculator.make_app() + app = caimira.apps.calculator.make_app() page = [ (r'/', ProcessingErrorPage), ] diff --git a/cara/tests/apps/test_expert_app.py b/caimira/tests/apps/test_expert_app.py similarity index 90% rename from cara/tests/apps/test_expert_app.py rename to caimira/tests/apps/test_expert_app.py index 3e4d2362..c94f8206 100644 --- a/cara/tests/apps/test_expert_app.py +++ b/caimira/tests/apps/test_expert_app.py @@ -1,11 +1,11 @@ import pytest -import cara.apps +import caimira.apps @pytest.fixture def expert_app(): - return cara.apps.ExpertApplication() + return caimira.apps.ExpertApplication() def test_app(expert_app): diff --git a/cara/tests/conftest.py b/caimira/tests/conftest.py similarity index 90% rename from cara/tests/conftest.py rename to caimira/tests/conftest.py index 2f9a3dc9..b64c0b20 100644 --- a/cara/tests/conftest.py +++ b/caimira/tests/conftest.py @@ -1,6 +1,6 @@ -from cara import models -import cara.data -import cara.dataclass_utils +from caimira import models +import caimira.data +import caimira.dataclass_utils import pytest @@ -51,11 +51,11 @@ def baseline_exposure_model(baseline_concentration_model, baseline_sr_model): @pytest.fixture def exposure_model_w_outside_temp_changes(baseline_exposure_model: models.ExposureModel): - exp_model = cara.dataclass_utils.nested_replace( + exp_model = caimira.dataclass_utils.nested_replace( baseline_exposure_model, { 'concentration_model.ventilation': models.SlidingWindow( active=models.PeriodicInterval(2.2 * 60, 1.8 * 60), - outside_temp=cara.data.GenevaTemperatures['Jan'], + outside_temp=caimira.data.GenevaTemperatures['Jan'], window_height=1.6, opening_length=0.6, ) diff --git a/cara/tests/data/__init__.py b/caimira/tests/data/__init__.py similarity index 100% rename from cara/tests/data/__init__.py rename to caimira/tests/data/__init__.py diff --git a/cara/tests/data/test_weather.py b/caimira/tests/data/test_weather.py similarity index 98% rename from cara/tests/data/test_weather.py rename to caimira/tests/data/test_weather.py index 2a667df8..03eb29c3 100644 --- a/cara/tests/data/test_weather.py +++ b/caimira/tests/data/test_weather.py @@ -5,7 +5,7 @@ import numpy as np import numpy.testing import pytest -import cara.data.weather as wx +import caimira.data.weather as wx def test_nearest_wx_station(): diff --git a/cara/tests/models/__init__.py b/caimira/tests/models/__init__.py similarity index 100% rename from cara/tests/models/__init__.py rename to caimira/tests/models/__init__.py diff --git a/cara/tests/models/test_concentration_model.py b/caimira/tests/models/test_concentration_model.py similarity index 99% rename from cara/tests/models/test_concentration_model.py rename to caimira/tests/models/test_concentration_model.py index ea11a005..0f6acb37 100644 --- a/cara/tests/models/test_concentration_model.py +++ b/caimira/tests/models/test_concentration_model.py @@ -4,7 +4,7 @@ import numpy as np import numpy.testing as npt import pytest -from cara import models +from caimira import models @pytest.mark.parametrize( diff --git a/cara/tests/models/test_exposure_model.py b/caimira/tests/models/test_exposure_model.py similarity index 98% rename from cara/tests/models/test_exposure_model.py rename to caimira/tests/models/test_exposure_model.py index 667ebf0b..49662bf0 100644 --- a/cara/tests/models/test_exposure_model.py +++ b/caimira/tests/models/test_exposure_model.py @@ -5,9 +5,9 @@ import numpy.testing import pytest from dataclasses import dataclass -from cara import models -from cara.models import ExposureModel -from cara.dataclass_utils import replace +from caimira import models +from caimira.models import ExposureModel +from caimira.dataclass_utils import replace @dataclass(frozen=True) diff --git a/cara/tests/models/test_mask.py b/caimira/tests/models/test_mask.py similarity index 97% rename from cara/tests/models/test_mask.py rename to caimira/tests/models/test_mask.py index 08004fa1..5d87ac61 100644 --- a/cara/tests/models/test_mask.py +++ b/caimira/tests/models/test_mask.py @@ -2,7 +2,7 @@ import numpy as np import numpy.testing as npt import pytest -from cara import models +from caimira import models @pytest.mark.parametrize( diff --git a/cara/tests/models/test_piecewiseconstant.py b/caimira/tests/models/test_piecewiseconstant.py similarity index 98% rename from cara/tests/models/test_piecewiseconstant.py rename to caimira/tests/models/test_piecewiseconstant.py index 9ef3befb..74c8a056 100644 --- a/cara/tests/models/test_piecewiseconstant.py +++ b/caimira/tests/models/test_piecewiseconstant.py @@ -1,8 +1,8 @@ import numpy as np import pytest -from cara import models -from cara import data +from caimira import models +from caimira import data def test_piecewiseconstantfunction_wrongarguments(): diff --git a/cara/tests/models/test_short_range_model.py b/caimira/tests/models/test_short_range_model.py similarity index 96% rename from cara/tests/models/test_short_range_model.py rename to caimira/tests/models/test_short_range_model.py index a62b23d8..28bb8934 100644 --- a/cara/tests/models/test_short_range_model.py +++ b/caimira/tests/models/test_short_range_model.py @@ -3,10 +3,10 @@ import typing import numpy as np import pytest -from cara import models -import cara.monte_carlo as mc_models -from cara.apps.calculator.model_generator import build_expiration -from cara.monte_carlo.data import short_range_expiration_distributions,\ +from caimira import models +import caimira.monte_carlo as mc_models +from caimira.apps.calculator.model_generator import build_expiration +from caimira.monte_carlo.data import short_range_expiration_distributions,\ expiration_distributions, short_range_distances, activity_distributions SAMPLE_SIZE = 250_000 diff --git a/cara/tests/models/test_virus.py b/caimira/tests/models/test_virus.py similarity index 97% rename from cara/tests/models/test_virus.py rename to caimira/tests/models/test_virus.py index 650da211..060ae6af 100644 --- a/cara/tests/models/test_virus.py +++ b/caimira/tests/models/test_virus.py @@ -2,7 +2,7 @@ import numpy as np import numpy.testing as npt import pytest -from cara import models +from caimira import models @pytest.mark.parametrize( diff --git a/cara/tests/test_cara.py b/caimira/tests/test_caimira.py similarity index 53% rename from cara/tests/test_cara.py rename to caimira/tests/test_caimira.py index 0e8dfdb0..c99882be 100644 --- a/cara/tests/test_cara.py +++ b/caimira/tests/test_caimira.py @@ -3,8 +3,8 @@ High-level tests for the package. """ -import cara +import caimira def test_version(): - assert cara.__version__ is not None + assert caimira.__version__ is not None diff --git a/cara/tests/test_dataclass_utils.py b/caimira/tests/test_dataclass_utils.py similarity index 91% rename from cara/tests/test_dataclass_utils.py rename to caimira/tests/test_dataclass_utils.py index 270066ee..ac575052 100644 --- a/cara/tests/test_dataclass_utils.py +++ b/caimira/tests/test_dataclass_utils.py @@ -1,6 +1,6 @@ import dataclasses -from cara.dataclass_utils import nested_replace, walk_dataclass +from caimira.dataclass_utils import nested_replace, walk_dataclass @dataclasses.dataclass(frozen=True) diff --git a/cara/tests/test_expiration.py b/caimira/tests/test_expiration.py similarity index 95% rename from cara/tests/test_expiration.py rename to caimira/tests/test_expiration.py index b9a04cf9..4d498775 100644 --- a/cara/tests/test_expiration.py +++ b/caimira/tests/test_expiration.py @@ -5,8 +5,8 @@ import numpy.testing as npt import pytest from retry import retry -from cara import models -from cara.monte_carlo.data import expiration_distribution +from caimira import models +from caimira.monte_carlo.data import expiration_distribution def test_multiple_wrong_weight_size(): diff --git a/cara/tests/test_full_algorithm.py b/caimira/tests/test_full_algorithm.py similarity index 98% rename from cara/tests/test_full_algorithm.py rename to caimira/tests/test_full_algorithm.py index ff16335c..89af5545 100644 --- a/cara/tests/test_full_algorithm.py +++ b/caimira/tests/test_full_algorithm.py @@ -8,12 +8,12 @@ import numpy.testing as npt import pytest from retry import retry -import cara.monte_carlo as mc -from cara import models,data -from cara.utils import method_cache -from cara.models import _VectorisedFloat,Interval,SpecificInterval -from cara.monte_carlo.sampleable import LogNormal -from cara.monte_carlo.data import (expiration_distributions, +import caimira.monte_carlo as mc +from caimira import models,data +from caimira.utils import method_cache +from caimira.models import _VectorisedFloat,Interval,SpecificInterval +from caimira.monte_carlo.sampleable import LogNormal +from caimira.monte_carlo.data import (expiration_distributions, expiration_BLO_factors,short_range_expiration_distributions, short_range_distances,virus_distributions,activity_distributions) @@ -29,7 +29,7 @@ ln2 = np.log(2) class SimpleConcentrationModel: """ Simple model for the background (long-range) concentration, without - all the flexibility of cara.models.ConcentrationModel. + all the flexibility of caimira.models.ConcentrationModel. For independent, end-to-end testing purposes. This assumes no mask wearing, and the same ventilation rate at all times. @@ -183,7 +183,7 @@ class SimpleConcentrationModel: class SimpleShortRangeModel: """ Simple model for the short-range concentration, without - all the flexibility of cara.models.ShortRangeModel. + all the flexibility of caimira.models.ShortRangeModel. For independent, end-to-end testing purposes. This assumes no mask wearing. """ @@ -286,7 +286,7 @@ class SimpleShortRangeModel: class SimpleExposureModel(SimpleConcentrationModel): """ Simple model for the background (long-range) exposure, without - all the flexibility of cara.models.ExposureModel. + all the flexibility of caimira.models.ExposureModel. For independent, end-to-end testing purposes. This assumes no mask wearing, identical inhalation and exhalation breathing rate, indentical presence for the infected and the exposed diff --git a/cara/tests/test_infected_population.py b/caimira/tests/test_infected_population.py similarity index 74% rename from cara/tests/test_infected_population.py rename to caimira/tests/test_infected_population.py index 8856d312..8937d1af 100644 --- a/cara/tests/test_infected_population.py +++ b/caimira/tests/test_infected_population.py @@ -1,7 +1,7 @@ import numpy as np import pytest -import cara.models +import caimira.models @pytest.mark.parametrize( @@ -17,25 +17,25 @@ def test_infected_population_vectorisation(override_params): } defaults.update(override_params) - office_hours = cara.models.SpecificInterval(present_times=[(8,17)]) - infected = cara.models.InfectedPopulation( + office_hours = caimira.models.SpecificInterval(present_times=[(8,17)]) + infected = caimira.models.InfectedPopulation( number=1, presence=office_hours, - mask=cara.models.Mask( + mask=caimira.models.Mask( factor_exhale=0.95, η_inhale=0.3, ), - activity=cara.models.Activity( + activity=caimira.models.Activity( 0.51, defaults['exhalation_rate'], ), - virus=cara.models.Virus( + virus=caimira.models.Virus( viral_load_in_sputum=defaults['viral_load_in_sputum'], infectious_dose=50., viable_to_RNA_ratio = 0.5, transmissibility_factor=1.0, ), - expiration=cara.models._ExpirationBase.types['Breathing'], + expiration=caimira.models._ExpirationBase.types['Breathing'], host_immunity=0., ) emission_rate = infected.emission_rate(10) diff --git a/cara/tests/test_known_quantities.py b/caimira/tests/test_known_quantities.py similarity index 99% rename from cara/tests/test_known_quantities.py rename to caimira/tests/test_known_quantities.py index 19314824..8f061486 100644 --- a/cara/tests/test_known_quantities.py +++ b/caimira/tests/test_known_quantities.py @@ -2,8 +2,8 @@ import numpy as np import numpy.testing as npt import pytest -import cara.models as models -import cara.data as data +import caimira.models as models +import caimira.data as data def test_no_mask_superspeading_emission_rate(baseline_concentration_model): diff --git a/cara/tests/test_model.py b/caimira/tests/test_model.py similarity index 87% rename from cara/tests/test_model.py rename to caimira/tests/test_model.py index add6a899..eec01921 100644 --- a/cara/tests/test_model.py +++ b/caimira/tests/test_model.py @@ -1,5 +1,5 @@ -import cara.models -from cara.dataclass_utils import nested_replace +import caimira.models +from caimira.dataclass_utils import nested_replace def test_exposure_r0(baseline_exposure_model): diff --git a/caimira/tests/test_monte_carlo.py b/caimira/tests/test_monte_carlo.py new file mode 100644 index 00000000..c549e501 --- /dev/null +++ b/caimira/tests/test_monte_carlo.py @@ -0,0 +1,97 @@ +import dataclasses + +import numpy as np +import pytest + +import caimira.models +import caimira.monte_carlo.models as mc_models +import caimira.monte_carlo.sampleable + +MODEL_CLASSES = [ + cls for cls in vars(caimira.models).values() + if dataclasses.is_dataclass(cls) +] + + +def test_type_annotations(): + # Check that there are appropriate type annotations for all of the model + # classes in caimira.models. Note that these must be statically defined in + # caimira.monte_carlo, rather than being dynamically generated, in order to + # allow the type system to be able to see their definition without needing + # runtime execution. + missing = [] + for cls in MODEL_CLASSES: + if not hasattr(caimira.monte_carlo, cls.__name__): + missing.append(cls.__name__) + continue + mc_cls = getattr(caimira.monte_carlo, cls.__name__) + assert issubclass(mc_cls, caimira.monte_carlo.MCModelBase) + + if missing: + msg = ( + 'There are missing model implementations in caimira.monte_carlo. ' + 'The following definitions are needed:\n ' + + '\n '.join([f'{model} = build_mc_model(caimira.models.{model})' for model in missing]) + ) + pytest.fail(msg) + + +@pytest.fixture +def baseline_mc_concentration_model() -> caimira.monte_carlo.ConcentrationModel: + mc_model = caimira.monte_carlo.ConcentrationModel( + room=caimira.monte_carlo.Room(volume=caimira.monte_carlo.sampleable.Normal(75, 20), + inside_temp=caimira.models.PiecewiseConstant((0., 24.), (293,))), + ventilation=caimira.monte_carlo.SlidingWindow( + active=caimira.models.PeriodicInterval(period=120, duration=120), + outside_temp=caimira.models.PiecewiseConstant((0., 24.), (283,)), + window_height=1.6, opening_length=0.6, + ), + infected=caimira.models.InfectedPopulation( + number=1, + virus=caimira.models.Virus.types['SARS_CoV_2'], + presence=caimira.models.SpecificInterval(((0., 4.), (5., 8.))), + mask=caimira.models.Mask.types['No mask'], + activity=caimira.models.Activity.types['Light activity'], + expiration=caimira.models.Expiration.types['Breathing'], + host_immunity=0., + ), + evaporation_factor=0.3, + ) + return mc_model + + +@pytest.fixture +def baseline_mc_sr_model() -> caimira.monte_carlo.ShortRangeModel: + return () + + +@pytest.fixture +def baseline_mc_exposure_model(baseline_mc_concentration_model, baseline_mc_sr_model) -> caimira.monte_carlo.ExposureModel: + return caimira.monte_carlo.ExposureModel( + baseline_mc_concentration_model, + baseline_mc_sr_model, + exposed=caimira.models.Population( + number=10, + presence=baseline_mc_concentration_model.infected.presence, + activity=baseline_mc_concentration_model.infected.activity, + mask=baseline_mc_concentration_model.infected.mask, + host_immunity=0., + ) + ) + + +def test_build_concentration_model(baseline_mc_concentration_model: caimira.monte_carlo.ConcentrationModel): + model = baseline_mc_concentration_model.build_model(7) + assert isinstance(model, caimira.models.ConcentrationModel) + assert isinstance(model.concentration(time=0.), float) + conc = model.concentration(time=1.) + assert isinstance(conc, np.ndarray) + assert conc.shape == (7, ) + + +def test_build_exposure_model(baseline_mc_exposure_model: caimira.monte_carlo.ExposureModel): + model = baseline_mc_exposure_model.build_model(7) + assert isinstance(model, caimira.models.ExposureModel) + prob = model.deposited_exposure() + assert isinstance(prob, np.ndarray) + assert prob.shape == (7, ) diff --git a/cara/tests/test_monte_carlo_full_models.py b/caimira/tests/test_monte_carlo_full_models.py similarity index 97% rename from cara/tests/test_monte_carlo_full_models.py rename to caimira/tests/test_monte_carlo_full_models.py index ffbaef42..dfcff434 100644 --- a/cara/tests/test_monte_carlo_full_models.py +++ b/caimira/tests/test_monte_carlo_full_models.py @@ -3,10 +3,10 @@ import numpy.testing as npt import pytest from retry import retry -import cara.monte_carlo as mc -from cara import models,data -from cara.monte_carlo.data import activity_distributions, virus_distributions, expiration_distributions, infectious_dose_distribution, viable_to_RNA_ratio_distribution -from cara.apps.calculator.model_generator import build_expiration +import caimira.monte_carlo as mc +from caimira import models,data +from caimira.monte_carlo.data import activity_distributions, virus_distributions, expiration_distributions, infectious_dose_distribution, viable_to_RNA_ratio_distribution +from caimira.apps.calculator.model_generator import build_expiration SAMPLE_SIZE = 500_000 TOLERANCE = 0.05 diff --git a/cara/tests/test_predefined_distributions.py b/caimira/tests/test_predefined_distributions.py similarity index 94% rename from cara/tests/test_predefined_distributions.py rename to caimira/tests/test_predefined_distributions.py index 959565f7..e2c029da 100644 --- a/cara/tests/test_predefined_distributions.py +++ b/caimira/tests/test_predefined_distributions.py @@ -2,7 +2,7 @@ import numpy as np import numpy.testing as npt import pytest -from cara.monte_carlo.data import activity_distributions, virus_distributions +from caimira.monte_carlo.data import activity_distributions, virus_distributions # Mean & std deviations from https://doi.org/10.1101/2021.10.14.21264988 (Table 3) diff --git a/cara/tests/test_sampleable_distribution.py b/caimira/tests/test_sampleable_distribution.py similarity index 99% rename from cara/tests/test_sampleable_distribution.py rename to caimira/tests/test_sampleable_distribution.py index 76544b35..98f0a9ca 100644 --- a/cara/tests/test_sampleable_distribution.py +++ b/caimira/tests/test_sampleable_distribution.py @@ -3,7 +3,7 @@ import numpy.testing as npt import pytest from retry import retry -from cara.monte_carlo import sampleable +from caimira.monte_carlo import sampleable @retry(tries=10) diff --git a/cara/tests/test_state.py b/caimira/tests/test_state.py similarity index 99% rename from cara/tests/test_state.py rename to caimira/tests/test_state.py index 814d2ae4..f984136d 100644 --- a/cara/tests/test_state.py +++ b/caimira/tests/test_state.py @@ -4,7 +4,7 @@ from unittest.mock import Mock import pytest -from cara import state +from caimira import state @dataclass diff --git a/cara/tests/test_ventilation.py b/caimira/tests/test_ventilation.py similarity index 99% rename from cara/tests/test_ventilation.py rename to caimira/tests/test_ventilation.py index 201da2c7..4a09782f 100644 --- a/cara/tests/test_ventilation.py +++ b/caimira/tests/test_ventilation.py @@ -4,7 +4,7 @@ import numpy as np import numpy.testing as npt import pytest -from cara import models +from caimira import models @pytest.fixture diff --git a/cara/utils.py b/caimira/utils.py similarity index 100% rename from cara/utils.py rename to caimira/utils.py diff --git a/cara/docs/cara.apps.calculator.rst b/cara/docs/cara.apps.calculator.rst deleted file mode 100644 index 0ac63777..00000000 --- a/cara/docs/cara.apps.calculator.rst +++ /dev/null @@ -1,45 +0,0 @@ -cara.apps.calculator package -============================ - -Submodules ----------- - -cara.apps.calculator.markdown\_tools module -------------------------------------------- - -.. automodule:: cara.apps.calculator.markdown_tools - :members: - :undoc-members: - :show-inheritance: - -cara.apps.calculator.model\_generator module --------------------------------------------- - -.. automodule:: cara.apps.calculator.model_generator - :members: - :undoc-members: - :show-inheritance: - -cara.apps.calculator.report\_generator module ---------------------------------------------- - -.. automodule:: cara.apps.calculator.report_generator - :members: - :undoc-members: - :show-inheritance: - -cara.apps.calculator.user module --------------------------------- - -.. automodule:: cara.apps.calculator.user - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: cara.apps.calculator - :members: - :undoc-members: - :show-inheritance: diff --git a/cara/docs/cara.monte_carlo.rst b/cara/docs/cara.monte_carlo.rst deleted file mode 100644 index eca899a8..00000000 --- a/cara/docs/cara.monte_carlo.rst +++ /dev/null @@ -1,37 +0,0 @@ -cara.monte\_carlo package -========================= - -Submodules ----------- - -cara.monte\_carlo.data module ------------------------------ - -.. automodule:: cara.monte_carlo.data - :members: - :undoc-members: - :show-inheritance: - -cara.monte\_carlo.models module -------------------------------- - -.. automodule:: cara.monte_carlo.models - :members: - :undoc-members: - :show-inheritance: - -cara.monte\_carlo.sampleable module ------------------------------------ - -.. automodule:: cara.monte_carlo.sampleable - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: cara.monte_carlo - :members: - :undoc-members: - :show-inheritance: diff --git a/cara/docs/cara.rst b/cara/docs/cara.rst deleted file mode 100644 index b769848b..00000000 --- a/cara/docs/cara.rst +++ /dev/null @@ -1,56 +0,0 @@ -CARA source code -================ - -Subpackages ------------ - -.. toctree:: - :maxdepth: 4 - - cara.apps - cara.data - cara.monte_carlo - cara.tests - -Submodules ----------- - -cara.dataclass\_utils module ----------------------------- - -.. automodule:: cara.dataclass_utils - :members: - :undoc-members: - :show-inheritance: - -cara.models module ------------------- - -.. automodule:: cara.models - :members: - :undoc-members: - :show-inheritance: - -cara.state module ------------------ - -.. automodule:: cara.state - :members: - :undoc-members: - :show-inheritance: - -cara.utils module ------------------ - -.. automodule:: cara.utils - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: cara - :members: - :undoc-members: - :show-inheritance: diff --git a/cara/docs/cara.tests.apps.calculator.rst b/cara/docs/cara.tests.apps.calculator.rst deleted file mode 100644 index 9dedbf22..00000000 --- a/cara/docs/cara.tests.apps.calculator.rst +++ /dev/null @@ -1,53 +0,0 @@ -cara.tests.apps.calculator package -================================== - -Submodules ----------- - -cara.tests.apps.calculator.conftest module ------------------------------------------- - -.. automodule:: cara.tests.apps.calculator.conftest - :members: - :undoc-members: - :show-inheritance: - -cara.tests.apps.calculator.test\_markdown\_tools module -------------------------------------------------------- - -.. automodule:: cara.tests.apps.calculator.test_markdown_tools - :members: - :undoc-members: - :show-inheritance: - -cara.tests.apps.calculator.test\_model\_generator module --------------------------------------------------------- - -.. automodule:: cara.tests.apps.calculator.test_model_generator - :members: - :undoc-members: - :show-inheritance: - -cara.tests.apps.calculator.test\_report\_generator module ---------------------------------------------------------- - -.. automodule:: cara.tests.apps.calculator.test_report_generator - :members: - :undoc-members: - :show-inheritance: - -cara.tests.apps.calculator.test\_webapp module ----------------------------------------------- - -.. automodule:: cara.tests.apps.calculator.test_webapp - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: cara.tests.apps.calculator - :members: - :undoc-members: - :show-inheritance: diff --git a/cara/docs/cara.tests.apps.rst b/cara/docs/cara.tests.apps.rst deleted file mode 100644 index 625aed14..00000000 --- a/cara/docs/cara.tests.apps.rst +++ /dev/null @@ -1,29 +0,0 @@ -cara.tests.apps package -======================= - -Subpackages ------------ - -.. toctree:: - :maxdepth: 4 - - cara.tests.apps.calculator - -Submodules ----------- - -cara.tests.apps.test\_expert\_app module ----------------------------------------- - -.. automodule:: cara.tests.apps.test_expert_app - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: cara.tests.apps - :members: - :undoc-members: - :show-inheritance: diff --git a/cara/docs/cara.tests.data.rst b/cara/docs/cara.tests.data.rst deleted file mode 100644 index 18524ecf..00000000 --- a/cara/docs/cara.tests.data.rst +++ /dev/null @@ -1,21 +0,0 @@ -cara.tests.data package -======================= - -Submodules ----------- - -cara.tests.data.test\_weather module ------------------------------------- - -.. automodule:: cara.tests.data.test_weather - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: cara.tests.data - :members: - :undoc-members: - :show-inheritance: diff --git a/cara/docs/cara.tests.models.rst b/cara/docs/cara.tests.models.rst deleted file mode 100644 index 9a3df291..00000000 --- a/cara/docs/cara.tests.models.rst +++ /dev/null @@ -1,53 +0,0 @@ -cara.tests.models package -========================= - -Submodules ----------- - -cara.tests.models.test\_concentration\_model module ---------------------------------------------------- - -.. automodule:: cara.tests.models.test_concentration_model - :members: - :undoc-members: - :show-inheritance: - -cara.tests.models.test\_exposure\_model module ----------------------------------------------- - -.. automodule:: cara.tests.models.test_exposure_model - :members: - :undoc-members: - :show-inheritance: - -cara.tests.models.test\_mask module ------------------------------------ - -.. automodule:: cara.tests.models.test_mask - :members: - :undoc-members: - :show-inheritance: - -cara.tests.models.test\_piecewiseconstant module ------------------------------------------------- - -.. automodule:: cara.tests.models.test_piecewiseconstant - :members: - :undoc-members: - :show-inheritance: - -cara.tests.models.test\_short\_range\_model module --------------------------------------------------- - -.. automodule:: cara.tests.models.test_short_range_model - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: cara.tests.models - :members: - :undoc-members: - :show-inheritance: diff --git a/cara/docs/cara.tests.rst b/cara/docs/cara.tests.rst deleted file mode 100644 index 8cf1a976..00000000 --- a/cara/docs/cara.tests.rst +++ /dev/null @@ -1,135 +0,0 @@ -cara.tests package -================== - -Subpackages ------------ - -.. toctree:: - :maxdepth: 4 - - cara.tests.apps - cara.tests.data - cara.tests.models - -Submodules ----------- - -cara.tests.conftest module --------------------------- - -.. automodule:: cara.tests.conftest - :members: - :undoc-members: - :show-inheritance: - -cara.tests.test\_cara module ----------------------------- - -.. automodule:: cara.tests.test_cara - :members: - :undoc-members: - :show-inheritance: - -cara.tests.test\_dataclass\_utils module ----------------------------------------- - -.. automodule:: cara.tests.test_dataclass_utils - :members: - :undoc-members: - :show-inheritance: - -cara.tests.test\_expiration module ----------------------------------- - -.. automodule:: cara.tests.test_expiration - :members: - :undoc-members: - :show-inheritance: - -cara.tests.test\_full\_algorithm module ---------------------------------------- - -.. automodule:: cara.tests.test_full_algorithm - :members: - :undoc-members: - :show-inheritance: - -cara.tests.test\_infected\_population module --------------------------------------------- - -.. automodule:: cara.tests.test_infected_population - :members: - :undoc-members: - :show-inheritance: - -cara.tests.test\_known\_quantities module ------------------------------------------ - -.. automodule:: cara.tests.test_known_quantities - :members: - :undoc-members: - :show-inheritance: - -cara.tests.test\_model module ------------------------------ - -.. automodule:: cara.tests.test_model - :members: - :undoc-members: - :show-inheritance: - -cara.tests.test\_monte\_carlo module ------------------------------------- - -.. automodule:: cara.tests.test_monte_carlo - :members: - :undoc-members: - :show-inheritance: - -cara.tests.test\_monte\_carlo\_full\_models module --------------------------------------------------- - -.. automodule:: cara.tests.test_monte_carlo_full_models - :members: - :undoc-members: - :show-inheritance: - -cara.tests.test\_predefined\_distributions module -------------------------------------------------- - -.. automodule:: cara.tests.test_predefined_distributions - :members: - :undoc-members: - :show-inheritance: - -cara.tests.test\_sampleable\_distribution module ------------------------------------------------- - -.. automodule:: cara.tests.test_sampleable_distribution - :members: - :undoc-members: - :show-inheritance: - -cara.tests.test\_state module ------------------------------ - -.. automodule:: cara.tests.test_state - :members: - :undoc-members: - :show-inheritance: - -cara.tests.test\_ventilation module ------------------------------------ - -.. automodule:: cara.tests.test_ventilation - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: cara.tests - :members: - :undoc-members: - :show-inheritance: diff --git a/cara/tests/test_monte_carlo.py b/cara/tests/test_monte_carlo.py deleted file mode 100644 index d709e6c1..00000000 --- a/cara/tests/test_monte_carlo.py +++ /dev/null @@ -1,97 +0,0 @@ -import dataclasses - -import numpy as np -import pytest - -import cara.models -import cara.monte_carlo.models as mc_models -import cara.monte_carlo.sampleable - -MODEL_CLASSES = [ - cls for cls in vars(cara.models).values() - if dataclasses.is_dataclass(cls) -] - - -def test_type_annotations(): - # Check that there are appropriate type annotations for all of the model - # classes in cara.models. Note that these must be statically defined in - # cara.monte_carlo, rather than being dynamically generated, in order to - # allow the type system to be able to see their definition without needing - # runtime execution. - missing = [] - for cls in MODEL_CLASSES: - if not hasattr(cara.monte_carlo, cls.__name__): - missing.append(cls.__name__) - continue - mc_cls = getattr(cara.monte_carlo, cls.__name__) - assert issubclass(mc_cls, cara.monte_carlo.MCModelBase) - - if missing: - msg = ( - 'There are missing model implementations in cara.monte_carlo. ' - 'The following definitions are needed:\n ' + - '\n '.join([f'{model} = build_mc_model(cara.models.{model})' for model in missing]) - ) - pytest.fail(msg) - - -@pytest.fixture -def baseline_mc_concentration_model() -> cara.monte_carlo.ConcentrationModel: - mc_model = cara.monte_carlo.ConcentrationModel( - room=cara.monte_carlo.Room(volume=cara.monte_carlo.sampleable.Normal(75, 20), - inside_temp=cara.models.PiecewiseConstant((0., 24.), (293,))), - ventilation=cara.monte_carlo.SlidingWindow( - active=cara.models.PeriodicInterval(period=120, duration=120), - outside_temp=cara.models.PiecewiseConstant((0., 24.), (283,)), - window_height=1.6, opening_length=0.6, - ), - infected=cara.models.InfectedPopulation( - number=1, - virus=cara.models.Virus.types['SARS_CoV_2'], - presence=cara.models.SpecificInterval(((0., 4.), (5., 8.))), - mask=cara.models.Mask.types['No mask'], - activity=cara.models.Activity.types['Light activity'], - expiration=cara.models.Expiration.types['Breathing'], - host_immunity=0., - ), - evaporation_factor=0.3, - ) - return mc_model - - -@pytest.fixture -def baseline_mc_sr_model() -> cara.monte_carlo.ShortRangeModel: - return () - - -@pytest.fixture -def baseline_mc_exposure_model(baseline_mc_concentration_model, baseline_mc_sr_model) -> cara.monte_carlo.ExposureModel: - return cara.monte_carlo.ExposureModel( - baseline_mc_concentration_model, - baseline_mc_sr_model, - exposed=cara.models.Population( - number=10, - presence=baseline_mc_concentration_model.infected.presence, - activity=baseline_mc_concentration_model.infected.activity, - mask=baseline_mc_concentration_model.infected.mask, - host_immunity=0., - ) - ) - - -def test_build_concentration_model(baseline_mc_concentration_model: cara.monte_carlo.ConcentrationModel): - model = baseline_mc_concentration_model.build_model(7) - assert isinstance(model, cara.models.ConcentrationModel) - assert isinstance(model.concentration(time=0.), float) - conc = model.concentration(time=1.) - assert isinstance(conc, np.ndarray) - assert conc.shape == (7, ) - - -def test_build_exposure_model(baseline_mc_exposure_model: cara.monte_carlo.ExposureModel): - model = baseline_mc_exposure_model.build_model(7) - assert isinstance(model, cara.models.ExposureModel) - prob = model.deposited_exposure() - assert isinstance(prob, np.ndarray) - assert prob.shape == (7, ) diff --git a/requirements.txt b/requirements.txt index a7a970cb..ceb2da70 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -# Created by installing the cara[app] extra and running: +# Created by installing the caimira[app] extra and running: # echo '.[app]' > requirements.txt -# pip list --format freeze | grep -vi cara | grep -v pip | grep -v setuptools >> requirements.txt +# pip list --format freeze | grep -vi caimira | grep -v pip | grep -v setuptools >> requirements.txt .[app] anyio==3.3.0 diff --git a/server-performance-tests/README.md b/server-performance-tests/README.md index 7bf5e43b..61fcaf7d 100644 --- a/server-performance-tests/README.md +++ b/server-performance-tests/README.md @@ -11,7 +11,7 @@ In order to set it up for the first time, we followed the documentation at https To use, uncomment the desired method on ``lucust.py``` file, open the terminal on this folder and run the following command: -``locust -f locust.py --host https://cara.web.cern.ch`` +``locust -f locust.py --host https://caimira.web.cern.ch`` Then, open up a browser and point it to http://localhost:8089. By default we pointed out the test to our own web server. diff --git a/setup.py b/setup.py index 1e12f4fa..108a3811 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ -# This module is part of CARA. Please see the repository at +# This module is part of CAiMIRA. Please see the repository at # https://gitlab.cern.ch/cara/cara for details of the license and terms of use. """ -setup.py for CARA. +setup.py for CAiMIRA. For reference see https://packaging.python.org/guides/distributing-packages-using-setuptools/ @@ -58,7 +58,7 @@ REQUIREMENTS: dict = { setup( - name='CARA', + name='CAiMIRA', version="1.0.0", maintainer='Andre Henriques', @@ -66,7 +66,7 @@ setup( description='COVID Airborne Risk Assessment', long_description=LONG_DESCRIPTION, long_description_content_type='text/markdown', - url='cern.ch/cara', + url='cern.ch/caimira', packages=find_packages(), python_requires='~=3.9', @@ -87,7 +87,7 @@ setup( # The 'all' extra is the union of all requirements. 'all': [req for reqs in REQUIREMENTS.values() for req in reqs], }, - package_data={'cara': [ + package_data={'caimira': [ 'apps/*/*', 'apps/*/*/*', 'apps/*/*/*/*',