Skip to content

Commit 3f5d881

Browse files
add base common library
1 parent 968b5ab commit 3f5d881

File tree

19 files changed

+371
-6
lines changed

19 files changed

+371
-6
lines changed

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
aws-library: ${{ steps.filter.outputs.aws-library }}
5555
dask-task-models-library: ${{ steps.filter.outputs.dask-task-models-library }}
5656
models-library: ${{ steps.filter.outputs.models-library }}
57+
common-library: ${{ steps.filter.outputs.common-library }}
5758
notifications-library: ${{ steps.filter.outputs.notifications-library }}
5859
postgres-database: ${{ steps.filter.outputs.postgres-database }}
5960
service-integration: ${{ steps.filter.outputs.service-integration }}
@@ -110,6 +111,8 @@ jobs:
110111
- 'services/docker-compose*'
111112
- 'scripts/mypy/*'
112113
- 'mypy.ini'
114+
common-library:
115+
- 'packages/common-library/**'
113116
notifications-library:
114117
- 'packages/notifications-library/**'
115118
- 'packages/postgres-database/**'
@@ -1593,6 +1596,47 @@ jobs:
15931596
with:
15941597
flags: unittests #optional
15951598

1599+
unit-test-common-library:
1600+
needs: changes
1601+
if: ${{ needs.changes.outputs.common-library == 'true' || github.event_name == 'push' }}
1602+
timeout-minutes: 18 # if this timeout gets too small, then split the tests
1603+
name: "[unit] common-library"
1604+
runs-on: ${{ matrix.os }}
1605+
strategy:
1606+
matrix:
1607+
python: ["3.11"]
1608+
os: [ubuntu-22.04]
1609+
fail-fast: false
1610+
steps:
1611+
- uses: actions/checkout@v4
1612+
- name: setup docker buildx
1613+
id: buildx
1614+
uses: docker/setup-buildx-action@v3
1615+
with:
1616+
driver: docker-container
1617+
- name: setup python environment
1618+
uses: actions/setup-python@v5
1619+
with:
1620+
python-version: ${{ matrix.python }}
1621+
- name: install uv
1622+
uses: yezz123/setup-uv@v4
1623+
- uses: actions/cache@v4
1624+
id: cache-uv
1625+
with:
1626+
path: ~/.cache/uv
1627+
key: ${{ runner.os }}-${{ github.job }}-python-${{ matrix.python }}-uv
1628+
- name: show system version
1629+
run: ./ci/helpers/show_system_versions.bash
1630+
- name: install
1631+
run: ./ci/github/unit-testing/common-library.bash install
1632+
- name: typecheck
1633+
run: ./ci/github/unit-testing/common-library.bash typecheck
1634+
- name: test
1635+
run: ./ci/github/unit-testing/common-library.bash test
1636+
- uses: codecov/[email protected]
1637+
with:
1638+
flags: unittests #optional
1639+
15961640
unit-test-notifications-library:
15971641
needs: changes
15981642
if: ${{ needs.changes.outputs.notifications-library == 'true' || github.event_name == 'push' }}
@@ -1704,6 +1748,7 @@ jobs:
17041748
unit-test-efs-guardian,
17051749
unit-test-frontend,
17061750
unit-test-models-library,
1751+
unit-test-common-library,
17071752
unit-test-notifications-library,
17081753
unit-test-osparc-gateway-server,
17091754
unit-test-payments,
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
make devenv
10+
# shellcheck source=/dev/null
11+
source .venv/bin/activate
12+
pushd packages/common-library
13+
make install-ci
14+
popd
15+
uv pip list
16+
}
17+
18+
test() {
19+
# shellcheck source=/dev/null
20+
source .venv/bin/activate
21+
pushd packages/common-library
22+
make tests-ci
23+
popd
24+
}
25+
26+
typecheck() {
27+
# shellcheck source=/dev/null
28+
source .venv/bin/activate
29+
uv pip install mypy
30+
pushd packages/common-library
31+
make mypy
32+
popd
33+
}
34+
35+
# Check if the function exists (bash specific)
36+
if declare -f "$1" >/dev/null; then
37+
# call arguments verbatim
38+
"$@"
39+
else
40+
# Show a helpful error
41+
echo "'$1' is not a known function name" >&2
42+
exit 1
43+
fi

packages/common-library/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
# simcore pydantic common library
1+
# simcore pydantic models library
2+
3+
Contains the [pydantic](https://pydantic-docs.helpmanual.io/)-based models for use in the simcore platform. As a reminder pydantic allows creation of python classes that automatically validate their contents based on types. It also provides mechanism to generate json schemas describing the classes internals.
4+
5+
Requirements to be compatible with the library:
6+
7+
- be a pydantic-based model
8+
- not a model for use in a REST API (or at least not directly) only for a specific service (ServiceUpdate model for use in a PATCH REST call on the webserver has nothing to do in the library for example, but a base class for it is ok)
29

310
## Installation
411

@@ -24,7 +31,7 @@ How run diagnostics on the service metadata published in a docker registry?
2431
make devenv
2532
source .venv/bin/activate
2633

27-
cd packages/common-library
34+
cd packages/models-library
2835
make install-dev
2936
```
3037
2. Set ``REGISTRY_*`` env vars in ``.env`` (in the repository base folder)

packages/common-library/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.0
1+
0.2.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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# Specifies third-party dependencies for 'models-library'
3+
#
4+
--constraint ../../../requirements/constraints.txt
5+
6+
pydantic
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
annotated-types==0.7.0
2+
# via pydantic
3+
pydantic==2.9.2
4+
# via
5+
# -c requirements/../../../requirements/constraints.txt
6+
# -r requirements/_base.in
7+
pydantic-core==2.23.4
8+
# via pydantic
9+
typing-extensions==4.12.2
10+
# via
11+
# pydantic
12+
# pydantic-core
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Specifies dependencies required to run 'models-library'
3+
#
4+
--constraint ../../../requirements/constraints.txt
5+
6+
# Adds base AS CONSTRAINT specs, not requirement.
7+
# - Resulting _text.txt is a frozen list of EXTRA packages for testing, besides _base.txt
8+
#
9+
--constraint _base.txt
10+
11+
coverage
12+
faker
13+
pytest
14+
pytest-asyncio
15+
pytest-cov
16+
pytest-icdiff
17+
pytest-instafail
18+
pytest-mock
19+
pytest-runner
20+
pytest-sugar
21+
python-dotenv
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
coverage==7.6.1
2+
# via
3+
# -r requirements/_test.in
4+
# pytest-cov
5+
faker==30.1.0
6+
# via -r requirements/_test.in
7+
icdiff==2.0.7
8+
# via pytest-icdiff
9+
iniconfig==2.0.0
10+
# via pytest
11+
packaging==24.1
12+
# via
13+
# pytest
14+
# pytest-sugar
15+
pluggy==1.5.0
16+
# via pytest
17+
pprintpp==0.4.0
18+
# via pytest-icdiff
19+
pytest==8.3.3
20+
# via
21+
# -r requirements/_test.in
22+
# pytest-asyncio
23+
# pytest-cov
24+
# pytest-icdiff
25+
# pytest-instafail
26+
# pytest-mock
27+
# pytest-sugar
28+
pytest-asyncio==0.23.8
29+
# via
30+
# -c requirements/../../../requirements/constraints.txt
31+
# -r requirements/_test.in
32+
pytest-cov==5.0.0
33+
# via -r requirements/_test.in
34+
pytest-icdiff==0.9
35+
# via -r requirements/_test.in
36+
pytest-instafail==0.5.0
37+
# via -r requirements/_test.in
38+
pytest-mock==3.14.0
39+
# via -r requirements/_test.in
40+
pytest-runner==6.0.1
41+
# via -r requirements/_test.in
42+
pytest-sugar==1.0.0
43+
# via -r requirements/_test.in
44+
python-dateutil==2.9.0.post0
45+
# via faker
46+
python-dotenv==1.0.1
47+
# via -r requirements/_test.in
48+
six==1.16.0
49+
# via python-dateutil
50+
termcolor==2.5.0
51+
# via pytest-sugar
52+
typing-extensions==4.12.2
53+
# via
54+
# -c requirements/_base.txt
55+
# faker
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--constraint ../../../requirements/constraints.txt
2+
--constraint _base.txt
3+
--constraint _test.txt
4+
5+
--requirement ../../../requirements/devenv.txt

0 commit comments

Comments
 (0)