Skip to content

Commit

Permalink
Merge branch 'pypi-releases' into 'master'
Browse files Browse the repository at this point in the history
releases: add PyPI config

Closes #430

See merge request caimira/caimira!518
  • Loading branch information
lrdossan committed Dec 3, 2024
2 parents a93e697 + 90fd2a5 commit 778444a
Show file tree
Hide file tree
Showing 15 changed files with 148 additions and 80 deletions.
23 changes: 23 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ docker-build-docs-release:

# ###################################################################################################
# Deploy to OpenShift

.deploy:
stage: deploy
image: gitlab-registry.cern.ch/paas-tools/openshift-client
Expand Down Expand Up @@ -249,3 +250,25 @@ deploy-docs-test:
IMAGE_NAME: caimira-docs
OPENSHIFT_DEPLOYMENT: caimira-test-docs
OPENSHIFT_CONTAINER_NAME: caimira-test-docs

# ###################################################################################################
# Publish on PyPI

.publish-to-pypi:
stage: deploy
image: python:3.12
script:
- cd caimira
- pip install build twine
- python -m build
- twine upload dist/* -u $PYPI_USERNAME -p $PYPI_TOKEN
rules:
- if: $CI_COMMIT_TAG

publish-caimira:
extends: .publish-to-pypi
variables:
PYPI_USERNAME: __token__
PYPI_TOKEN: $PYPI_TOKEN
rules:
- if: $CI_COMMIT_TAG
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Contributions are welcome on our [GitHub repository](https://github.com/CERN/CAi

Developed by CERN's HSE, Beams, and IT departments, in collaboration with WHO.

© Copyright 2020-2021 CERN. All rights not expressly granted are reserved.<br>
© Copyright 2020 CERN. All rights not expressly granted are reserved.<br>
Licensed under the Apache License, Version 2.0

See the full [license](caimira/LICENSE) for details.
2 changes: 1 addition & 1 deletion caimira/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2020-2021 CERN. All rights not expressly granted are reserved.
Copyright 2020 CERN. All rights not expressly granted are reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion caimira/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Contributions are welcome on our [GitHub repository](https://github.com/CERN/CAi

Developed by CERN's HSE, Beams, and IT departments, in collaboration with WHO.

© Copyright 2020-2021 CERN. All rights not expressly granted are reserved.<br>
© Copyright 2020 CERN. All rights not expressly granted are reserved.<br>
Licensed under the Apache License, Version 2.0

See the full [license](caimira/LICENSE) for details.
2 changes: 1 addition & 1 deletion caimira/docs/mkdocs/docs/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2020-2021 CERN. All rights not expressly granted are reserved.
Copyright 2020 CERN. All rights not expressly granted are reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
33 changes: 23 additions & 10 deletions caimira/docs/mkdocs/docs/code/rest_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,21 @@ The API is served by the **Tornado** web framework, which provides asynchronous

To run the API, follow these steps from the root directory of the project:

1. Install dependencies:
```
cd caimira
pip install -e .
```
1. Install dependencies (two options available):
- From previously cloned [GitLab Repository](https://gitlab.cern.ch/caimira/caimira):

cd caimira
pip install -e .

- From [PyPI](https://pypi.org/project/caimira/):

pip install caimira

2. Run the backend:
```
python -m caimira.api.app
```
The web server will be accessible on port `8081`.

python -m caimira.api.app

The web server will be accessible at [http://localhost:8081/](http://localhost:8081/).

#### API Endpoints

Expand Down Expand Up @@ -199,4 +203,13 @@ As the project is growing, more endpoints targeted to specific tasks will be dev
"room_capacity": "10",
"room_volume": "60",
"total_people": "2"
}'
}'

#### Development

For testing new releases, use the PyPI Test instance by running the following command (directory independent):

pip install --index-url https://test.pypi.org/simple --extra-index-url https://pypi.org/simple caimira

!!! info
`--extra-index-url` is necessary to resolve dependencies from PyPI.
2 changes: 1 addition & 1 deletion caimira/docs/mkdocs/docs/root/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ CAiMIRA – CERN Airborne Model for Indoor Risk Assessment tool

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6520431.svg)](https://doi.org/10.5281/zenodo.6520431)

© Copyright 2020-2021 CERN. All rights not expressly granted are reserved.
© Copyright 2020 CERN. All rights not expressly granted are reserved.

**For use of the CAiMIRA model**

Expand Down
146 changes: 91 additions & 55 deletions caimira/docs/mkdocs/docs/root/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This installation guide provides instructions for both quickly running CAiMIRA w
**Guide Overview**:

1. **[Quick Start](#quick-start)**: Designed for users aiming to run CAiMIRA with minimal setup. The Quick Guide section outlines the fastest approach to using CAiMIRA through a pre-built Docker image.
2. **[Development Installation](#development-installation)**: Intended for developers or those requiring advanced customization. This section includes detailed steps for setting up the environment, running the backend REST API, and contributing to the project.
2. **[Development Installation](#development-installation)**: Intended for developers or those requiring advanced customization. This section includes detailed steps for setting up the environment, customizing the UI, running the backend REST API, and contributing to the project.

## Quick Start

Expand Down Expand Up @@ -37,7 +37,7 @@ This will start a local version of CAiMIRA, which can be visited by loading this

This section provides comprehensive instructions for setting up the CAiMIRA environment in development mode. The guide is tailored for contributors and advanced users who want to build the project from source, customize its features, or contribute to its codebase<sup>1</sup>.

Developers can follow the steps below to build and run the CAiMIRA backend and frontend applications, set up APIs, run tests, and generate the documentation. Additionally, this section includes instructions for running legacy expert applications, profiling the system, and testing specific features.
Developers can follow the steps below to build and run the CAiMIRA backend, APIs, or Calculator applications, run tests, and generate the documentation. Additionally, this section includes instructions for running legacy expert applications, profiling the system, and testing specific features.

The project contains two different Python packages:

Expand All @@ -62,8 +62,8 @@ Before proceeding with the development installation of CAiMIRA, ensure that your

python -m pip install --upgrade pip setuptools

!!! note
It's recommended to use `pyenv` or similar tools to manage Python versions. For details on how to install and use `pyenv`, see [here](https://github.com/pyenv/pyenv). While not mandatory, it is also recommended to create a virtual environment (`virtualenv`) to avoid conflicts between different package versions. For more information on setting up a virtual environment, see [here](https://virtualenv.pypa.io/en/latest/).
!!! note
It's recommended to use `pyenv` or similar tools to manage Python versions. For details on how to install and use `pyenv`, see [here](https://github.com/pyenv/pyenv). While not mandatory, it is also recommended to create a virtual environment (`virtualenv`) to avoid conflicts between different package versions. For more information on setting up a virtual environment, see [here](https://virtualenv.pypa.io/en/latest/).

2. **Git**:

Expand All @@ -79,46 +79,49 @@ Before proceeding with the development installation of CAiMIRA, ensure that your

- A code editor such as [VSCode](https://code.visualstudio.com/), or an IDE like [PyCharm](https://www.jetbrains.com/pycharm/).

5. **Repository Setup**:
### Installing and running

- Clone the CAiMIRA repository from the GitLab or GitHub mirror by opening a terminal and running:

git clone https://gitlab.cern.ch/caimira/caimira.git
cd caimira
This section provides instructions for setting up, running, and testing CAiMIRA in a local development environment.

!!! note
The directory in which you run the previous commands will be the root directory of your project.
Cloning the full repository from GitLab is required for using the [native Calculator app](#calculator), running [tests](#tests), [profiling](#profiler), or generating [documentation](#docs).

### Installing and running
**For development and/or running the backend model alone (without a UI), or for REST API integration, go directly to the [Backend](#backend) section.**

This section provides instructions for setting up, running, and testing CAiMIRA in a local development environment. It covers the installation of the backend logic, interaction with user interfaces, and utilization of the API app. Additionally, instructions for legacy applications (expert apps), testing procedures, and tools for profiling and documentation generation are provided.
The repository can be cloned with the following command:

##### Prerequisites:
!!! note
The directory in which you run these commands will be the root directory of your project.

After following what is described in the main [prerequisites](#prerequisites) section, ensure the following dependencies are correctly installed:
```
git clone https://gitlab.cern.ch/caimira/caimira.git
```

1. **CAiMIRA repository**: Can be cloned from the official GitLab repository [here](https://gitlab.cern.ch/caimira/caimira).
2. **Python `3.9` or later**: Required for running the CAiMIRA backend and UI.
This ensures access to both the backend and the native UI, along with all tools and resources.

#### CAiMIRA
#### Calculator

CAiMIRA can be installed locally for development and usage in editable mode. This allows full access to both the backend logic, as well as the CAiMIRA-native UI. The following sections provide step-by-step instructions for installing and running CAiMIRA on a local environment.
The following sections provide step-by-step instructions for setting up and running the native CAiMIRA Calculator app and associated applications in a local development environment. It is designed for users seeking to develop new features, test existing functionalities, or explore the available tools.

##### Installing:
!!! info
The CAiMIRA Calculator integrates the backend functionality with a CAiMIRA-native UI, offering a complete webpage for modeling and interaction. Therefore, local installation of the two packages - [`caimira`](#installing-backend) and [`cern_caimira`](#installing-ui) - in editable mode is required, and are described in the following sections.

In order to install the CAiMIRA's backend logic, from the root directory of the project, run:
##### Installing backend

In order to install the CAiMIRA backend, from the root directory of the project, run:

cd caimira
pip install -e .

In order to install the CAiMIRA-native UI version, that links to the previously installed backend, from the root directory of the project, run:
##### Installing UI:

In order to install the CAiMIRA-native UI, that links to the previously installed backend, from the root directory of the project, run:

cd cern_caimira
pip install -e .

##### Running:

The calculator can be started with the CAiMIRA-native UI using the following command in the project root directory:
The calculator can be started with the CAiMIRA-native UI using the following command (directory independent):

python -m cern_caimira.apps.calculator

Expand All @@ -130,6 +133,10 @@ Additional options allow customization, such as specifying themes, application r

python -m cern_caimira.apps.calculator --theme=cern_caimira/src/cern_caimira/apps/templates/{theme}

Where `{theme}` is the name of the folder within the `cern_caimira/apps/templates/` directory. E.g. for the `cern` theme:

python -m cern_caimira.apps.calculator --theme=cern_caimira/src/cern_caimira/apps/templates/cern

- **Run the app with a different `APPLICATION_ROOT` path**:

The base path of the web application on the server. It determines where the app is "rooted" in relation to the server's URL structure. To run with a specific application root:
Expand All @@ -146,16 +153,18 @@ Each of these commands will start a local version of CAiMIRA, which can be visit

##### Expert-Apps:

The CAiMIRA Expert App and CO2 App are legacy tools designed to provide dynamic interaction with the CAiMIRA model parameters.
The CAiMIRA Expert App and CO<sub>2</sub> App are legacy tools designed to provide dynamic interaction with the CAiMIRA model parameters.

!!! warning

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

###### Running the Applications
These apps only work within Jupyter notebooks.

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

Attempting to run them outside of a Jupyter environment may result in errors or degraded functionality.

1. **Install dependencies**:

Expand All @@ -171,35 +180,6 @@ These applications only work within Jupyter notebooks. Attempting to run them ou

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

##### API app

CAiMIRA includes a REST API for programmatic interaction with its models. The following steps describe how to run and test the API locally.

1. **Run the backend API**:

python -m caimira.api.app

The Tornado server will be accessible on port `8081`.

2. **Test the API**:

Send a `POST` request to `http://localhost:8081/virus_report` with the required inputs in the body. Example request formats can be found in the [Virus Validator Code](https://gitlab.cern.ch/caimira/caimira/blob/master/caimira/src/caimira/calculator/validators/virus/virus_validator.py#L565).

3. **Example Response**:
A successful response will return data in the following format:

!!! success
{
"status": "success",
"message": "Results generated successfully",
"report_data": {
...
},
...
}

For further details please refer to the [REST API documentation page](../code/rest_api.md).

#### Tests

CAiMIRA includes a suite of tests to validate the functionality of both its backend (`caimira` package) and UI components (`cern_caimira` package).
Expand Down Expand Up @@ -265,6 +245,62 @@ CAiMIRA includes comprehensive documentation, which can be compiled and viewed l

The documentation can now be accessed at [http://0.0.0.0:8080/](http://0.0.0.0:8080/).

#### Backend

The CAiMIRA backend includes the logic underlying the [physics model](https://caimira-test.docs.cern.ch/root/physics_model/) and the REST API for programmatic interaction with the models. Local installation enables full access to these features, supporting development and testing.

##### Installing

CAiMIRA's backend logic can be installed with the following two options:

1. **From [PyPI](https://pypi.org/project/caimira/)**:

pip install caimira
2. **From the [GitLab Repository](https://gitlab.cern.ch/caimira/caimira)<sup>1</sup>**:

Clone the repository and install it in editable mode for development by running the following commands:

git clone https://gitlab.cern.ch/caimira/caimira.git
cd caimira

In the root directory:

cd caimira
pip install -e .

!!! note
<sup>1</sup>In case you haven't cloned the repository before.

##### Running and testing with API

CAiMIRA backend includes a REST API for programmatic interaction with its models. The following steps describe how to run and test the API locally.

1. **Run the backend API**:

python -m caimira.api.app

The Tornado server will be accessible at [http://localhost:8081/](http://localhost:8081/).

2. **Test the API**:

Send a `POST` request to `http://localhost:8081/virus_report` with the required inputs in the body. Example request formats can be found in the [Virus Validator Code](https://gitlab.cern.ch/caimira/caimira/blob/master/caimira/src/caimira/calculator/validators/virus/virus_validator.py#L565).

3. **Example Response**:
A successful response will return data in the following format:

!!! success
{
"status": "success",
"message": "Results generated successfully",
"report_data": {
...
},
...
}

For further details please refer to the [REST API documentation page](../code/rest_api.md).

### Setting up the full environment

This section outlines the steps to build and run the full CAiMIRA environment locally using Docker. It provides instructions for creating the necessary Docker images, configuring authentication, and running the application with Docker Compose.
Expand Down
3 changes: 0 additions & 3 deletions caimira/docs/sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
# -- Project information -----------------------------------------------------

project = 'CAiMIRA'
copyright = '2024, Andre Henriques et al.'
author = 'Andre Henriques et al.'

release = '1.0.0'

# -- General configuration ---------------------------------------------------

extensions = ['sphinx.ext.autodoc', 'sphinx_markdown_builder']
Expand Down
4 changes: 2 additions & 2 deletions caimira/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build-backend = "setuptools.build_meta"
name = "caimira"
version = "4.17.5"
description = "CAiMIRA - CERN Airborne Model for Indoor Risk Assessment"
readme = "README.md"
license = { text = "Apache-2.0" }
authors = [
{ name = "Andre Henriques", email = "[email protected]" }
Expand Down Expand Up @@ -41,7 +42,6 @@ test = [
"pytest-mypy >= 0.10.3",
"mypy >= 1.0.0",
"pytest-tornasync",
"numpy-stubs @ git+https://github.com/numpy/numpy-stubs.git",
"types-dataclasses",
"types-python-dateutil",
"types-requests",
Expand All @@ -56,7 +56,7 @@ doc = [
]

[project.urls]
Homepage = "https://github.com/cern/caimira"
Homepage = "https://gitlab.cern.ch/caimira/caimira"

[tool.setuptools.package-data]
caimira = ["**/*"]
Expand Down
2 changes: 1 addition & 1 deletion caimira/src/caimira/calculator/report/virus_report_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def calculate_report_data(form: VirusFormData, executor_factory: typing.Callable
def conditional_prob_inf_given_vl_dist(
infection_probability: models._VectorisedFloat,
viral_loads: np.ndarray,
specific_vl: float,
specific_vl: models._VectorisedFloat,
step: models._VectorisedFloat
):

Expand Down
Loading

0 comments on commit 778444a

Please sign in to comment.