metadata#

metadata(outfile=None, version=None, comments=None, require=None, pipfreeze=True, user=True, caller=True, git=True, asdict=False, tostring=False, relframe=0, **kwargs)[source]#

Collect common metadata: useful for exactly recreating (or remembering) the environment at a moment in time.

Parameters:
  • outfile (str) – if not None, then save as JSON to this filename

  • version (str) – if supplied, the user-supplied version of the data being stored

  • comments (str/dict) – additional comments on the data to store

  • require (str/dict) – if provided, an additional manual set of requirements

  • pipfreeze (bool) – store the current Python environment, equivalent to “pip freeze”

  • user (bool) – store the username

  • caller (bool) – store info on the calling file

  • git (bool) – store git information on the calling file (branch, hash, etc.)

  • asdict (bool) – construct as a dict instead of an objdict

  • tostring (bool) – return a string rather than a dict

  • relframe (int) – how far to descend into the calling stack (if used directly, use 0; if called by another function, use 1; etc)

  • kwargs (dict) – any additional data to store (can be anything JSON-compatible)

Returns:

A dictionary with information on the date, plateform, executable, versions of key libraries (Sciris, Numpy, pandas, and Matplotlib), and the Python environment

Examples:

metadata = sc.metadata()
sc.compareversions(metadata.versions.pandas, '1.5.0')

sc.metadata('my-metadata.json') # Save to disk

New in version 3.0.0.