From d824cca31fcebe97b8c7cfd1040eecbb9e5f03d3 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Thu, 12 Nov 2015 16:56:16 -0500 Subject: [PATCH 1/2] In interactive environments, the /import volume can now be made conditional. Also, fix a bug when using a proxy for the node proxy and cookie_path is / --- .../ipython/config/ipython.ini.sample | 2 +- .../ipython/templates/ipython.mako | 19 +++++-------------- .../web/base/interactive_environments.py | 12 +++++++++--- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/config/plugins/interactive_environments/ipython/config/ipython.ini.sample b/config/plugins/interactive_environments/ipython/config/ipython.ini.sample index 01926333c51..17ea7128a89 100644 --- a/config/plugins/interactive_environments/ipython/config/ipython.ini.sample +++ b/config/plugins/interactive_environments/ipython/config/ipython.ini.sample @@ -17,7 +17,7 @@ #command = docker {docker_args} # The docker image name that should be started. -image = bgruening/docker-ipython-notebook:15.10 +image = bgruening/docker-ipython-notebook:15.10-1 # Additional arguments that are passed to the `docker run` command. #command_inject = --sig-proxy=true -e DEBUG=false diff --git a/config/plugins/interactive_environments/ipython/templates/ipython.mako b/config/plugins/interactive_environments/ipython/templates/ipython.mako index 2e87c5ae221..3c3686735c5 100644 --- a/config/plugins/interactive_environments/ipython/templates/ipython.mako +++ b/config/plugins/interactive_environments/ipython/templates/ipython.mako @@ -8,8 +8,7 @@ import hashlib # Sets ID and sets up a lot of other variables ie_request.load_deploy_config() ie_request.attr.docker_port = 6789 -# Create tempdir in galaxy -temp_dir = ie_request.temp_dir +ie_request.attr.import_volume = False if ie_request.attr.PASSWORD_AUTH: m = hashlib.sha1() @@ -19,23 +18,15 @@ else: PASSWORD = "none" ## IPython Specific -# Prepare an empty notebook -notebook_id = ie_request.generate_hex(64) -with open( os.path.join( ie_request.attr.our_template_dir, 'notebook.ipynb' ), 'r') as nb_handle: - empty_nb = nb_handle.read() -empty_nb = empty_nb % notebook_id -# Copy over default notebook, unless the dataset this viz is running on is a notebook -empty_nb_path = os.path.join(temp_dir, 'ipython_galaxy_notebook.ipynb') - -if hda.datatype.__class__.__name__ != "Ipynb": - with open( empty_nb_path, 'w+' ) as handle: - handle.write( empty_nb ) +if hda.datatype.__class__.__name__ == "Ipynb": + DATASET_HID = hda.hid else: - shutil.copy( hda.file_name, empty_nb_path ) + DATASET_HID = None # Add all environment variables collected from Galaxy's IE infrastructure ie_request.launch(env_override={ 'notebook_password': PASSWORD, + 'dataset_hid': DATASET_HID, }) ## General IE specific diff --git a/lib/galaxy/web/base/interactive_environments.py b/lib/galaxy/web/base/interactive_environments.py index 52c5886f569..9967d83a519 100644 --- a/lib/galaxy/web/base/interactive_environments.py +++ b/lib/galaxy/web/base/interactive_environments.py @@ -31,6 +31,7 @@ class InteractiveEnviornmentRequest(object): self.attr.galaxy_root_dir = os.path.abspath(self.attr.galaxy_config.root) self.attr.root = web.url_for("/") self.attr.app_root = self.attr.root + "plugins/interactive_environments/" + self.attr.viz_id + "/static/" + self.attr.import_volume = True plugin_path = os.path.abspath( plugin.path ) @@ -60,8 +61,12 @@ class InteractiveEnviornmentRequest(object): # This duplicates the logic in the proxy manager if self.attr.galaxy_config.dynamic_proxy_external_proxy: - self.attr.proxy_prefix = '%s/%s' % ( + slash = '/' + if self.attr.galaxy_config.cookie_path.endswith('/'): + slash = '' + self.attr.proxy_prefix = '%s%s%s' % ( self.attr.galaxy_config.cookie_path, + slash, self.attr.galaxy_config.dynamic_proxy_prefix) else: self.attr.proxy_prefix = '' @@ -184,18 +189,19 @@ class InteractiveEnviornmentRequest(object): conf.update(env_override) env_str = ' '.join(['-e "%s=%s"' % (key.upper(), item) for key, item in conf.items()]) volume_str = ' '.join(['-v "%s"' % volume for volume in volumes]) + import_volume_str = '-v "{temp_dir}:/import/"'.format(temp_dir=temp_dir) if self.attr.import_volume else '' # This is the basic docker command such as "sudo -u docker docker {docker_args}" # or just "docker {docker_args}" command = self.attr.viz_config.get("docker", "command") # Then we format in the entire docker command in place of # {docker_args}, so as to let the admin not worry about which args are # getting passed - command = command.format(docker_args='run {command_inject} {environment} -d -P -v "{temp_dir}:/import/" {volume_str} {image}') + command = command.format(docker_args='run {command_inject} {environment} -d -P {import_volume_str} {volume_str} {image}') # Once that's available, we format again with all of our arguments command = command.format( command_inject=self.attr.viz_config.get("docker", "command_inject"), environment=env_str, - temp_dir=temp_dir, + import_volume_str=import_volume_str, volume_str=volume_str, image=self.attr.viz_config.get("docker", "image") ) From c4351413265796dacc15b8e3fc7382b8514f5b59 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 13 Nov 2015 10:55:25 -0500 Subject: [PATCH 2/2] Built image tag differs from intended. --- .../interactive_environments/ipython/config/ipython.ini.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/plugins/interactive_environments/ipython/config/ipython.ini.sample b/config/plugins/interactive_environments/ipython/config/ipython.ini.sample index 17ea7128a89..95f4430c17a 100644 --- a/config/plugins/interactive_environments/ipython/config/ipython.ini.sample +++ b/config/plugins/interactive_environments/ipython/config/ipython.ini.sample @@ -17,7 +17,7 @@ #command = docker {docker_args} # The docker image name that should be started. -image = bgruening/docker-ipython-notebook:15.10-1 +image = bgruening/docker-ipython-notebook:15.10.1 # Additional arguments that are passed to the `docker run` command. #command_inject = --sig-proxy=true -e DEBUG=false