memote.suite.results

Provide the memote result object and managers for various situations.

  • The MemoteResult represents the collective result of running the metabolic model test suite on a given model at a certain point in time.
  • The ResultManager and its subclasses knows how to store a MemoteResult in various data backends (file, SQL, NoSQL).
  • The ResultHistoryManager uses the different ResultManagers to iterate over and collect a model’s test result history.

Package Contents

Classes

MemoteResult Collect the metabolic model test suite results.
ResultManager Manage storage of results to JSON files.
RepoResultManager Manage storage of results to JSON files.
SQLResultManager Manage storage of results to a database.
HistoryManager Manage access to results in the commit history of a git repository.
class memote.suite.results.MemoteResult(*args, **kwargs)[source]

Bases: dict

Collect the metabolic model test suite results.

static add_environment_information(meta)

Record environment information.

class memote.suite.results.ResultManager(**kwargs)[source]

Bases: object

Manage storage of results to JSON files.

store(self, result, filename, pretty=True)

Write a result to the given file.

Parameters:
result : memote.MemoteResult

The dictionary structure of results.

filename : str or pathlib.Path

Store results directly to the given filename.

pretty : bool, optional

Whether (default) or not to write JSON in a more legible format.

load(self, filename)

Load a result from the given JSON file.

class memote.suite.results.RepoResultManager(repository, location, **kwargs)[source]

Bases: memote.suite.results.result_manager.ResultManager

Manage storage of results to JSON files.

Results are stored to and loaded from a specific location (directory) and enriched with git commit meta information.

record_git_info(self, commit=None)

Record git meta information.

Parameters:
commit : str, optional

Unique hexsha of the desired commit.

Returns:
GitInfo

Git commit meta information.

get_filename(self, git_info)

Create a filename from the storage directory and the commit hash.

Parameters:
git_info : GitInfo

A named tuple with git meta information.

Returns:
str

The path to the file where the result of the current commit is stored.

static add_git(meta, git_info)

Enrich the result meta information with commit data.

store(self, result, commit=None, **kwargs)

Store a result in a JSON file attaching git meta information.

Parameters:
result : memote.MemoteResult

The dictionary structure of results.

commit : str, optional

Unique hexsha of the desired commit.

kwargs

Passed to parent function.

load(self, commit=None)

Load a result from the storage directory.

class memote.suite.results.SQLResultManager(**kwargs)[source]

Bases: memote.suite.results.repo_result_manager.RepoResultManager

Manage storage of results to a database.

store(self, result, commit=None, **kwargs)

Store a result in a JSON file attaching git meta information.

Parameters:
result : memote.MemoteResult

The dictionary structure of results.

commit : str, optional

Unique hexsha of the desired commit.

kwargs

Passed to parent function.

load(self, commit=None)

Load a result from the database.

class memote.suite.results.HistoryManager(repository, manager, **kwargs)[source]

Bases: object

Manage access to results in the commit history of a git repository.

Attributes:
manager : memote.RepoResultManager

The manager for accessing individual results.

current : str

The name of the currently active branch.

build_branch_structure(self, model, skip)

Inspect and record the repo’s branches and their history.

iter_branches(self)

Iterate over branch names and their commit histories.

iter_commits(self)

Iterate over all commit hashes in the repository.

load_history(self, model, skip=('gh-pages', ))

Load the entire results history into memory.

Could be a bad idea in a far future.

get_result(self, commit, default=None)

Return an individual result from the history if it exists.

__contains__(self, commit)

Test for the existence of a result for a commit.