From af36ca6d9467932036d19a448ca4c74affffae9a Mon Sep 17 00:00:00 2001 From: Bjoern Gruening Date: Tue, 2 Jun 2015 23:09:22 +0200 Subject: [PATCH 1/2] add BAM iobio visualisation as Interactive Environment --- .../bam_iobio/config/bam_iobio.ini.sample | 43 +++++++++++++ .../bam_iobio/config/bam_iobio.xml | 15 +++++ .../bam_iobio/static/js/bam_iobio.js | 39 ++++++++++++ .../bam_iobio/templates/bam_iobio.mako | 62 +++++++++++++++++++ .../common/templates/ie.mako | 1 - .../ipython/config/ipython.ini.sample | 1 - .../ipython/static/js/ipython.js | 2 +- .../rstudio/static/js/rstudio.js | 2 +- .../web/base/interactive_environments.py | 3 +- 9 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 config/plugins/interactive_environments/bam_iobio/config/bam_iobio.ini.sample create mode 100644 config/plugins/interactive_environments/bam_iobio/config/bam_iobio.xml create mode 100644 config/plugins/interactive_environments/bam_iobio/static/js/bam_iobio.js create mode 100644 config/plugins/interactive_environments/bam_iobio/templates/bam_iobio.mako diff --git a/config/plugins/interactive_environments/bam_iobio/config/bam_iobio.ini.sample b/config/plugins/interactive_environments/bam_iobio/config/bam_iobio.ini.sample new file mode 100644 index 000000000000..d6ff35d95bba --- /dev/null +++ b/config/plugins/interactive_environments/bam_iobio/config/bam_iobio.ini.sample @@ -0,0 +1,43 @@ +[main] +# Following options are ignored if using the Galaxy dynamic proxy but +# are useful if mapping a range of ports for environment consumption. +#password_auth = False +#ssl = False + +[docker] +# Command to launch docker container. For example `sudo docker` or `docker-lxc`. +# If you need to use a command like `sg` you can do that here, just be sure to +# wrap all of the docker portion in single quotes. E.g. `sg 'docker' 'docker {docker_args}'` +# +# It is recommended that you use command_inject if you need to inject +# additional parameters. This command string is re-used for a `docker inspect` +# command and will likely cause errors if it is extensively modified, past the +# usual group/sudo changes. +#command = docker {docker_args} + +# The docker image name that should be started. +image = qiaoy/iobio-bundle.bam-iobio:1.0-ondemand + +# Additional arguments that are passed to the `docker run` command. +#command_inject = --sig-proxy=true -e DEBUG=false + +# URL to access the Galaxy API with from the spawn Docker containter, if empty +# this falls back to galaxy.ini's galaxy_infrastructure_url and finally to the +# Docker host of the spawned container if that is also not set. +#galaxy_url = + +# The Docker hostname. It can be useful to run the Docker daemon on a different +# host than Galaxy. +#docker_hostname = localhost + +# Try to set the tempdirectory to world execute - this can fix the issue +# where 'sudo docker' is not able to mount the folder otherwise. +# "finalize namespace chdir to /import permission denied" +#wx_tempdir = False + +# Overwride the IE tempdirectory. This can be useful if you regular tempdir is +# located on an NFS share, which does not work well as Docker volume. In this case +# you can have a shared sshfs share which you can use as temporary directory to +# share data between the IE and Galaxy. +#docker_galaxy_temp_dir = None + diff --git a/config/plugins/interactive_environments/bam_iobio/config/bam_iobio.xml b/config/plugins/interactive_environments/bam_iobio/config/bam_iobio.xml new file mode 100644 index 000000000000..fa96cdb7570c --- /dev/null +++ b/config/plugins/interactive_environments/bam_iobio/config/bam_iobio.xml @@ -0,0 +1,15 @@ + + + + + + HistoryDatasetAssociation + binary.Bam + dataset_id + + + + dataset_id + + bam_iobio.mako + diff --git a/config/plugins/interactive_environments/bam_iobio/static/js/bam_iobio.js b/config/plugins/interactive_environments/bam_iobio/static/js/bam_iobio.js new file mode 100644 index 000000000000..395904e329b7 --- /dev/null +++ b/config/plugins/interactive_environments/bam_iobio/static/js/bam_iobio.js @@ -0,0 +1,39 @@ +function message_failed_auth(password){ + toastr.info( + "Automatic authorization failed.", + "Please login manually", + {'closeButton': true, 'timeOut': 100000, 'tapToDismiss': false} + ); +} + +function message_failed_connection(){ + toastr.error( + "Could not connect to BAM iobio. Please contact your administrator.", + "Security warning", + {'closeButton': true, 'timeOut': 20000, 'tapToDismiss': true} + ); +} + +/** + * Load an interactive environment (IE) from a remote URL + * @param {String} password: password used to authenticate to the remote resource + * @param {String} notebook_login_url: URL that should be POSTed to for login + * @param {String} notebook_access_url: the URL embeded in the page and loaded + * + */ +function load_notebook(notebook_access_url){ + $( document ).ready(function() { + // Test notebook_login_url for accessibility, executing the login+load function whenever + // we've successfully connected to the IE. + test_ie_availability(notebook_access_url, function(){ + _handle_notebook_loading(notebook_access_url); + }); + }); +} + +/** + * Must be implemented by IEs + */ +function _handle_notebook_loading(notebook_access_url){ + append_notebook(notebook_access_url); +} diff --git a/config/plugins/interactive_environments/bam_iobio/templates/bam_iobio.mako b/config/plugins/interactive_environments/bam_iobio/templates/bam_iobio.mako new file mode 100644 index 000000000000..8f18630074ea --- /dev/null +++ b/config/plugins/interactive_environments/bam_iobio/templates/bam_iobio.mako @@ -0,0 +1,62 @@ + <%namespace name="ie" file="ie.mako" /> + +<% +import subprocess +from galaxy.util import sockets + +# Sets ID and sets up a lot of other variables +ie_request.load_deploy_config() +ie_request.attr.docker_port = 80 +ie_request.attr.import_volume = False + +bam = ie_request.volume(hda.file_name, '/input/bamfile.bam', how='ro') +bam_index = ie_request.volume(hda.metadata.bam_index.file_name, '/input/bamfile.bam.bai', how='ro') + +ie_request.launch(volumes=[bam, bam_index], env_override={ + 'PUB_HTTP_PORT': ie_request.attr.galaxy_config.dynamic_proxy_bind_port, + 'PUB_HOSTNAME': ie_request.attr.HOST, +}) + +notebook_access_url = ie_request.url_template('${PROXY_URL}/?bam=http://localhost/tmp/bamfile.bam') + +root = h.url_for( '/' ) +%> + + + ${ ie.load_default_js() } + + + + +
+
+ + diff --git a/config/plugins/interactive_environments/common/templates/ie.mako b/config/plugins/interactive_environments/common/templates/ie.mako index 2437602672bc..c6e77e3f5d31 100644 --- a/config/plugins/interactive_environments/common/templates/ie.mako +++ b/config/plugins/interactive_environments/common/templates/ie.mako @@ -4,7 +4,6 @@ // Following three are for older-style IE proxies, newer dynamic Galaxy proxy // does not use these. ie_password_auth = ${ ie_request.javascript_boolean(ie_request.attr.PASSWORD_AUTH) }; -ie_apache_urls = ${ ie_request.javascript_boolean(ie_request.attr.APACHE_URLS) }; ie_password = '${ ie_request.notebook_pw }'; diff --git a/config/plugins/interactive_environments/ipython/config/ipython.ini.sample b/config/plugins/interactive_environments/ipython/config/ipython.ini.sample index 01926333c519..c59bf22b3610 100644 --- a/config/plugins/interactive_environments/ipython/config/ipython.ini.sample +++ b/config/plugins/interactive_environments/ipython/config/ipython.ini.sample @@ -1,7 +1,6 @@ [main] # Following options are ignored if using the Galaxy dynamic proxy but # are useful if mapping a range of ports for environment consumption. -#apache_urls = False #password_auth = False #ssl = False diff --git a/config/plugins/interactive_environments/ipython/static/js/ipython.js b/config/plugins/interactive_environments/ipython/static/js/ipython.js index a63574a2248c..534ed225052a 100644 --- a/config/plugins/interactive_environments/ipython/static/js/ipython.js +++ b/config/plugins/interactive_environments/ipython/static/js/ipython.js @@ -65,7 +65,7 @@ function _handle_notebook_loading(password, notebook_login_url, notebook_access_ append_notebook(notebook_access_url); }, error: function(jqxhr, status, error){ - if(ie_password_auth && !ie_apache_urls){ + if(ie_password_auth){ // Failure happens due to CORS message_failed_auth(password); append_notebook(notebook_access_url); diff --git a/config/plugins/interactive_environments/rstudio/static/js/rstudio.js b/config/plugins/interactive_environments/rstudio/static/js/rstudio.js index 7229a2b5bedc..ccff80ff943f 100644 --- a/config/plugins/interactive_environments/rstudio/static/js/rstudio.js +++ b/config/plugins/interactive_environments/rstudio/static/js/rstudio.js @@ -78,7 +78,7 @@ function _handle_notebook_loading(password, notebook_login_url, notebook_access_ append_notebook(notebook_access_url); }, error: function(jqxhr, status, error){ - if(ie_password_auth && !ie_apache_urls){ + if(ie_password_auth){ // Failure now happens because the redirect that RStudio gives us includes the // port internal to nginx. (E.g. localhost:NNNN/rstudio/NNNN/) // so disabling the message here makes sense as long as it's working correctly diff --git a/lib/galaxy/web/base/interactive_environments.py b/lib/galaxy/web/base/interactive_environments.py index 52c5886f569a..1cd81ccd1954 100644 --- a/lib/galaxy/web/base/interactive_environments.py +++ b/lib/galaxy/web/base/interactive_environments.py @@ -25,7 +25,7 @@ def __init__(self, trans, plugin): self.log = log self.attr = Bunch() - self.attr.viz_id = plugin_config["name"].lower() + self.attr.viz_id = plugin.name self.attr.history_id = trans.security.encode_id( trans.history.id ) self.attr.galaxy_config = trans.app.config self.attr.galaxy_root_dir = os.path.abspath(self.attr.galaxy_config.root) @@ -95,7 +95,6 @@ def _boolean_option(option, default=False): # we always assume use of Galaxy dynamic proxy? None of these need to be specified # if using the Galaxy dynamic proxy. self.attr.PASSWORD_AUTH = _boolean_option("password_auth") - self.attr.APACHE_URLS = _boolean_option("apache_urls") self.attr.SSL_URLS = _boolean_option("ssl") def get_conf_dict(self): From 5188b4179063b3cc57c5c983d48a5fb62387d2b3 Mon Sep 17 00:00:00 2001 From: Bjoern Gruening Date: Thu, 19 Nov 2015 20:53:30 +0100 Subject: [PATCH 2/2] make travis happy --- lib/galaxy/web/base/interactive_environments.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/galaxy/web/base/interactive_environments.py b/lib/galaxy/web/base/interactive_environments.py index 1cd81ccd1954..e44e09396c0c 100644 --- a/lib/galaxy/web/base/interactive_environments.py +++ b/lib/galaxy/web/base/interactive_environments.py @@ -19,8 +19,6 @@ class InteractiveEnviornmentRequest(object): def __init__(self, trans, plugin): - plugin_config = plugin.config - self.trans = trans self.log = log