diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/JupyterUtil.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/JupyterUtil.js index 460044b98aefcc5705d0411df10e684f0a7f97c7..5ae907eec166da9d4671a2574ba18f86376aa66a 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/JupyterUtil.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/JupyterUtil.js @@ -135,7 +135,6 @@ var JupyterUtil = new function() { }, "outputs": [], "source": [ - "ds" + cIdx + ".data['dataStore']['downloadUrl'] = '" + profile.jupyterDSSEndpoint + "'\n", "ds" + cIdx + ".download(files=ds" + cIdx + ".file_list, destination='./', wait_until_finished=True)", ] }; @@ -161,32 +160,59 @@ var JupyterUtil = new function() { }; content.push(notebookProcess); - var saveHTMLTitle = { + var saveTitle = { "cell_type": "markdown", "metadata": {}, "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); - var saveHTML = { + content.push(saveTitle); + 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", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], - "source": [ - "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", - ] + "source": createHTML.concat(createDataset) }; - content.push(saveHTML); + content.push(save); return { "cells": content, diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/JupyterNotebookController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/JupyterNotebookController.js index 3b72c0b195c9eb468bb75d09d8e55f22bb6a3013..add4c3941a167d32495236bacd89f66d35d325e3 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/JupyterNotebookController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/JupyterNotebookController.js @@ -22,8 +22,8 @@ function JupyterNotebookController(entity) { this._jupyterNotebookView.repaint(); } - this.create = function(workspace, notebook, datasets) { - JupyterUtil.createJupyterNotebookAndOpen(workspace, notebook, datasets); + this.create = function(workspace, notebook, datasets, notebookOwner) { + JupyterUtil.createJupyterNotebookAndOpen(workspace, notebook, datasets, notebookOwner); Util.unblockUI(); } } \ No newline at end of file