Skip to content

Commit

Permalink
Merge pull request #29 from ecmwf/feature/rest-fastapi
Browse files Browse the repository at this point in the history
Feature/rest fastapi
  • Loading branch information
sametd authored Mar 14, 2024
2 parents efbbe46 + 99da591 commit 8c49e08
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 224 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/check-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ on:
jobs:
quality:
name: Code QA
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: pip install black flake8 isort
- run: black --version
- run: isort --check .
Expand All @@ -28,16 +28,16 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: ["ubuntu-20.04", "macos-13"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
platform: ["ubuntu-latest", "macos-13"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

name: Python ${{ matrix.python-version }} on ${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
needs: quality

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

Expand Down Expand Up @@ -75,18 +75,18 @@ jobs:
pip install -r docs/requirements.txt
- name: Tests on Ubuntu
if: matrix.platform == 'ubuntu-20.04'
run: |
pip freeze
pytest
if: runner.os == 'Linux'
env:
AVISO_DEBUG: True

- name: Tests on macOS
if: matrix.platform == 'macos-13'
run: |
pip freeze
pytest -v --cov=pyaviso --cache-clear
if: runner.os == 'macOS'
env:
AVISO_DEBUG: True

Expand All @@ -105,9 +105,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: "3.8"

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Code QA
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: pip install black flake8 isort
- run: black --version
- run: isort --check .
Expand All @@ -24,16 +24,16 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: ["ubuntu-20.04","macos-13"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
platform: ["ubuntu-latest","macos-13"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

name: Python ${{ matrix.python-version }} on ${{ matrix.platform }}
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v2
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

Expand Down
9 changes: 4 additions & 5 deletions aviso-server/rest/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# Aviso Rest

This component is a REST frontend that allows notification providers to submit notifications to the Aviso service
via REST. Internally it uses Aviso API as if it was a client towards the store.
via REST. Internally it uses Aviso API as if it is a client towards the notification store.

Install it by, from the main project directory:
Run the following commands in the main project directory to install aviso-rest:
```
% pip install -e .
% pip install -e aviso-server/monitoring
% pip install -e aviso-server/rest
```
The aviso and aviso-monitoring packages are required by aviso-rest.

Launch it by:
Aviso rest can be launched by:

```
% aviso-rest
```

```
2 changes: 1 addition & 1 deletion aviso-server/rest/aviso_rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import logging

# version number for the application.
__version__ = "0.4.0"
__version__ = "0.5.0"

# setting application logger
logger = logging.getLogger("aviso-rest")
Expand Down
16 changes: 1 addition & 15 deletions aviso-server/rest/aviso_rest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def __init__(
host=None,
port=None,
server_type=None,
workers=None,
aviso=None,
monitoring=None,
skips=None,
Expand Down Expand Up @@ -73,7 +72,6 @@ def __init__(
self.host = host
self.port = port
self.server_type = server_type
self.workers = workers
self.aviso = aviso
self.monitoring = monitoring
self.skips = skips
Expand All @@ -94,8 +92,7 @@ def _create_default_config() -> Dict:
config["debug"] = False
config["host"] = "127.0.0.1"
config["port"] = 8080
config["server_type"] = "flask"
config["workers"] = "1"
config["server_type"] = "uvicorn"
config["skips"] = {}
return config

Expand Down Expand Up @@ -159,8 +156,6 @@ def _read_env_variables(self) -> Dict[str, any]:
config["port"] = int(os.environ["AVISO_REST_PORT"])
if "AVISO_REST_SERVER_TYPE" in os.environ:
config["server_type"] = os.environ["AVISO_REST_SERVER_TYPE"]
if "AVISO_REST_WORKERS" in os.environ:
config["workers"] = int(os.environ["AVISO_REST_WORKERS"])
return config

def logging_setup(self, logging_conf_path: str):
Expand Down Expand Up @@ -250,14 +245,6 @@ def server_type(self):
def server_type(self, server_type: str):
self._server_type = self._configure_property(server_type, "server_type")

@property
def workers(self):
return self._workers

@workers.setter
def workers(self, workers: int):
self._workers = self._configure_property(workers, "workers")

@property
def debug(self) -> bool:
return self._debug
Expand Down Expand Up @@ -293,7 +280,6 @@ def __str__(self):
+ f", port: {self.port}"
+ f", server_type: {self.server_type}"
+ f", debug: {self.debug}"
+ f", workers: {self.workers}"
+ f", aviso: {self.aviso}"
+ f", monitoring: {self.monitoring}"
+ f", skips: {self.skips}"
Expand Down
Loading

0 comments on commit 8c49e08

Please sign in to comment.