Skip to content

AntaresSimulatorTeam/AntaREST

Folders and files

NameName
Last commit message
Last commit date
May 3, 2023
Aug 29, 2022
May 23, 2023
Jul 13, 2021
May 15, 2023
Apr 13, 2023
Feb 25, 2022
Mar 3, 2023
May 3, 2023
May 23, 2023
May 16, 2023
Jan 12, 2022
Apr 12, 2022
Apr 12, 2022
Apr 12, 2022
May 3, 2023
Mar 4, 2021
May 3, 2023
Jul 20, 2021
Jun 21, 2022
Jun 21, 2022
Apr 5, 2023
Mar 1, 2022
Oct 7, 2021
Mar 6, 2023
Dec 6, 2021
Mar 6, 2023
Apr 12, 2022
Mar 22, 2023
Mar 6, 2023
May 15, 2023
May 15, 2023

Repository files navigation

Antares Web

CI Coverage Licence

Screenshot

Documentation

The full project documentation can be found in the readthedocs website.

Build the API

First clone the projet:

git clone https://github.com/AntaresSimulatorTeam/AntaREST.git
cd AntaREST

Install back dependencies

python -m pip install --upgrade pip
pip install pydantic --no-binary pydantic
pip install -r requirements.txt  # use requirements-dev.txt if building a single binary with pyinstaller 

Build front

cd webapp
npm install
cd ..
NODE_OPTIONS="--max-old-space-size=8192" ./scripts/build-front.sh

Using pyinstaller

Linux system:

git log -1 HEAD --format=%H > ./resources/commit_id
pyinstaller -F antarest/main.py -n server --additional-hooks-dir extra-hooks --add-data resources:resources

Windows system:

git log -1 HEAD --format=%H > .\resources\commit_id
pyinstaller -F api_iso_antares\main.py -n server --additional-hooks-dir extra-hooks --add-data ".\resources;.\resources"

You can test the build is ok using:

dist/server -v       # Linux based system
dist\server.exe -v   # Windows system

Using docker

To build the docker image, use the following command:

docker build --tag antarest -f docker/Dockerfile .

Start the API

Using builded binary with pyinstaller

dist/server -s $STUDIES_ABSOLUTE_PATH         # Linux based system
dist\server.exe -s %STUDIES_ABSOLUTE_PATH%    # Windows system
  • $STUDIES_ABSOLUTE_PATH is the path of the ANTARES studies folders you wish to manipulate

Using docker image

docker run \
  -p 80:5000 \
  -e GUNICORN_WORKERS=4 \
  -v $STUDIES_ABSOLUTE_PATH:/studies \
  antarest
  • Setting the environment variable GUNICORN_WORKERS to ALL_AVAILABLE will make GUNICORN use 2 * nb_cpu +1 workers
  • $STUDIES_ABSOLUTE_PATH is the path of the ANTARES studies folders you wish to manipulate
    • If you do not mount /studies to a host path, the docker image will use the current path as the studies path
  • An exemple is available in this repo in the script folder

Using python directly

Using the dev wsgi server of Flask

pip install -r ./requirements.txt
export PYTHONPATH=$PYTHONPATH:.
python ./api_iso_antares/main.py -s $STUDIES_ABSOLUTE_PATH
  • $STUDIES_ABSOLUTE_PATH is the path of the ANTARES studies folders you wish to manipulate
  • An exemple is available in this repo in the script folder

Using gunicorn wsgi server

pip install -r ./requirements.txt
export PYTHONPATH=$PYTHONPATH:.

export ANTAREST_CONF=$ANTAREST_CONF_YAML_PATH
export GUNICORN_WORKERS=4

gunicorn --config "$YOUR_GUNICORN_CONFIG" antarest.wsgi:app
  • $YOUR_GUNICORN_CONFIG is the path of a gunicorn server configuration file
    • An example is available in this repo in the conf folder
  • Setting the environment variable GUNICORN_WORKERS to ALL_AVAILABLE will make GUNICORN use 2 * nb_cpu +1 workers
  • An exemple is available in this repo in the script folder

Examples

Once you started the server, you have access to the API. The address (the port mostly) depends of the way you started the server. If you start the server

To test the server, you can list the available studies in your workspace using:

curl http://localhost:8080/v1/studies

Or data of a specific study using:

curl http://localhost:8080/v1/studies/{study_uuid}

The current API handle hundreds of html end point (get and post) to manipulate your studies. The best way to discover the API is using it's swagger documentation (see below).

Swagger

The ANTARES API doc is available within the application (open your browser to http://localhost:8080) You can also fetch the raw open api spec :

curl http://localhost:8080/openapi.json > swagger.json