Skip to content

Commit

Permalink
Merge pull request #286 from opensafely-core/add-preflight-checks-rst…
Browse files Browse the repository at this point in the history
…udio-jupyter

Add Docker preflight check to opensafely jupyter and rstudio subcommands
  • Loading branch information
remlapmot authored Oct 28, 2024
2 parents 907413e + d840e75 commit 21c2a60
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions opensafely/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path

from opensafely import utils
from opensafely._vendor.jobrunner.cli.local_run import docker_preflight_check


DESCRIPTION = "Run a jupyter lab notebook using the OpenSAFELY environment"
Expand Down Expand Up @@ -86,6 +87,9 @@ def read_metadata_and_open(name, port):


def main(directory, name, port, no_browser, jupyter_args):
if not docker_preflight_check():
return False

if name is None:
name = f"os-jupyter-{directory.name}"

Expand Down
4 changes: 4 additions & 0 deletions opensafely/rstudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from sys import platform

from opensafely import utils
from opensafely._vendor.jobrunner.cli.local_run import docker_preflight_check


DESCRIPTION = "Run an RStudio Server session using the OpenSAFELY environment"
Expand All @@ -29,6 +30,9 @@ def add_arguments(parser):


def main(directory, name, port):
if not docker_preflight_check():
return False

if name is None:
name = f"os-rstudio-{directory.name}"

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ omit = [
]

[tool.coverage.report]
fail_under = 88
fail_under = 87
skip_covered = true
show_missing = true

Expand Down
2 changes: 2 additions & 0 deletions tests/test_jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def test_jupyter(run, no_user, monkeypatch):
# these calls are done in different threads, so can come in any order
run.concurrent = True

run.expect(["docker", "info"])

run.expect(
[
"docker",
Expand Down
2 changes: 2 additions & 0 deletions tests/test_rstudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def test_rstudio(run, tmp_path, monkeypatch, gitconfig_exists):
else:
uid = None

run.expect(["docker", "info"])

run.expect(["docker", "image", "inspect", "ghcr.io/opensafely-core/rstudio:latest"])

expected = [
Expand Down

0 comments on commit 21c2a60

Please sign in to comment.