Skip to content
Snippets Groups Projects
Commit 9108b4f5 authored by juanf's avatar juanf
Browse files

SSDM-4223 : Jupyter integration - ongoing work

SVN: 38741
parent 28b71e9c
No related branches found
No related tags found
No related merge requests found
...@@ -135,7 +135,6 @@ var JupyterUtil = new function() { ...@@ -135,7 +135,6 @@ var JupyterUtil = new function() {
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"ds" + cIdx + ".data['dataStore']['downloadUrl'] = '" + profile.jupyterDSSEndpoint + "'\n",
"ds" + cIdx + ".download(files=ds" + cIdx + ".file_list, destination='./', wait_until_finished=True)", "ds" + cIdx + ".download(files=ds" + cIdx + ".file_list, destination='./', wait_until_finished=True)",
] ]
}; };
...@@ -161,32 +160,59 @@ var JupyterUtil = new function() { ...@@ -161,32 +160,59 @@ var JupyterUtil = new function() {
}; };
content.push(notebookProcess); content.push(notebookProcess);
var saveHTMLTitle = { var saveTitle = {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"### Save Notebook as HTML (save it first!)" "### Create Result Dataset with current notebook and HTML version with the output (save the notebook first!)"
] ]
} }
content.push(saveHTMLTitle); content.push(saveTitle);
var saveHTML = { var createHTML = [
"from nbconvert import HTMLExporter\n",
"import codecs\n",
"import nbformat\n",
"exporter = HTMLExporter()\n",
"output_notebook = nbformat.read('" + fileName + "', as_version=4)\n",
"output, resources = exporter.from_notebook_node(output_notebook)\n",
"codecs.open('" + fileName + ".html', 'w', encoding='utf-8').write(output)\n",
"\n"
];
var ownerSettings = ""
switch(ownerEntity["@type"]) {
case "as.dto.experiment.Experiment":
ownerSettings = "experiment= o.get_experiment('"+ ownerEntity.identifier.identifier +"'),\n";
break;
case "as.dto.sample.Sample":
ownerSettings = "sample= o.get_sample('"+ ownerEntity.identifier.identifier +"'),\n";
break;
}
var parents = JSON.stringify(dataSetIds);
var createDataset = [
"ds_new = o.new_dataset(\n",
"type='ANALYZED_DATA',\n",
ownerSettings,
"parents=" + parents + ",\n",
"files = ['" + fileName + "', '" + fileName + ".html'],\n",
"props={'name': 'Name your dataset!', 'notes': 'Write some notes or delete this property!'}\n",
")\n",
"ds_new.save()"
];
var save = {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
"outputs": [], "outputs": [],
"source": [ "source": createHTML.concat(createDataset)
"from nbconvert import HTMLExporter\n",
"import codecs\n",
"import nbformat\n",
"exporter = HTMLExporter()\n",
"output_notebook = nbformat.read('" + fileName + "', as_version=4)\n",
"output, resources = exporter.from_notebook_node(output_notebook)\n",
"codecs.open('" + fileName + ".html', 'w', encoding='utf-8').write(output)\n",
]
}; };
content.push(saveHTML); content.push(save);
return { return {
"cells": content, "cells": content,
......
...@@ -22,8 +22,8 @@ function JupyterNotebookController(entity) { ...@@ -22,8 +22,8 @@ function JupyterNotebookController(entity) {
this._jupyterNotebookView.repaint(); this._jupyterNotebookView.repaint();
} }
this.create = function(workspace, notebook, datasets) { this.create = function(workspace, notebook, datasets, notebookOwner) {
JupyterUtil.createJupyterNotebookAndOpen(workspace, notebook, datasets); JupyterUtil.createJupyterNotebookAndOpen(workspace, notebook, datasets, notebookOwner);
Util.unblockUI(); Util.unblockUI();
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment