Skip to content

Commit 4506969

Browse files
♻️ clean up e2e testing (#128)
* update workflow before publishing python package * fix dependency issue and bump version * point to website in project description * fix broken dependency * improve doc * add github token to download artifacts * ensure only read-access @wvangeit * yet another attempt at downloading artifacts * make sure to use repo that ran the trigger wf * another attempt at fixing * change owner * allow publishing to testpypi also when pr * minor change * revert minor (but breaking) change * minor fix * add debug messages * another debug message * hopefully the final version * final fix * minor fix * move master and tag to individual jobs * add debug messages * dev->post * add python script for determining semantic version * minor changes * minor changes * improve error handling and add version file to artifacts * check if release * minor fix * ensure to enter venv * also when tagging * source venv in publishin workflow * ensure only master * add script for testing 'pure' semver * adapt workflows to new python script * minor change * attempt to evaluate expressions correctly * several fixes to fix tests * ensure repo is checked out in publish workflow * several small fixes * cleanup * debug * minor cleanup * mionr changes * add debug message * minor change * minor change * yet another try * minor change * minor change * minor change * mionr change * minor changes * correct workflow run id * cosmetic change * avoid using gh * change to a single job for publishing * minor cleanup * reorganize * several changes * dont install in edit mode * install in edit mode * several minor changes * clean up logging * dont use relative paths * ensure artifacts dir exists * minor change * make sure pandas gets all dependencies * correct pandas dependency * simplify client config * clean up client config * small correction * sevaral minor changes * minor fixes * corrections * add messages to debug * correction * minor correction * add osparc as a dependency * master -> latest_master * bugfix * cosmetic * cosmetic * create artifacts dir when creating pytest.ini * use jobs fcn to iterate over jobs * minor changes * add method for getting logdir * pip freeze * python 3.9 compatible * fix * generate log dir early * minor change * dont install e2e in test mode * ensure e2e is installed in editable mode * dont install in editable mode * install e2e in editable mode for pip freeze * delete job directly instead of stopping it first * clean up once for each server config * expose RequestError * split requirements into unit and 2e2 testing * fix dev.txt requirements * move dependencies to unit tests * _data_classes.py -> _models.py @pcrespov * config -> settings @pcrespov * read -> create_from_file @pcrespov * _warnings_and_errors.py -> _exceptions.py @pcrespov
1 parent 1ed574d commit 4506969

33 files changed

+607
-648
lines changed

.github/workflows/build-python-client.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
python -m pip install pytest
9090
python -m pip install clients/python/artifacts/dist/${{needs.build.outputs.osparc}} --find-links=clients/python/artifacts/dist
9191
cd clients/python
92-
make install-test
92+
make install-unit-test
9393
pytest -v --ignore=/artifacts/client --ignore=test/e2e
9494
9595
test-latest:
@@ -125,7 +125,7 @@ jobs:
125125
python -m pip install pytest
126126
python -m pip install clients/python/artifacts/dist/${{needs.build.outputs.osparc}} --find-links=clients/python/artifacts/dist
127127
cd clients/python
128-
make install-test
128+
make install-unit-test
129129
pytest -v --ignore=/artifacts/client --ignore=test/e2e
130130
131131
publish:

clients/python/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,13 @@ _check_venv_active:
106106
install-dev: _check_venv_active ## install packages for development
107107
pip install -r requirements/dev.txt
108108

109-
.PHONY: install-test
110-
install-test: _check_venv_active install-dev ## install packages for testing client
111-
pip install -r $(PYTHON_DIR)/requirements/test.txt
109+
.PHONY: install-unit-test
110+
install-unit-test: _check_venv_active ## install packages for unit testing client
111+
pip install -r $(PYTHON_DIR)/requirements/unit-test.txt
112+
113+
.PHONY: install-e2e-test
114+
install-e2e-test: _check_venv_active ## install packages for e2e testing client
115+
pip install -r $(PYTHON_DIR)/requirements/e2e-test.txt
112116

113117
.PHONY: install-doc
114118
install-doc: _check_venv_active install-dev ## install packages for generating documentation

clients/python/client/osparc/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
__version__,
3636
)
3737

38+
from ._exceptions import RequestError
3839
from ._files_api import FilesApi
3940
from ._info import openapi
4041
from ._solvers_api import SolversApi
@@ -88,4 +89,5 @@
8889
"SolverPort",
8990
"ErrorGet",
9091
"openapi",
92+
"RequestError",
9193
) # type: ignore
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from functools import wraps
2+
3+
from httpx import HTTPStatusError
4+
5+
6+
class VisibleDeprecationWarning(UserWarning):
7+
"""Visible deprecation warning.
8+
9+
Acknowledgement: Having this wrapper is borrowed from numpy
10+
"""
11+
12+
13+
class RequestError(Exception):
14+
"""For exceptions encountered when performing HTTP requests."""
15+
16+
17+
def handle_exceptions(func):
18+
@wraps(func)
19+
def wrapper(*args, **kwargs):
20+
try:
21+
return func(*args, **kwargs)
22+
except HTTPStatusError as e:
23+
raise RequestError(f"{e}") from e
24+
25+
return wrapper

clients/python/client/osparc/_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
Study,
1818
)
1919

20+
from ._exceptions import RequestError
21+
2022
_KB = 1024 # in bytes
2123
_MB = _KB * 1024 # in bytes
2224
_GB = _MB * 1024 # in bytes
@@ -61,8 +63,12 @@ def __iter__(self) -> Generator[T, None, None]:
6163
assert isinstance(page.total, int)
6264
yield from page.items
6365
if page.links.next is None:
64-
break
66+
return
6567
response: httpx.Response = self._client.get(page.links.next)
68+
try:
69+
response.raise_for_status()
70+
except httpx.HTTPStatusError as e:
71+
raise RequestError() from e
6672
page = self._api_client._ApiClient__deserialize(response.json(), type(page))
6773

6874

clients/python/client/osparc/_warnings_and_errors.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

clients/python/client/osparc/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from osparc_client.api import FilesApi, MetaApi, SolversApi, UsersApi
55

6-
from ._warnings_and_errors import VisibleDeprecationWarning
6+
from ._exceptions import VisibleDeprecationWarning
77

88
warning_msg: Final[str] = (
99
"osparc.api has been deprecated. Instead functionality within this module "

clients/python/client/osparc/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from osparc_client.models import RunningState as TaskStates
1818
from osparc_client.models import Solver, UserRoleEnum, UsersGroup, ValidationError
1919

20-
from ._warnings_and_errors import VisibleDeprecationWarning
20+
from ._exceptions import VisibleDeprecationWarning
2121

2222
warning_msg: Final[str] = (
2323
"osparc.models has been deprecated. Instead functionality within this module "
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
-r ../../../requirements.txt
2-
-r test.txt
2+
-r unit-test.txt
3+
-r e2e-test.txt
34
pylint

clients/python/requirements/test.txt renamed to clients/python/requirements/e2e-test.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,5 @@ pydantic
1212
pytest
1313
pytest-env
1414
pytest-html
15-
typer
1615
packaging
17-
pipdeptree
18-
pipreqs
16+
-e test/e2e/ci/e2e

0 commit comments

Comments
 (0)