Switch assemble_scripts to use methods instead of traitlets

pull/206/head
yuvipanda 2018-02-01 01:43:14 -08:00
rodzic 42eb8e573c
commit 28bccecfff
4 zmienionych plików z 9 dodań i 15 usunięć

Wyświetl plik

@ -222,9 +222,8 @@ class BuildPack(LoggingConfigurable):
""" """
return [] return []
assemble_scripts = List( def get_assemble_scripts(self):
[], """
help="""
Ordered list of shell script snippets to build the repo into the image. Ordered list of shell script snippets to build the repo into the image.
A list of tuples, where the first item is a username & the A list of tuples, where the first item is a username & the
@ -247,7 +246,7 @@ class BuildPack(LoggingConfigurable):
You can use environment variable substitutions in both the You can use environment variable substitutions in both the
username and the execution script. username and the execution script.
""" """
) return []
post_build_scripts = List( post_build_scripts = List(
[], [],
@ -295,9 +294,8 @@ class BuildPack(LoggingConfigurable):
result.get_labels = lambda: _merge_dicts(self.get_labels(), other.get_labels()) result.get_labels = lambda: _merge_dicts(self.get_labels(), other.get_labels())
result.get_build_script_files = lambda: _merge_dicts(self.get_build_script_files(), other.get_build_script_files()) result.get_build_script_files = lambda: _merge_dicts(self.get_build_script_files(), other.get_build_script_files())
result.get_build_scripts = lambda: self.get_build_scripts() + other.get_build_scripts() result.get_build_scripts = lambda: self.get_build_scripts() + other.get_build_scripts()
result.get_assemble_scripts = lambda: self.get_assemble_scripts() + other.get_assemble_scripts()
result.assemble_scripts = (self.assemble_scripts +
other.assemble_scripts)
result.post_build_scripts = (self.post_build_scripts + result.post_build_scripts = (self.post_build_scripts +
other.post_build_scripts) other.post_build_scripts)
@ -335,7 +333,7 @@ class BuildPack(LoggingConfigurable):
assemble_script_directives = [] assemble_script_directives = []
last_user = 'root' last_user = 'root'
for user, script in self.assemble_scripts: for user, script in self.get_assemble_scripts():
if last_user != user: if last_user != user:
assemble_script_directives.append("USER {}".format(user)) assemble_script_directives.append("USER {}".format(user))
last_user = user last_user = user

Wyświetl plik

@ -108,8 +108,7 @@ class CondaBuildPack(BuildPack):
"""Am I building a Python 2 kernel environment?""" """Am I building a Python 2 kernel environment?"""
return self.python_version and self.python_version.split('.')[0] == '2' return self.python_version and self.python_version.split('.')[0] == '2'
#@default('assemble_scripts') def get_assemble_scripts(self):
def setup_assembly(self):
assembly_scripts = [] assembly_scripts = []
environment_yml = self.binder_path('environment.yml') environment_yml = self.binder_path('environment.yml')
env_name = 'kernel' if self.py2 else 'root' env_name = 'kernel' if self.py2 else 'root'

Wyświetl plik

@ -49,8 +49,7 @@ class JuliaBuildPack(BuildPack):
) )
] ]
@default('assemble_scripts') def get_assemble_scripts(self):
def setup_assembly(self):
require = self.binder_path('REQUIRE') require = self.binder_path('REQUIRE')
return [( return [(
"${NB_USER}", "${NB_USER}",

Wyświetl plik

@ -60,8 +60,7 @@ class PythonBuildPack(BuildPack):
) )
] ]
@default('assemble_scripts') def get_assemble_scripts(self):
def setup_assembly(self):
# If we have a runtime.txt & that's set to python-2.7, # If we have a runtime.txt & that's set to python-2.7,
# we will *not* install requirements.txt but will find & # we will *not* install requirements.txt but will find &
# install a requirements3.txt file if it exists. # install a requirements3.txt file if it exists.
@ -140,8 +139,7 @@ class Python2BuildPack(BuildPack):
) )
] ]
@default('assemble_scripts') def get_assemble_scripts(self):
def setup_assembly(self):
return [ return [
( (
'${NB_USER}', '${NB_USER}',