wlauto.result_processors.ipynb_exporter package

Module contents

class wlauto.result_processors.ipynb_exporter.IPythonNotebookExporter(**kwargs)[source]

Bases: wlauto.core.result.ResultProcessor

aliases = AC([])
artifacts = AC([])
core_modules = []
description = '\n Generates an IPython notebook from a template with the results and runs it.\n Optionally it can show the resulting notebook in a web browser.\n It can also generate a PDF from the notebook.\n\n The template syntax is that of `jinja2 <http://jinja.pocoo.org/>`_\n and the template should generate a valid ipython notebook. The\n templates receives ``result`` and ``context`` which correspond to\n the RunResult and ExecutionContext respectively. You can use those\n in your ipython notebook template to extract any information you\n want to parse or show.\n\n This results_processor depends on ``ipython`` and ``python-jinja2`` being\n installed on the system.\n\n For example, a simple template that plots a bar graph of the results is::\n\n \n {\n "metadata": {\n "name": ""\n },\n "nbformat": 3,\n "nbformat_minor": 0,\n "worksheets": [\n {\n "cells": [\n {\n "cell_type": "code",\n "collapsed": false,\n "input": [\n "%pylab inline"\n ],\n "language": "python",\n "metadata": {},\n "outputs": [],\n "prompt_number": 1\n },\n {\n "cell_type": "code",\n "collapsed": false,\n "input": [\n "results = {",\n {% for ir in result.iteration_results -%}\n {% for metric in ir.metrics -%}\n {% if metric.name in ir.workload.summary_metrics or not ir.workload.summary_metrics -%}\n "\\"{{ ir.spec.label }}_{{ ir.id }}_{{ ir.iteration }}_{{ metric.name }}\\": {{ metric.value }}, ",\n {%- endif %}\n {%- endfor %}\n {%- endfor %}\n "}\\n",\n "width = 0.7\\n",\n "ind = np.arange(len(results))"\n ],\n "language": "python",\n "metadata": {},\n "outputs": [],\n "prompt_number": 2\n },\n {\n "cell_type": "code",\n "collapsed": false,\n "input": [\n "fig, ax = plt.subplots()\\n",\n "ax.bar(ind, results.values(), width)\\n",\n "ax.set_xticks(ind + width/2)\\n",\n "_ = ax.set_xticklabels(results.keys())"\n ],\n "language": "python",\n "metadata": {},\n "outputs": [],\n "prompt_number": 3\n }\n ],\n "metadata": {}\n }\n ]\n }\n'
export_run_result(result, context)[source]
finalize(*args, **kwargs)
generate_notebook(result, context)[source]

Generate a notebook from the template and run it

initialize(*args, **kwargs)
kind = 'result_processor'
name = 'ipynb_exporter'
open_file(output_format)[source]

Open the exported notebook

open_notebook()[source]

Open the notebook in a browser

parameters = AC(["Param({'kind': <type 'list'>, 'mandatory': None, 'name': 'modules', 'constraint': None, 'default': None, 'allowed_values': None, 'global_alias': None, 'override': False})", "Param({'kind': <function file_path>, 'mandatory': None, 'name': 'notebook_template', 'constraint': None, 'default': 'template.ipynb', 'allowed_values': None, 'global_alias': None, 'override': False})", "Param({'kind': <type 'str'>, 'mandatory': None, 'name': 'notebook_name_prefix', 'constraint': None, 'default': 'result_', 'allowed_values': None, 'global_alias': None, 'override': False})", "Param({'kind': <function boolean>, 'mandatory': None, 'name': 'show_notebook', 'constraint': None, 'default': None, 'allowed_values': None, 'global_alias': None, 'override': False})", "Param({'kind': <function file_path>, 'mandatory': None, 'name': 'notebook_directory', 'constraint': None, 'default': None, 'allowed_values': None, 'global_alias': None, 'override': False})", "Param({'kind': <type 'str'>, 'mandatory': None, 'name': 'notebook_url', 'constraint': None, 'default': 'http://localhost:8888/notebooks', 'allowed_values': None, 'global_alias': None, 'override': False})", "Param({'kind': <function boolean>, 'mandatory': None, 'name': 'convert_to_html', 'constraint': None, 'default': None, 'allowed_values': None, 'global_alias': None, 'override': False})", "Param({'kind': <function boolean>, 'mandatory': None, 'name': 'show_html', 'constraint': None, 'default': None, 'allowed_values': None, 'global_alias': None, 'override': False})", "Param({'kind': <function boolean>, 'mandatory': None, 'name': 'convert_to_pdf', 'constraint': None, 'default': None, 'allowed_values': None, 'global_alias': None, 'override': False})", "Param({'kind': <function boolean>, 'mandatory': None, 'name': 'show_pdf', 'constraint': None, 'default': None, 'allowed_values': None, 'global_alias': None, 'override': False})"])
validate(*args, **kwargs)