Skip to content

Commit a15a315

Browse files
committed
Copy binderspawner_mixin.py code to values.yaml
1 parent 02bebb3 commit a15a315

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

helm-chart/binderhub/values.yaml

+24-23
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ jupyterhub:
8181
- Duplicate the code here and in binderhub/binderspawner_mixin.py
8282
"""
8383
from tornado import web
84+
from traitlets import Bool
85+
from traitlets import Unicode
8486
from traitlets.config import Configurable
85-
from traitlets import Bool, Unicode
8687
8788
8889
class BinderSpawnerMixin(Configurable):
@@ -100,7 +101,7 @@ jupyterhub:
100101
# classes using traitlets?
101102
# https://stackoverflow.com/questions/9575409/calling-parent-class-init-with-multiple-inheritance-whats-the-right-way
102103
# https://github.com/ipython/traitlets/pull/175
103-
super(BinderSpawnerMixin, self).__init__(*args, **kwargs)
104+
super().__init__(*args, **kwargs)
104105
105106
auth_enabled = Bool(
106107
False,
@@ -110,7 +111,7 @@ jupyterhub:
110111
Requires `jupyterhub-singleuser` to be available inside the repositories
111112
being built.
112113
""",
113-
config=True
114+
config=True,
114115
)
115116
116117
cors_allow_origin = Unicode(
@@ -125,55 +126,55 @@ jupyterhub:
125126
See also BinderHub.cors_allow_origin in binderhub config
126127
for controlling CORS policy for the BinderHub API endpoint.
127128
""",
128-
config=True
129+
config=True,
129130
)
130131
131132
def get_args(self):
132133
if self.auth_enabled:
133134
args = super().get_args()
134135
else:
135136
args = [
136-
'--ip=0.0.0.0',
137-
f'--port={self.port}',
138-
f'--NotebookApp.base_url={self.server.base_url}',
137+
"--ip=0.0.0.0",
138+
f"--port={self.port}",
139+
f"--NotebookApp.base_url={self.server.base_url}",
139140
f"--NotebookApp.token={self.user_options['token']}",
140-
'--NotebookApp.trust_xheaders=True',
141+
"--NotebookApp.trust_xheaders=True",
141142
]
142143
if self.default_url:
143-
args.append(f'--NotebookApp.default_url={self.default_url}')
144+
args.append(f"--NotebookApp.default_url={self.default_url}")
144145
145146
if self.cors_allow_origin:
146-
args.append('--NotebookApp.allow_origin=' + self.cors_allow_origin)
147+
args.append("--NotebookApp.allow_origin=" + self.cors_allow_origin)
147148
# allow_origin=* doesn't properly allow cross-origin requests to single files
148149
# see https://github.com/jupyter/notebook/pull/5898
149-
if self.cors_allow_origin == '*':
150-
args.append('--NotebookApp.allow_origin_pat=.*')
150+
if self.cors_allow_origin == "*":
151+
args.append("--NotebookApp.allow_origin_pat=.*")
151152
args += self.args
152153
return args
153154
154155
def start(self):
155156
if not self.auth_enabled:
156-
if 'token' not in self.user_options:
157+
if "token" not in self.user_options:
157158
raise web.HTTPError(400, "token required")
158-
if 'image' not in self.user_options:
159+
if "image" not in self.user_options:
159160
raise web.HTTPError(400, "image required")
160-
if 'image' in self.user_options:
161-
self.image = self.user_options['image']
161+
if "image" in self.user_options:
162+
self.image = self.user_options["image"]
162163
return super().start()
163164
164165
def get_env(self):
165166
env = super().get_env()
166-
if 'repo_url' in self.user_options:
167-
env['BINDER_REPO_URL'] = self.user_options['repo_url']
167+
if "repo_url" in self.user_options:
168+
env["BINDER_REPO_URL"] = self.user_options["repo_url"]
168169
for key in (
169-
'binder_ref_url',
170-
'binder_launch_host',
171-
'binder_persistent_request',
172-
'binder_request'):
170+
"binder_ref_url",
171+
"binder_launch_host",
172+
"binder_persistent_request",
173+
"binder_request",
174+
):
173175
if key in self.user_options:
174176
env[key.upper()] = self.user_options[key]
175177
return env
176-
177178
00-binder: |
178179
# image & token are set via spawn options
179180
from kubespawner import KubeSpawner

0 commit comments

Comments
 (0)