Skip to content

Commit

Permalink
Rework Jupyter IE for additional_ids handling.
Browse files Browse the repository at this point in the history
- Add a new option ``use_volumes`` to the Docker config.
- If using volumes, do nothing differently.
- If not using volumes, set ADDITIONAL_IDS in the environment for the IE itself to fetch (requires bgruening/docker-jupyter-notebook#17).
  • Loading branch information
jmchilton committed Apr 26, 2017
1 parent 740d85a commit 3b615f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
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
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 3b615f8

Please sign in to comment.