From ebb41225bef68042d7725bbff2f75721f23f0e66 Mon Sep 17 00:00:00 2001 From: shiltemann Date: Tue, 2 Feb 2016 11:08:31 +0100 Subject: [PATCH 1/4] added Phinch interactive environment --- .../phinch/config/phinch.ini.sample | 21 ++++++++ .../phinch/config/phinch.xml | 15 ++++++ .../phinch/static/js/phinch.js | 44 +++++++++++++++++ .../phinch/templates/phinch.mako | 49 +++++++++++++++++++ 4 files changed, 129 insertions(+) create mode 100644 config/plugins/interactive_environments/phinch/config/phinch.ini.sample create mode 100644 config/plugins/interactive_environments/phinch/config/phinch.xml create mode 100644 config/plugins/interactive_environments/phinch/static/js/phinch.js create mode 100644 config/plugins/interactive_environments/phinch/templates/phinch.mako diff --git a/config/plugins/interactive_environments/phinch/config/phinch.ini.sample b/config/plugins/interactive_environments/phinch/config/phinch.ini.sample new file mode 100644 index 00000000000..66adc27dc92 --- /dev/null +++ b/config/plugins/interactive_environments/phinch/config/phinch.ini.sample @@ -0,0 +1,21 @@ +[main] +# Unused + +[docker] +# Command to execute docker. For example `sudo docker` or `docker-lxc`. +command = docker {docker_args} + +# The docker image name that should be started. +image = shiltemann/docker-phinch-galaxy:v1 + +# 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 container, 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 diff --git a/config/plugins/interactive_environments/phinch/config/phinch.xml b/config/plugins/interactive_environments/phinch/config/phinch.xml new file mode 100644 index 00000000000..3af1eee586b --- /dev/null +++ b/config/plugins/interactive_environments/phinch/config/phinch.xml @@ -0,0 +1,15 @@ + + + + + + HistoryDatasetAssociation + Biom1 + dataset_id + + + + dataset_id + + phinch.mako + \ No newline at end of file diff --git a/config/plugins/interactive_environments/phinch/static/js/phinch.js b/config/plugins/interactive_environments/phinch/static/js/phinch.js new file mode 100644 index 00000000000..e91c8983007 --- /dev/null +++ b/config/plugins/interactive_environments/phinch/static/js/phinch.js @@ -0,0 +1,44 @@ +function load_notebook(url){ + $( document ).ready(function() { + test_ie_availability(url, function(){ + append_notebook(url) + }); + }); +} + +function keep_alive(notebook_access_url){ + /** + * This is needed to keep the container alive. If the user leaves this site + * this function is not constantly pinging the container, the container will + * terminate itself. + */ + + var request_count = 0; + interval = setInterval(function(){ + $.ajax({ + url: notebook_access_url, + xhrFields: { + withCredentials: true + }, + type: "GET", + timeout: 500, + success: function(){ + console.log("Connected to IE, returning"); + }, + error: function(jqxhr, status, error){ + request_count++; + console.log("Request " + request_count); + if(request_count > 30){ + clearInterval(interval); + clear_main_area(); + toastr.error( + "Could not connect to IE, contact your administrator", + "Error", + {'closeButton': true, 'timeOut': 20000, 'tapToDismiss': false} + ); + } + } + }); + }, 10000); +} + diff --git a/config/plugins/interactive_environments/phinch/templates/phinch.mako b/config/plugins/interactive_environments/phinch/templates/phinch.mako new file mode 100644 index 00000000000..e6308f6f0a7 --- /dev/null +++ b/config/plugins/interactive_environments/phinch/templates/phinch.mako @@ -0,0 +1,49 @@ +<%namespace name="ie" file="ie.mako" /> +<% + +import os + +# Sets ID and sets up a lot of other variables +ie_request.load_deploy_config() + +# Define a volume that will be mounted into the container. +# This is a useful way to provide access to large files in the container, +# if the user knows ahead of time that they will need it. +user_file = ie_request.volume(hda.file_name, '/home/Phinch/data/'+os.path.basename(hda.file_name)+'.biom', how='ro') + +# Launch the IE. This builds and runs the docker command in the background. +ie_request.launch( + volumes=[user_file] +) + +# Only once the container is launched can we template our URLs. The ie_request +# doesn't have all of the information needed until the container is running. +url = ie_request.url_template('${PROXY_URL}/phinch/') + + +%> + + +${ ie.load_default_js() } + + + +
+
+ + From 87b5ba458fe574deb8c6200d8f12a8c329af98a1 Mon Sep 17 00:00:00 2001 From: shiltemann Date: Wed, 3 Feb 2016 10:41:55 +0100 Subject: [PATCH 2/4] changed docker tag to fit with Galaxy release --- .../interactive_environments/phinch/config/phinch.ini.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/plugins/interactive_environments/phinch/config/phinch.ini.sample b/config/plugins/interactive_environments/phinch/config/phinch.ini.sample index 66adc27dc92..be08cb60848 100644 --- a/config/plugins/interactive_environments/phinch/config/phinch.ini.sample +++ b/config/plugins/interactive_environments/phinch/config/phinch.ini.sample @@ -6,7 +6,7 @@ command = docker {docker_args} # The docker image name that should be started. -image = shiltemann/docker-phinch-galaxy:v1 +image = shiltemann/docker-phinch-galaxy:16.04 # Additional arguments that are passed to the `docker run` command. #command_inject = --sig-proxy=true -e DEBUG=false From 1b04ba3833597f2ebdc2e4f527044906ab7a4e7d Mon Sep 17 00:00:00 2001 From: Saskia Hiltemann Date: Thu, 4 Feb 2016 11:02:11 +0100 Subject: [PATCH 3/4] use bioblend for dataset import instead of mount --- .../phinch/templates/phinch.mako | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/config/plugins/interactive_environments/phinch/templates/phinch.mako b/config/plugins/interactive_environments/phinch/templates/phinch.mako index e6308f6f0a7..3b139ba311d 100644 --- a/config/plugins/interactive_environments/phinch/templates/phinch.mako +++ b/config/plugins/interactive_environments/phinch/templates/phinch.mako @@ -6,15 +6,12 @@ import os # Sets ID and sets up a lot of other variables ie_request.load_deploy_config() -# Define a volume that will be mounted into the container. -# This is a useful way to provide access to large files in the container, -# if the user knows ahead of time that they will need it. -user_file = ie_request.volume(hda.file_name, '/home/Phinch/data/'+os.path.basename(hda.file_name)+'.biom', how='ro') # Launch the IE. This builds and runs the docker command in the background. -ie_request.launch( - volumes=[user_file] -) +ie_request.launch(env_override={ + 'dataset_hid': hda.hid, + 'dataset_filename': hda.file_name +}) # Only once the container is launched can we template our URLs. The ie_request # doesn't have all of the information needed until the container is running. From 674bf530c65c05fea3e77a82404a77dc03f645ca Mon Sep 17 00:00:00 2001 From: Saskia Hiltemann Date: Fri, 5 Feb 2016 10:51:47 +0100 Subject: [PATCH 4/4] fix window height issue --- .../interactive_environments/phinch/static/js/phinch.js | 7 +++++++ .../interactive_environments/phinch/templates/phinch.mako | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config/plugins/interactive_environments/phinch/static/js/phinch.js b/config/plugins/interactive_environments/phinch/static/js/phinch.js index e91c8983007..1b4c993e554 100644 --- a/config/plugins/interactive_environments/phinch/static/js/phinch.js +++ b/config/plugins/interactive_environments/phinch/static/js/phinch.js @@ -6,6 +6,13 @@ function load_notebook(url){ }); } +function append_notebook(url){ + clear_main_area(); + $('#main').append('' + ); +} + + function keep_alive(notebook_access_url){ /** * This is needed to keep the container alive. If the user leaves this site diff --git a/config/plugins/interactive_environments/phinch/templates/phinch.mako b/config/plugins/interactive_environments/phinch/templates/phinch.mako index 3b139ba311d..c446bf7d6e5 100644 --- a/config/plugins/interactive_environments/phinch/templates/phinch.mako +++ b/config/plugins/interactive_environments/phinch/templates/phinch.mako @@ -40,7 +40,7 @@ requirejs(['interactive_environments', 'plugin/phinch'], function(){ }); -
+