How to use the papermill.api.Notebook function in papermill

To help you get started, we’ve selected a few papermill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nteract / papermill / papermill / api.py View on Github external
def read_notebook(path):
    """
    Returns a Notebook object loaded from the location specified at 'path'.

    Args:
        path (str): Path to notebook ".ipynb" file.

    Returns:
        A Notebook object.
    """
    if not path.endswith(".ipynb"):
        raise PapermillException(
            "Notebooks should have an '.ipynb' file extension. Provided path: '%s'", path)

    nb = Notebook()
    nb.path = path
    nb.node = load_notebook_node(path)
    return nb
github nteract / papermill / papermill / api.py View on Github external
def __setitem__(self, key, value):
        # If notebook is a path str then load the notebook.
        if isinstance(value, string_types):
            value = read_notebook(value)

        if not isinstance(value, Notebook):
            raise PapermillException(
                "Value must either be a path string or a Papermill Notebook object. Found: '%s'" % str(type(value)))
        self._notebooks[key] = value