Skip to content

Commit

Permalink
Merge pull request #1766 from yuvipanda/extra-args
Browse files Browse the repository at this point in the history
Add `BuildExecutor.repo2docker_extra_args` config
  • Loading branch information
consideRatio authored Oct 9, 2023
2 parents dfaf652 + 2deb3e8 commit 1b71389
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
13 changes: 12 additions & 1 deletion binderhub/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from kubernetes import client, watch
from tornado.ioloop import IOLoop
from tornado.log import app_log
from traitlets import Any, Bool, Dict, Integer, Unicode, default
from traitlets import Any, Bool, Dict, Integer, List, Unicode, default
from traitlets.config import LoggingConfigurable

from .utils import KUBE_REQUEST_TIMEOUT, ByteSpecification, rendezvous_rank
Expand Down Expand Up @@ -125,6 +125,15 @@ class BuildExecutor(LoggingConfigurable):
config=True,
)

repo2docker_extra_args = List(
Unicode,
default_value=[],
help="""
Extra commandline parameters to be passed to jupyter-repo2docker during build
""",
config=True,
)

def __init__(self, **kwargs):
super().__init__(**kwargs)
self.main_loop = IOLoop.current()
Expand Down Expand Up @@ -156,6 +165,8 @@ def get_r2d_cmd_options(self):
r2d_options.append("--build-memory-limit")
r2d_options.append(str(self.memory_limit))

r2d_options += self.repo2docker_extra_args

return r2d_options

def get_cmd(self):
Expand Down
20 changes: 19 additions & 1 deletion binderhub/tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from tornado.httputil import url_concat
from tornado.queues import Queue

from binderhub.build import KubernetesBuildExecutor, ProgressEvent
from binderhub.build import BuildExecutor, KubernetesBuildExecutor, ProgressEvent
from binderhub.build_local import LocalRepo2dockerBuild, ProcessTerminated, _execute_cmd

from .utils import async_requests
Expand Down Expand Up @@ -415,3 +415,21 @@ def break_callback():
lines.append(line)
assert lines == ["1\n"]
assert str(exc.value) == f"ProcessTerminated: {cmd}"


def test_extra_r2d_options():
bex = BuildExecutor()
bex.repo2docker_extra_args = ["--repo-dir=/srv/repo"]
bex.image_name = "test:test"
bex.ref = "main"

assert bex.get_r2d_cmd_options() == [
"--ref=main",
"--image=test:test",
"--no-clean",
"--no-run",
"--json-logs",
"--user-name=jovyan",
"--user-id=1000",
"--repo-dir=/srv/repo",
]

0 comments on commit 1b71389

Please sign in to comment.