Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion renku/core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,11 @@ def __init__(self, reason: str):
super().__init__(f"Docker failed: {reason}")


class RenkulabSessionError(RenkuException):
class SessionStartError(RenkuException):
"""Raised when an error occurs trying to start sessions."""


class RenkulabSessionError(SessionStartError):
"""Raised when an error occurs trying to start sessions with the notebook service."""


Expand Down
7 changes: 7 additions & 0 deletions renku/core/session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ def session_start(

# set resource settings
cpu_limit = cpu_request or get_value("interactive", "cpu_request")

if cpu_limit is not None:
try:
cpu_limit = float(cpu_limit)
except ValueError:
raise errors.SessionStartError(f"Invalid value for cpu_request (must be float): {cpu_limit}")

disk_limit = disk_request or get_value("interactive", "disk_request")
mem_limit = mem_request or get_value("interactive", "mem_request")
gpu = gpu_request or get_value("interactive", "gpu_request")
Expand Down
18 changes: 18 additions & 0 deletions tests/cli/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,21 @@ def test_session_up_down(runner, project, dummy_session_provider, monkeypatch):
result = runner.invoke(cli, ["session", "ls", "-p", "dummy"])
assert 0 == result.exit_code, format_result_exception(result)
assert 2 == len(result.output.splitlines())


def test_session_start_config_requests(runner, project, dummy_session_provider, monkeypatch):
"""Test session with configuration in the renku config."""
import docker

result = runner.invoke(cli, ["config", "set", "interactive.cpu_request", "0.5"])
assert 0 == result.exit_code, format_result_exception(result)
result = runner.invoke(cli, ["config", "set", "interactive.disk_request", "100mb"])
assert 0 == result.exit_code, format_result_exception(result)
result = runner.invoke(cli, ["config", "set", "interactive.mem_request", "100mb"])
assert 0 == result.exit_code, format_result_exception(result)

with monkeypatch.context() as monkey:
monkey.setattr(docker, "from_env", MagicMock())
result = runner.invoke(cli, ["session", "start", "-p", "docker"])
assert 0 == result.exit_code, format_result_exception(result)
assert "successfully started" in result.output