Skip to content

AntaresSimulatorTeam/AntaREST

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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-end dependencies

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

Install the front-end dependencies:

cd webapp
npm install
cd ..

Then build the front-end application:

  • for use with pyinstaller:
NODE_OPTIONS="--max-old-space-size=8192" ./scripts/build-front.sh
  • for other uses (docker deployement, ...):
cd webapp
npm run build
cd ..

Using pyinstaller

Linux system:

git log -1 HEAD --format=%H > ./resources/commit_id
pyinstaller AntaresWebLinux.spec

Windows system:

git log -1 HEAD --format=%H > .\resources\commit_id
pyinstaller AntaresWebWin.spec

You can test the build is ok using:

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

Using docker

To build the docker image, use the following command:

docker build --tag antarest .

Run the API

Using binary built with pyinstaller

dist/AntaresWeb/AntaresWebServer -c </path/to/config.yaml>  # Linux based system
dist\AntaresWeb\AntaresWebServer.exe -c </path/to/config.yaml>    # Windows system

Using docker image

You may run the back-end with default configuration using the following command:

docker run \
  -p 80:5000 \
  -e GUNICORN_WORKERS=1 \
  antarest

However, for a complete deployment including the front-end application, and the use of an external database and an external REDIS instance, please refer to the deployement instructions on readthedocs website

Using python directly

Using uvicorn

pip install -e .

python ./antarest/main.py -c resources/application.yaml

Using gunicorn wsgi server with uvicorn workers

pip install -e .

export ANTAREST_CONF=resources/application.yaml
export GUNICORN_WORKERS=4
gunicorn --config conf/gunicorn.py --worker-class=uvicorn.workers.UvicornWorker antarest.wsgi:app

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