niprov.plogging module

niprov.plogging.log(new, transformation, parents, code=None, logtext=None, transient=False, script=None, user=None, provenance=None, opts=None, dependencies=<niprov.dependencies.Dependencies object>)

Register a transformation that creates a new image (or several).

This will retrieve the primary parent’s provenance. if no provenance is availale for the primary parent, calls listener.unknownFile. Otherwise, some fields are copied from the primary parent, subject to availability. For instance, if the parent has no ‘subject’ field, the new file’s provenance won’t either.

Parameters:
  • new (str or list) – Path(s) to the newly created file(s).
  • transformation (str) – Name of the operation that has been used.
  • parents (str or list) – Path(s) to the file(s) that were used as the basis of the transformation. Assumes that the first file in the list is the primary parent for which basic provenance is known.
  • code (str, optional) – Code that was used to generate the new file
  • logtext (str, optional) – Any information about the transformation that was logged.
  • script (str, optional) – Path to the code file that contains the transformation code.
  • transient (bool, optional) – Set this to True to indicate that the file is only temporary and future checks should not expect it to be physically present. Defaults to False, assuming that the file remains.
  • user (string, optional) – Name of the user logging provenance.
  • provenance (dict, optional) – Add the key-value pairs in this dictionary to the provenance record for the new files.
  • opts (Configuration) – General settings for niprov. See niprov.config
Raises:

IOError – ‘[Errno 2] File not found’ is raised if the new file does not exist on the filesystem and is not marked as transient.

Returns:

New provenance, if multiple files were created, this is a list of images, otherwise, it is a single object.

Return type:

BaseFile