add the initial IPython Integration

This commit is contained in:
Bjoern Gruening
2014-10-18 18:37:57 -04:00
parent 4d210bbb8f
commit 3f4be5ece0
2 changed files with 88 additions and 0 deletions
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE visualization SYSTEM "../../visualization.dtd">
<visualization name="IPython">
<data_sources>
<data_source>
<model_class>HistoryDatasetAssociation</model_class>
<test type="isinstance" test_attr="datatype" result_type="datatype">tabular.Tabular</test>
<to_param param_attr="id">dataset_id</to_param>
</data_source>
</data_sources>
<params>
<param type="dataset" var_name_in_template="hda" required="true">dataset_id</param>
</params>
<template>ipython.mako</template>
</visualization>
@@ -0,0 +1,73 @@
<%
import os
import sys
import tempfile
import shutil
import subprocess
empty_nb = """{
"metadata": {
"name": "",
"signature": "sha256:201eaf53a7ca0a5b661e0c8925adc61714a91ac871471604c428cbda4a698239"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Welcome to the interactive Galaxy IPython Notebook."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can access your data via the dataset number. For example: handle = open('42', 'r')"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}"""
PORT = 7777
temp_dir = os.path.abspath( tempfile.mkdtemp() )
new_dataset_path = os.path.join( temp_dir, str( hda.hid ) )
shutil.copy( hda.file_name, new_dataset_path )
empty_nb_path = os.path.join(temp_dir, 'ipython_galaxy_notebook.ipynb')
with open( empty_nb_path, 'w+' ) as handle:
handle.write( empty_nb )
docker_cmd = 'docker run -d -p %s:6789 -v "%s:/import/" bgruening/docker-ipython-notebook' % (PORT, temp_dir)
subprocess.call(docker_cmd, shell=True)
%>
<html>
<body>
<object data="http://localhost:${PORT}/notebooks/ipython_galaxy_notebook.ipynb" height="100%" width="100%">
<embed src="http://localhost:${PORT}/notebooks/ipython_galaxy_notebook.ipynb" height="100%" width="100%">
</embed>
</object>
</body>
</html>