Skip to content

Commit 663fd9b

Browse files
authored
🔨 New settings-library for settings (ITISFoundation#2395)
* NEW packages/settings-library package for settings : implements new settings designed drafted in sample-app-settings repo. * ADDS new fixtures pytest_simcore.cli_runner * UPDATED storage service: replaces model_library.settings by settings_library
1 parent aad00a6 commit 663fd9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1419
-199
lines changed

‎.github/CODEOWNERS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Makefile @pcrespov, @sanderegg
1717
/packages/pytest-simcore/ @pcrespov, @sanderegg
1818
/packages/service-integration/ @pcrespov, @sanderegg, @KZzizzle
1919
/packages/service-library/ @pcrespov
20+
/packages/settings-library/ @pcrespov, @sanderegg
2021
/requirements/ @pcrespov
2122
/scripts/demo/ @odeimaiz, @pcrespov
2223
/scripts/json-schema-to-openapi-schema @sanderegg

‎.github/workflows/ci-testing-deploy.yml‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,53 @@ jobs:
614614
name: codeclimate-${{ github.job }}-coverage
615615
path: codeclimate.${{ github.job }}_coverage.json
616616

617+
unit-test-settings-library:
618+
name: "[unit] settings-library"
619+
runs-on: ${{ matrix.os }}
620+
strategy:
621+
matrix:
622+
python: [3.8]
623+
os: [ubuntu-20.04]
624+
fail-fast: false
625+
steps:
626+
- uses: actions/checkout@v2
627+
- name: setup docker
628+
run: |
629+
sudo ./ci/github/helpers/setup_docker_compose.bash
630+
./ci/github/helpers/setup_docker_experimental.bash
631+
- name: setup python environment
632+
uses: actions/setup-python@v2
633+
with:
634+
python-version: ${{ matrix.python }}
635+
- name: show system version
636+
run: ./ci/helpers/show_system_versions.bash
637+
- uses: actions/cache@v2
638+
name: getting cached data
639+
with:
640+
path: ~/.cache/pip
641+
key: ${{ runner.os }}-pip-settings-library-${{ hashFiles('packages/settings-library/requirements/ci.txt') }}
642+
restore-keys: |
643+
${{ runner.os }}-pip-settings-library-
644+
${{ runner.os }}-pip-
645+
${{ runner.os }}-
646+
- name: install
647+
run: ./ci/github/unit-testing/settings-library.bash install
648+
- name: test
649+
run: ./ci/github/unit-testing/settings-library.bash test
650+
- uses: codecov/codecov-action@v1
651+
with:
652+
flags: unittests #optional
653+
- name: prepare codeclimate coverage file
654+
run: |
655+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-0.7.0-linux-amd64 > ./cc-test-reporter
656+
chmod +x ./cc-test-reporter && ./cc-test-reporter --version
657+
./cc-test-reporter format-coverage -t coverage.py -o codeclimate.${{ github.job }}_coverage.json coverage.xml
658+
- name: upload codeclimate coverage
659+
uses: actions/upload-artifact@v2
660+
with:
661+
name: codeclimate-${{ github.job }}-coverage
662+
path: codeclimate.${{ github.job }}_coverage.json
663+
617664
unit-test-models-library:
618665
name: "[unit] models-library"
619666
runs-on: ${{ matrix.os }}
@@ -1853,6 +1900,7 @@ jobs:
18531900
unit-test-dask-sidecar,
18541901
unit-test-service-integration,
18551902
unit-test-service-library,
1903+
unit-test-settings-library,
18561904
unit-test-models-library,
18571905
unit-test-simcore-sdk,
18581906
unit-test-storage,
@@ -1911,6 +1959,7 @@ jobs:
19111959
unit-test-python-linting,
19121960
unit-test-service-integration,
19131961
unit-test-service-library,
1962+
unit-test-settings-library,
19141963
unit-test-models-library,
19151964
unit-test-simcore-sdk,
19161965
unit-test-storage,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
3+
set -o errexit # abort on nonzero exitstatus
4+
set -o nounset # abort on unbound variable
5+
set -o pipefail # don't hide errors within pipes
6+
IFS=$'\n\t'
7+
8+
install() {
9+
bash ci/helpers/ensure_python_pip.bash
10+
pushd packages/settings-library; pip3 install -r requirements/ci.txt; popd;
11+
pip list -v
12+
}
13+
14+
test() {
15+
pytest --cov=settings_library --durations=10 --cov-append \
16+
--color=yes --cov-report=term-missing --cov-report=xml --cov-config=.coveragerc \
17+
-v packages/settings-library/tests
18+
}
19+
20+
# Check if the function exists (bash specific)
21+
if declare -f "$1" > /dev/null
22+
then
23+
# call arguments verbatim
24+
"$@"
25+
else
26+
# Show a helpful error
27+
echo "'$1' is not a known function name" >&2
28+
exit 1
29+
fi
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# pylint: disable=redefined-outer-name
2+
#
3+
# Fixture to test Typer applications
4+
#
5+
# SEE https://typer.tiangolo.com/tutorial/testing/#testing-input
6+
# Based on https://github.com/Stranger6667/pytest-click
7+
8+
9+
from typing import Iterator
10+
11+
import pytest
12+
from typer.testing import CliRunner
13+
14+
15+
@pytest.fixture
16+
def cli_runner() -> CliRunner:
17+
"""Instance of `typer.testing.CliRunner`"""
18+
return CliRunner()
19+
20+
21+
@pytest.fixture
22+
def isolated_cli_runner(cli_runner: CliRunner) -> Iterator[CliRunner]:
23+
"""Instance of `typer.testing.CliRunner` running under a temporary working directory for isolated filesystem tests."""
24+
with cli_runner.isolated_filesystem():
25+
yield cli_runner
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# Targets for DEVELOPMENT of models Library
3+
#
4+
include ../../scripts/common.Makefile
5+
include ../../scripts/common-package.Makefile
6+
7+
.PHONY: requirements
8+
requirements: ## compiles pip requirements (.in -> .txt)
9+
@$(MAKE_C) requirements reqs
10+
11+
12+
.PHONY: install-dev install-prod install-ci
13+
install-dev install-prod install-ci: _check_venv_active ## install app in development/production or CI mode
14+
# installing in $(subst install-,,$@) mode
15+
pip-sync requirements/$(subst install-,,$@).txt
16+
17+
18+
.PHONY: tests
19+
tests: ## runs unit tests
20+
# running unit tests
21+
@pytest -vv --color=yes --exitfirst --failed-first --durations=10 \
22+
--cov-config=../../.coveragerc --cov=settings_library --cov-report=term-missing \
23+
--pdb $(CURDIR)/tests
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# simcore settings library
2+
3+
Contains [pydantic](https://pydantic-docs.helpmanual.io/usage/settings/)-based
4+
common settings used for app configs
5+
6+
SEE concept in https://github.com/pcrespov/sample-app-settings
7+
8+
## Installation
9+
10+
```console
11+
make help
12+
make install-dev
13+
```
14+
15+
## Test
16+
17+
```console
18+
make help
19+
make test-dev
20+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# Targets to pip-compile requirements
3+
#
4+
include ../../../requirements/base.Makefile
5+
6+
# Add here any extra explicit dependency: e.g. _migration.txt: _base.txt
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Specifies third-party dependencies for 'models-library'
3+
#
4+
-c ../../../requirements/constraints.txt
5+
6+
pydantic
7+
8+
9+
# extra
10+
typer
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# This file is autogenerated by pip-compile with python 3.8
3+
# To update, run:
4+
#
5+
# pip-compile --output-file=requirements/_base.txt requirements/_base.in
6+
#
7+
click==7.1.2
8+
# via typer
9+
pydantic==1.8.2
10+
# via
11+
# -c requirements/../../../requirements/constraints.txt
12+
# -r requirements/_base.in
13+
typer==0.3.2
14+
# via -r requirements/_base.in
15+
typing-extensions==3.10.0.0
16+
# via pydantic

0 commit comments

Comments
 (0)