Skip to content

Commit

Permalink
Merge pull request #3980 from jmchilton/ie_for_mac_os_x_fixes
Browse files Browse the repository at this point in the history
Rework Jupyter IE for additional_ids handling.
  • Loading branch information
hexylena committed May 1, 2017
2 parents 4c1f9c8 + 6201c61 commit 0940411
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
Expand Up @@ -45,6 +45,10 @@
# inside your container to which Galaxy should connect the UI.
#docker_connect_port = None

# Set the following value to false if Docker volumes between Galaxy server and Docker
# container cannot or should not be used.
#use_volumes = True

# To run containers in Docker Swarm mode on (an existing swarm), set the
# following option to True *and*:
# - set docker_connect_port above. For Jupyter the # port should most likely be
Expand Down
Expand Up @@ -17,19 +17,26 @@ if ie_request.attr.PASSWORD_AUTH:
else:
PASSWORD = "none"
additional_ids = trans.request.params.get('additional_dataset_ids', None)
## Jupyter Notbook Specific
if hda.datatype.__class__.__name__ == "Ipynb":
DATASET_HID = hda.hid
else:
DATASET_HID = None
if not additional_ids:
additional_ids = str(trans.security.encode_id( hda.id ) )
else:
additional_ids += "," + trans.security.encode_id( hda.id )
# Add all environment variables collected from Galaxy's IE infrastructure
ie_request.launch(
image=trans.request.params.get('image_tag', None),
additional_ids=trans.request.params.get('additional_dataset_ids', None),
additional_ids=additional_ids if ie_request.use_volumes else None,
env_override={
'notebook_password': PASSWORD,
'dataset_hid': DATASET_HID,
'additional_ids': additional_ids if not ie_request.use_volumes else None,
}
)
Expand Down
Expand Up @@ -47,6 +47,10 @@ password_auth = True
# inside your container to which Galaxy should connect the UI.
#docker_connect_port = None

# Set the following value to false if Docker volumes between Galaxy server and Docker
# container cannot or should not be used.
#use_volumes = True

# To run containers in Docker Swarm mode on (an existing swarm), set the
# following option to True *and*:
# - set docker_connect_port above. For erasche/docker-rstudio-notebook the port
Expand Down
Expand Up @@ -13,16 +13,23 @@ USERNAME = "rstudio"
# Then override it again
ie_request.notebook_pw = "rstudio"
additional_ids = trans.request.params.get('additional_dataset_ids', None)
if not additional_ids:
additional_ids = str(trans.security.encode_id( hda.id ) )
else:
additional_ids += "," + trans.security.encode_id( hda.id )
DATASET_HID = hda.hid
# Add all environment variables collected from Galaxy's IE infrastructure
ie_request.launch(
image=trans.request.params.get('image_tag', None),
additional_ids=trans.request.params.get('additional_dataset_ids', None),
additional_ids=additional_ids if ie_request.use_volumes else None,
env_override={
'notebook_username': USERNAME,
'notebook_password': PASSWORD,
'dataset_hid': DATASET_HID,
'additional_ids': additional_ids if not ie_request.use_volumes else None,
}
)
Expand Down
13 changes: 11 additions & 2 deletions lib/galaxy/web/base/interactive_environments.py
Expand Up @@ -256,7 +256,7 @@ def _get_env_for_run(self, env_override=None):
return dict([(key.upper(), item) for key, item in conf.items()])

def _get_import_volume_for_run(self):
if self.attr.import_volume:
if self.use_volumes and self.attr.import_volume:
return '{temp_dir}:/import/'.format(temp_dir=self.temp_dir)
return ''

Expand All @@ -272,7 +272,7 @@ def docker_cmd(self, image, env_override=None, volumes=None):
env = self._get_env_for_run(env_override)
import_volume_def = self._get_import_volume_for_run()
env_str = ' '.join(['-e "%s=%s"' % (key, item) for key, item in env.items()])
volume_str = ' '.join(['-v "%s"' % volume for volume in volumes])
volume_str = ' '.join(['-v "%s"' % volume for volume in volumes]) if self.use_volumes else ''
import_volume_str = '-v "{import_volume}"'.format(import_volume=import_volume_def) if import_volume_def else ''
name = None
# This is the basic docker command such as "sudo -u docker docker {docker_args}"
Expand All @@ -298,6 +298,13 @@ def docker_cmd(self, image, env_override=None, volumes=None):
)
return command

@property
def use_volumes(self):
if self.attr.viz_config.has_option("docker", "use_volumes"):
return string_as_bool_or_none(self.attr.viz_config.get("docker", "use_volumes"))
else:
return True

def container_run_args(self, image, env_override=None, volumes=None):
if volumes is None:
volumes = []
Expand Down Expand Up @@ -434,6 +441,8 @@ def launch(self, image=None, additional_ids=None, env_override=None, volumes=Non
:param volumes: dictionary of docker volume mounts
"""
if volumes is None:
volumes = []
if image is None:
image = self.default_image

Expand Down

0 comments on commit 0940411

Please sign in to comment.