From 5a6e53f728858d14064c984956c5c24666395da3 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 26 Apr 2017 09:23:22 -0400 Subject: [PATCH 1/3] Rework Jupyter IE for additional_ids handling. - 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 https://github.com/bgruening/docker-jupyter-notebook/pull/17). --- .../jupyter/templates/jupyter.mako | 9 ++++++++- lib/galaxy/web/base/interactive_environments.py | 13 +++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/config/plugins/interactive_environments/jupyter/templates/jupyter.mako b/config/plugins/interactive_environments/jupyter/templates/jupyter.mako index 8f8490f5367b..eab2674bc7a5 100644 --- a/config/plugins/interactive_environments/jupyter/templates/jupyter.mako +++ b/config/plugins/interactive_environments/jupyter/templates/jupyter.mako @@ -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, } ) diff --git a/lib/galaxy/web/base/interactive_environments.py b/lib/galaxy/web/base/interactive_environments.py index 291374133feb..5a61af80d9ee 100644 --- a/lib/galaxy/web/base/interactive_environments.py +++ b/lib/galaxy/web/base/interactive_environments.py @@ -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 '' @@ -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}" @@ -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 = [] @@ -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 From 9bc24aeef06b3536a6f69ddc23ac1ede4fb9b7a0 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 28 Apr 2017 12:14:45 -0400 Subject: [PATCH 2/3] Update rstudio to match additional hid handling of Jupyter. Ping @erasche - does this work? I'm not sure how rstudio handles the existing DATASET_HID. --- .../rstudio/templates/rstudio.mako | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/config/plugins/interactive_environments/rstudio/templates/rstudio.mako b/config/plugins/interactive_environments/rstudio/templates/rstudio.mako index 1277c4c34cec..cbb8485c15cd 100644 --- a/config/plugins/interactive_environments/rstudio/templates/rstudio.mako +++ b/config/plugins/interactive_environments/rstudio/templates/rstudio.mako @@ -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, } ) From 6201c61d72df9b3b0a1af454d52e4462c02fc587 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Mon, 1 May 2017 12:38:05 -0400 Subject: [PATCH 3/3] Add a note about use_volumes to Jupyter and RStudio GIEs. --- .../jupyter/config/jupyter.ini.sample | 4 ++++ .../rstudio/config/rstudio.ini.sample | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/config/plugins/interactive_environments/jupyter/config/jupyter.ini.sample b/config/plugins/interactive_environments/jupyter/config/jupyter.ini.sample index e9bf4b4aa15d..e632f553ec1a 100644 --- a/config/plugins/interactive_environments/jupyter/config/jupyter.ini.sample +++ b/config/plugins/interactive_environments/jupyter/config/jupyter.ini.sample @@ -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 diff --git a/config/plugins/interactive_environments/rstudio/config/rstudio.ini.sample b/config/plugins/interactive_environments/rstudio/config/rstudio.ini.sample index 695ee5c6e9f5..ad4d0cf9c0c1 100644 --- a/config/plugins/interactive_environments/rstudio/config/rstudio.ini.sample +++ b/config/plugins/interactive_environments/rstudio/config/rstudio.ini.sample @@ -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