Skip to content

Commit f9fb08e

Browse files
🐛 Add execution timeout to tutorial tests (#148)
* 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 * swap loops in clean up jobs * correction * update server compatibility to new url * minor change to trigger ci * 20min execution timeout for tutorial notebooks * small cleanup
1 parent 5301f53 commit f9fb08e

File tree

2 files changed

+38
-32
lines changed

2 files changed

+38
-32
lines changed
Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1-
from typing import List, Optional
1+
from typing import Any, List, Optional
22

33
import httpx
44
from osparc_client import OnePageSolverPort, SolverPort
55
from osparc_client import SolversApi as _SolversApi
66

77
from . import ApiClient
8-
from ._utils import PaginationGenerator, dev_features_enabled
8+
from ._utils import PaginationGenerator, dev_feature, dev_features_enabled
99

1010

1111
class SolversApi(_SolversApi):
1212
"""Class for interacting with solvers"""
1313

14+
_dev_features = [
15+
"get_jobs_page",
16+
]
17+
18+
def __getattribute__(self, name: str) -> Any:
19+
if (name in SolversApi._dev_features) and (not dev_features_enabled()):
20+
raise NotImplementedError(f"SolversApi.{name} is still under development")
21+
return super().__getattribute__(name)
22+
1423
def __init__(self, api_client: Optional[ApiClient] = None):
1524
"""Construct object
1625
@@ -33,36 +42,31 @@ def list_solver_ports(self, solver_key: str, version: str) -> List[SolverPort]:
3342
) # type: ignore
3443
return page.items if page.items else []
3544

36-
if dev_features_enabled():
37-
38-
def get_jobs_page(self, solver_key: str, version: str) -> None:
39-
"""Method only for internal use"""
40-
raise NotImplementedError("This method is only for internal use")
41-
42-
def jobs(self, solver_key: str, version: str) -> PaginationGenerator:
43-
"""Returns an iterator through which one can iterate over
44-
all Jobs submitted to the solver
45-
46-
Args:
47-
solver_key (str): The solver key
48-
version (str): The solver version
49-
limit (int, optional): the limit of a single page
50-
offset (int, optional): the offset of the first element to return
45+
@dev_feature
46+
def jobs(self, solver_key: str, version: str) -> PaginationGenerator:
47+
"""Returns an iterator through which one can iterate over
48+
all Jobs submitted to the solver
5149
52-
Returns:
53-
PaginationGenerator: A generator whose elements are the Jobs submitted
54-
to the solver and the total number of jobs the iterator can yield
55-
(its "length")
56-
"""
50+
Args:
51+
solver_key (str): The solver key
52+
version (str): The solver version
53+
limit (int, optional): the limit of a single page
54+
offset (int, optional): the offset of the first element to return
5755
58-
def pagination_method():
59-
return super(SolversApi, self).get_jobs_page(
60-
solver_key=solver_key, version=version, limit=20, offset=0
61-
)
56+
Returns:
57+
PaginationGenerator: A generator whose elements are the Jobs submitted
58+
to the solver and the total number of jobs the iterator can yield
59+
(its "length")
60+
"""
6261

63-
return PaginationGenerator(
64-
first_page_callback=pagination_method,
65-
api_client=self.api_client,
66-
base_url=self.api_client.configuration.host,
67-
auth=self._auth,
62+
def pagination_method():
63+
return super(SolversApi, self).get_jobs_page(
64+
solver_key=solver_key, version=version, limit=20, offset=0
6865
)
66+
67+
return PaginationGenerator(
68+
first_page_callback=pagination_method,
69+
api_client=self.api_client,
70+
base_url=self.api_client.configuration.host,
71+
auth=self._auth,
72+
)

clients/python/test/e2e/test_notebooks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import shutil
22
import sys
33
from pathlib import Path
4-
from typing import Any, Dict, List
4+
from typing import Any, Dict, Final, List
55

66
import osparc
77
import papermill as pm
88
import pytest
99
from packaging.version import Version
1010

11+
_NOTEBOOK_EXECUTION_TIMEOUT_SECONDS: Final[int] = 60 * 20 # 20min
1112
docs_dir: Path = Path(__file__).parent.parent.parent / "docs"
1213
all_notebooks: List[Path] = list(docs_dir.rglob("*.ipynb"))
1314
min_version_reqs: Dict[str, Version] = {
@@ -60,4 +61,5 @@ def test_run_notebooks(tmp_path: Path, notebook: Path, params: dict[str, Any] =
6061
output_path=output,
6162
kernel_name="python3",
6263
parameters=params,
64+
execution_timeout=_NOTEBOOK_EXECUTION_TIMEOUT_SECONDS,
6365
)

0 commit comments

Comments
 (0)