Utilities

Utils

papermill.utils.any_tagged_cell(nb, tag)

Whether the notebook contains at least one cell tagged tag?

Parameters
  • nb (nbformat.NotebookNode) – The notebook to introspect

  • tag (str) – The tag to look for

Returns

Whether the notebook contains a cell tagged tag?

Return type

bool

papermill.utils.chdir(path)

Change working directory to path and restore old path on exit.

path can be None in which case this is a no-op.

papermill.utils.find_first_tagged_cell_index(nb, tag)

Find the first tagged cell tag in the notebook.

Parameters
  • nb (nbformat.NotebookNode) – The notebook to introspect

  • tag (str) – The tag to look for

Returns

Whether the notebook contains a cell tagged tag?

Return type

nbformat.NotebookNode

papermill.utils.merge_kwargs(caller_args, **callee_args)

Merge named argument.

Function takes a dictionary of caller arguments and callee arguments as keyword arguments Returns a dictionary with merged arguments. If same argument is in both caller and callee arguments the last one will be taken and warning will be raised.

Parameters
  • caller_args (dict) – Caller arguments

  • **callee_args – Keyword callee arguments

Returns

args – Merged arguments

Return type

dict

papermill.utils.nb_kernel_name(nb, name=None)

Helper for fetching out the kernel name from a notebook object.

Parameters
  • nb (nbformat.NotebookNode) – The notebook to introspect

  • name (str) – A provided name field

Returns

The name of the kernel

Return type

str

Raises

ValueError – If no kernel name is found or provided

papermill.utils.nb_language(nb, language=None)

Helper for fetching out the programming language from a notebook object.

Parameters
  • nb (nbformat.NotebookNode) – The notebook to introspect

  • language (str) – A provided language field

Returns

The programming language of the notebook

Return type

str

Raises

ValueError – If no notebook language is found or provided

papermill.utils.remove_args(args=None, **kwargs)

Remove arguments from kwargs.

Parameters
  • args (list) – Argument names to remove from kwargs

  • **kwargs – Arbitrary keyword arguments

Returns

kwargs – New dictionary of arguments

Return type

dict

papermill.utils.retry(num)

Exceptions

exception papermill.exceptions.AwsError

Raised when an AWS Exception is encountered.

exception papermill.exceptions.FileExistsError

Raised when a File already exists on S3.

exception papermill.exceptions.PapermillException

Raised when an exception is encountered when operating on a notebook.

exception papermill.exceptions.PapermillExecutionError(cell_index, exec_count, source, ename, evalue, traceback)

Raised when an exception is encountered in a notebook.

exception papermill.exceptions.PapermillMissingParameterException

Raised when a parameter without a value is required to operate on a notebook.

exception papermill.exceptions.PapermillOptionalDependencyException

Raised when an exception is encountered when an optional plugin is missing.

exception papermill.exceptions.PapermillParameterOverwriteWarning

Callee overwrites caller argument to pass down the stream.

exception papermill.exceptions.PapermillRateLimitException

Raised when an io request has been rate limited

exception papermill.exceptions.PapermillWarning

Base warning for papermill.

papermill.exceptions.missing_dependency_generator(package, dep)
papermill.exceptions.missing_environment_variable_generator(package, env_key)

Log

Sets up a logger