magni.reproducibility._annotation module

Module providing functions that may be used to annotate data.

Routine Listings

get_conda_info()
Function that returns information about an Anaconda install.
get_datetime()
Function that returns information about the current date and time.
get_git_revision(git_root_dir=None)
Function that returns information about the current git revision.
get_file_hashes(path, blocksize=2**30)
Function that returns the md5 and sha256 checksums of a file.
get_magni_config()
Function that returns information about the current configuration of Magni.
get_magni_info()
Function that returns genral information about Magni.
get_platform_info()
Function that returns information about the platform used to run the code.

Notes

The returned annotations are any nested level of dicts of dicts of strings.

magni.reproducibility._annotation.get_conda_info()[source]

Return a dictionary contianing information from Conda.

Conda is the package manager for the Anaconda scientific Python distribution. This function will return various information about the Anaconda installation on the system by querying the Conda package database.

Warning

THIS IS HIGHLY EXPERIMENTAL AND MAY BREAK WITHOUT FURTHER NOTICE.

Note

This only works with the conda root environment.

Returns:conda_info (dict) – Various information from conda (see notes below for further details).

Notes

If the Python intepreter is unable to locate and import the conda package, an empty dicionary is returned.

The returned dictionary contains the same infomation that is returned by “conda info” in addition to an overview of the linked modules in the Anaconda installation as well as information about the “conda env” if it is available. Specifically, the returned dictionary has the following keys:

  • platform
  • conda_version
  • root_prefix
  • default_prefix
  • envs_dirs
  • package_cache
  • channels
  • config_file
  • linked_modules
  • env_export

For conda < 4.2.0, it also includes the key:

  • is_foreign_system

For conda >= 4.2.0, it also includes the keys:

  • python_version
  • conda_is_private
  • offline_mode

Additionally, the returned dictionary has a key named status, which can have either of the following values:

  • ‘Succeeded’ (Everything seems to be OK)
  • ‘Failed’ (Something went wrong - a few details are incluede in the key)

If “conda-env” is installed on the system, the env_export essentially holds the infomation from “conda env export -n root” as a dictionary. The information provided by this key partially overlaps with the infomation in the linked_modules and modules_info keys.

magni.reproducibility._annotation.get_datetime()[source]

Return a dictionary holding the current date and time.

Returns:date_time (dict) – The dictionary holding the current date and time.

Notes

The returned dictionary has the following keys:

  • today (date and time including timezone offset)
  • utcnow (UTC date and time)
  • pretty_utc (UTC date and time formatted according to current locale)
  • status

The status entry informs about the success of the pretty_utc formatting. It has one of the follwing values:

  • Succeeded (Everything seems OK)
  • Failed (It was not possible to format the time)
magni.reproducibility._annotation.get_git_revision(git_root_dir=None)[source]

Return a dictionary containing information about the current git revision.

Parameters:git_root_dir (str) – The path to the git root directory to get git revision for (the default is None, which implies that the git revision of the magni directory is returned).
Returns:git_revision (dict) – Information about the current git revision.

Notes

If the git revision extract succeeded, the returned dictionary has the following keys:

  • status (with value ‘Succeeded’)
  • tag (output of “git describe”)
  • branch (output of “git describe –all”)
  • remote (output of “git remote -v”)

If the git revision extract failed, the returned dictionary has the following keys:

  • status (with value ‘Failed’)
  • returncode (returncode from failing git command)
  • output (output from failing git command)

The “git” commands are run in the git root directory.

magni.reproducibility._annotation.get_file_hashes(path, blocksize=1073741824)[source]

Return a dictionary with md5 and sha256 checksums of a file.

Parameters:
  • path (str) – The path to the file to checksum.
  • blocksize (int) – The chunksize (in bytes) to read from the file one at a time.
Returns:

file_hashes (dict) – The dictionary holding the md5 and sha256 hexdigests of the file.

magni.reproducibility._annotation.get_magni_config()[source]

Return a dictionary holding the current configuration of Magni.

Returns:magni_config (dict) – The dictionary holding the current configuration of Magni.

Notes

The returned dictionary has a key for each of the config modules in Magni and its subpackages. The value of a given key is a dictionary with the current configuration of the corresponding config module. Furthermore, the returned dictionary has a status key, which can have either of the following values:

  • Succeeded (The entire configuration was extracted)
  • Failed (It was not possible to get information from one or more modules)
magni.reproducibility._annotation.get_magni_info()[source]

Return a string representation of the output of help(magni).

Returns:magni_info (dict) – Information about magni.

Notes

The returned dictionary has a single key:

  • help_magni (a string representation of help(magni))
magni.reproducibility._annotation.get_platform_info()[source]

Return a dictionary containing information about the system platform.

Returns:platform_info (dict) – Various information about the system platform.

See also

platform()
The Python module used to query information about the system.

Notes

The returned dictionary has the following keys:

  • system
  • node
  • release
  • version
  • processor
  • python
  • libc
  • linux
  • mac_os
  • win32
  • status

The linux/mac_os/win32 entries are “empty” if they are not applicable.

If the processor information returned by platform is “empty”, a query of lscpu is attempted in order to provide the necessary information.

The status entry informs about the success of the queries. It has one of the follwing values:

  • ‘All OK’ (everything seems to be OK)
  • ‘Used lscpu in processor query’ (lscpu was used)
  • ‘Processor query failed’ (failed to get processor information)