• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SwissDataScienceCenter / renku-data-services / 9952703261

16 Jul 2024 07:37AM UTC coverage: 90.328%. Remained the same
9952703261

push

github

web-flow
feat: move notebook service code (#301)

* style: fix code style and add tests

* refactor: increase encapsulation; minor bug fixes

* feat: spawn new server for different branch

* use Kubernetes api for notebook queries (#185)

* refactor: minor formatting and unnecessary code removal

* feat: include notebook username in pod labels

* refactor: minor

* feat: use k8s API to get user Jupyter servers

* refactor: remove ununsed code

* fix: minor fix in README.rst

* feat: return server data as needed by UI

Co-authored-by: rokroskar <rokroskar@gmail.com>

* build: make tests pass

* fix: apply review comments

* fix: uncaught exception when creating notebooks

* fix: use local and remote shortened commit-sha to recover from autosaves (#190)

* fix: use shortened commit-sha to check for an autosave match

* fix: use commit-sha of remote branch to create autosave branch name

* fix: avoid a None dereferencing

* fix: use both local and remote commit-sha for autosave

* feat: implement new notebook API

* feat: can force delete pods (#205)

* refactor: add more logs (#207)

* restore telepresence script (#209)

fix: update telepresence script and add vs code debugger

* feat: use project name in the notebook URL (#211)

* feat: handle k8s api errors when querying for logs (#216)

* feat: handle k8s api errors when querying for logs (#216)

* feat: update server_logs api (#225)

feat: return json data from server_logs and expose lines limit

fix #224

* chore: update werkzeug behavior (#242)

* feat: add requested resources info to servers endpoint (#261)

fix #223

* fix: use registry API to find image

closes #273

* feat: allow unprivileged an anonymous users to launch servers

- Enable the use of tmpauthenticator for Jupyterhub authentication.
  This enables notebook sessions for logged-out users. Closes #171

- Enable logged in users without write access to a project to st... (continued)

8863 of 9812 relevant lines covered (90.33%)

1.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.62
/components/renku_data_services/base_api/misc.py
1
"""Common blueprints."""
2✔
2

3
from collections.abc import Awaitable, Callable, Coroutine
2✔
4
from dataclasses import dataclass
2✔
5
from functools import wraps
2✔
6
from typing import Any, NoReturn, ParamSpec, TypeVar, cast
2✔
7

8
from sanic import Request, json
2✔
9
from sanic.response import JSONResponse
2✔
10

11
from renku_data_services import errors
2✔
12
from renku_data_services.base_api.blueprint import BlueprintFactoryResponse, CustomBlueprint
2✔
13

14

15
@dataclass(kw_only=True)
2✔
16
class MiscBP(CustomBlueprint):
2✔
17
    """Server contains all handlers for CRC and the configuration."""
2✔
18

19
    apispec: dict[str, Any]
2✔
20
    version: str
2✔
21

22
    def get_apispec(self) -> BlueprintFactoryResponse:
2✔
23
        """Servers the OpenAPI specification."""
24

25
        async def _get_apispec(_: Request) -> JSONResponse:
2✔
26
            return json(self.apispec)
1✔
27

28
        return "/spec.json", ["GET"], _get_apispec
2✔
29

30
    def get_error(self) -> BlueprintFactoryResponse:
2✔
31
        """Returns a sample error response."""
32

33
        async def _get_error(_: Request) -> NoReturn:
2✔
34
            raise errors.ValidationError(message="Sample validation error")
1✔
35

36
        return "/error", ["GET"], _get_error
2✔
37

38
    def get_version(self) -> BlueprintFactoryResponse:
2✔
39
        """Returns the version."""
40

41
        async def _get_version(_: Request) -> JSONResponse:
2✔
42
            return json({"version": self.version})
2✔
43

44
        return "/version", ["GET"], _get_version
2✔
45

46

47
_T = TypeVar("_T")
2✔
48
_P = ParamSpec("_P")
2✔
49

50

51
def validate_db_ids(f: Callable[_P, Awaitable[_T]]) -> Callable[_P, Coroutine[Any, Any, _T]]:
2✔
52
    """Decorator for a Sanic handler that errors out if passed in IDs are outside of the valid range for postgres."""
53

54
    @wraps(f)
2✔
55
    async def decorated_function(*args: _P.args, **kwargs: _P.kwargs) -> _T:
2✔
56
        resource_pool_id = cast(int | None, kwargs.get("resource_pool_id"))
2✔
57
        class_id = cast(int | None, kwargs.get("class_id"))
2✔
58
        min_val = 1  # postgres primary keys start at 1
2✔
59
        max_val = 2_147_483_647  # the max value for a default postgres primary key sequence
2✔
60
        if resource_pool_id and not min_val <= resource_pool_id <= max_val:
2✔
61
            raise errors.ValidationError(
1✔
62
                message=f"The provided resource pool ID is outside of the allowed range [{min_val}, {max_val}]"
63
            )
64
        if class_id and not min_val <= class_id <= max_val:
2✔
65
            raise errors.ValidationError(
×
66
                message=f"The provided resource class ID is outside of the allowed range [{min_val}, {max_val}]"
67
            )
68
        response = await f(*args, **kwargs)
2✔
69
        return response
2✔
70

71
    return decorated_function
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc