mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #1076 from natefoo/ie-conditional-import-volume
[15.10] Fix a bug in IEs when proxying the proxy
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user