Skip to content

Commit

Permalink
v2.15.0
Browse files Browse the repository at this point in the history
Release v2.15.0 to master
  • Loading branch information
laurent-laporte-pro authored Sep 30, 2023
2 parents 7503059 + bc89a86 commit d0cfb44
Show file tree
Hide file tree
Showing 271 changed files with 25,428 additions and 11,748 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: compatibility
on:
push:
branches:
- 'compatibility'
- "compatibility"

jobs:
python-test:
Expand All @@ -11,11 +11,11 @@ jobs:
max-parallel: 9
matrix:
os: [windows-latest, ubuntu-20.04, macOS-latest]
python-version: [ 3.8 ]
python-version: [3.8]

steps:
- name: Checkout github repo
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v1
with:
Expand All @@ -33,13 +33,13 @@ jobs:
strategy:
max-parallel: 9
matrix:
os: [ windows-latest, ubuntu-20.04, macOS-latest ]
node-version: [ 10.x, 14.x ]
os: [windows-latest, ubuntu-20.04, macOS-latest]
node-version: [18.16.1]
steps:
- name: Checkout github repo
uses: actions/checkout@v1
uses: actions/checkout@v3
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
Expand All @@ -48,7 +48,3 @@ jobs:
- name: Build
run: npm run build
working-directory: webapp
# - name: Run tests
# run: npm run test
# working-directory: webapp

8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: deploy
on:
push:
branches:
- 'master'
- 'hotfix/**'
- "master"
- "hotfix/**"

jobs:
binary:
Expand All @@ -27,10 +27,10 @@ jobs:
- name: 💚 Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '14.x'
node-version: 18.16.1

- name: 💚 Install dependencies
run: npm install
run: npm install --legacy-peer-deps
working-directory: webapp

- name: 💚 Build webapp
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: main
on:
push:
branches:
- '**'
- "**"

jobs:
python-lint:
runs-on: ubuntu-20.04
steps:
- name: Checkout github repo (+ download lfs dependencies)
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:

steps:
- name: Checkout github repo (+ download lfs dependencies)
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -72,13 +72,13 @@ jobs:
os: [ ubuntu-20.04 ]
steps:
- name: Checkout github repo
uses: actions/checkout@v1
uses: actions/checkout@v3
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.16.1
- name: Install dependencies
run: npm install
run: npm install --legacy-peer-deps
working-directory: webapp
- name: Build
run: npm run build
Expand All @@ -104,7 +104,7 @@ jobs:
runs-on: ubuntu-20.04
needs: [ python-test, npm-test ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Download python coverage report
uses: actions/download-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV ANTAREST_CONF /resources/application.yaml

RUN mkdir -p examples/studies

COPY ./requirements.txt /conf/
COPY ./requirements.txt ./conf/* /conf/
COPY ./antarest /antarest
COPY ./resources /resources
COPY ./scripts /scripts
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [2021] [RTE]
Copyright © 2007 - 2023 RTE

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
76 changes: 35 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,32 @@ git clone https://github.com/AntaresSimulatorTeam/AntaREST.git
cd AntaREST
```

Install back dependencies
Install back-end dependencies

```shell script
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
Install the front-end dependencies:

```shell script
cd webapp
npm install
cd ..
```

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


Expand All @@ -43,91 +54,74 @@ Linux system:

```shell script
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
pyinstaller AntaresWebLinux.spec
```

Windows system:

```shell script
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"
pyinstaller AntaresWebWin.spec
```

You can test the build is ok using:

```shell script
dist/server -v # Linux based system
dist\server.exe -v # Windows system
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:

```shell script
docker build --tag antarest -f docker/Dockerfile .
docker build --tag antarest .
```

## Start the API
## Run the API

### Using builded binary with pyinstaller
### Using binary built with pyinstaller

```shell script
dist/server -s $STUDIES_ABSOLUTE_PATH # Linux based system
dist\server.exe -s %STUDIES_ABSOLUTE_PATH% # Windows system
dist/AntaresWeb/AntaresWebServer -c </path/to/config.yaml> # Linux based system
dist\AntaresWeb\AntaresWebServer.exe -c </path/to/config.yaml> # Windows system
```

* $STUDIES_ABSOLUTE_PATH is the path of the ANTARES studies folders you wish to manipulate

### Using docker image

You may run the back-end with default configuration using the following command:
```shell script
docker run \
-p 80:5000 \
-e GUNICORN_WORKERS=4 \
-v $STUDIES_ABSOLUTE_PATH:/studies \
-e GUNICORN_WORKERS=1 \
antarest
```

* Setting the environment variable GUNICORN_WORKERS to *ALL_AVAILABLE* will make GUNICORN use 2 * nb_cpu +1 workers
* https://docs.gunicorn.org/en/stable/design.html#how-many-workers
* ALL_AVAILABLE is also the default value of GUNICORN_WORKERS if you do not set it
* $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
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](https://antares-web.readthedocs.io/en/latest)


### Using python directly

#### Using the dev wsgi server of Flask
#### Using uvicorn

```shell script
pip install -r ./requirements.txt
export PYTHONPATH=$PYTHONPATH:.
python ./api_iso_antares/main.py -s $STUDIES_ABSOLUTE_PATH
```
pip install -e .

* $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
python ./antarest/main.py -c resources/application.yaml
```

#### Using gunicorn wsgi server
#### Using gunicorn wsgi server with uvicorn workers

```shell script
pip install -r ./requirements.txt
export PYTHONPATH=$PYTHONPATH:.
pip install -e .

export ANTAREST_CONF=$ANTAREST_CONF_YAML_PATH
export ANTAREST_CONF=resources/application.yaml
export GUNICORN_WORKERS=4

gunicorn --config "$YOUR_GUNICORN_CONFIG" antarest.wsgi:app
gunicorn --config conf/gunicorn.py --worker-class=uvicorn.workers.UvicornWorker 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
* https://docs.gunicorn.org/en/stable/design.html#how-many-workers
* ALL_AVAILABLE is also the default value of GUNICORN_WORKERS if you do not set it
* An exemple is available in this repo in the *script* folder

## Examples

Once you started the server, you have access to the API.
Expand Down
4 changes: 2 additions & 2 deletions antarest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

# Standard project metadata

__version__ = "2.14.6"
__version__ = "2.15.0"
__author__ = "RTE, Antares Web Team"
__date__ = "2023-09-01"
__date__ = "2023-09-30"
# noinspection SpellCheckingInspection
__credits__ = "(c) Réseau de Transport de l’Électricité (RTE)"

Expand Down
45 changes: 42 additions & 3 deletions antarest/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,39 @@ class ShouldNotHappenException(Exception):
pass


class STStorageFieldsNotFoundError(HTTPException):
"""Fields of the short-term storage are not found"""

def __init__(self, storage_id: str) -> None:
detail = f"Fields of storage '{storage_id}' not found"
super().__init__(HTTPStatus.NOT_FOUND, detail)

def __str__(self) -> str:
return self.detail


class STStorageMatrixNotFoundError(HTTPException):
"""Matrix of the short-term storage is not found"""

def __init__(self, study_id: str, area_id: str, storage_id: str, ts_name: str) -> None:
detail = f"Time series '{ts_name}' of storage '{storage_id}' not found"
super().__init__(HTTPStatus.NOT_FOUND, detail)

def __str__(self) -> str:
return self.detail


class STStorageConfigNotFoundError(HTTPException):
"""Configuration for short-term storage is not found"""

def __init__(self, study_id: str, area_id: str) -> None:
detail = f"The short-term storage configuration of area '{area_id}' not found:"
super().__init__(HTTPStatus.NOT_FOUND, detail)

def __str__(self) -> str:
return self.detail


class UnknownModuleError(Exception):
def __init__(self, message: str) -> None:
super(UnknownModuleError, self).__init__(message)
Expand Down Expand Up @@ -163,12 +196,18 @@ def __init__(self, message: str) -> None:

class LayerNotFound(HTTPException):
def __init__(self) -> None:
super().__init__(HTTPStatus.NOT_FOUND)
super().__init__(
HTTPStatus.NOT_FOUND,
"Layer not found",
)


class LayerNotAllowedToBeDeleted(HTTPException):
def __init__(self) -> None:
super().__init__(HTTPStatus.EXPECTATION_FAILED)
def __init__(self, layer_name: str = "All") -> None:
super().__init__(
HTTPStatus.BAD_REQUEST,
f"You cannot delete the layer: '{layer_name}'",
)


class StudyOutputNotFoundError(Exception):
Expand Down
4 changes: 2 additions & 2 deletions antarest/core/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from alembic import command
from alembic.config import Config
from alembic.util import CommandError
from sqlalchemy.ext.declarative import declarative_base # type: ignore
from sqlalchemy.orm import declarative_base # type: ignore

from antarest.core.utils.utils import get_local_path

Expand Down Expand Up @@ -38,4 +38,4 @@ def upgrade_db(config_file: Path) -> None:
if current_version != head:
logger.info(f"Upgrading database from {current_version} to {head}")
command.upgrade(alembic_cfg, head)
logger.info(f"Database up to date")
logger.info("Database up to date")
4 changes: 2 additions & 2 deletions antarest/core/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def get_user_id(self) -> str:


class UserHasNotPermissionError(HTTPException):
def __init__(self) -> None:
super().__init__(status_code=403, detail="Permission denied")
def __init__(self, msg: str = "Permission denied") -> None:
super().__init__(status_code=403, detail=msg)


class MustBeAuthenticatedError(HTTPException):
Expand Down
Loading

0 comments on commit d0cfb44

Please sign in to comment.