pcvs.backend.bank module

pcvs.backend.bank.BANKS: Dict[str, str] = {}
Variables

BANKS – list of available banks when PCVS starts up

class pcvs.backend.bank.Bank(path: Optional[str] = None, token: str = '')[source]

Bases: object

Representation of a PCVS result datastore.

Stored as a Git repo, a bank hold multiple results to be scanned and used to analyse benchmarks result over time. A single bank can manipulate namespaces (referred as ‘projects’). The namespace is provided by suffixing @proj to the original name.

Parameters
  • root (str) – the root bank directory

  • repo (Pygit2.Repository) – the Pygit2 handle

  • config (MetaDict) – when set, configuration file of the just-submitted archive

  • rootree (Pygit2.Object) – When set, root handler to the next commit to insert

  • locked (bool) – Serialize Bank manipulation among multiple processes

  • preferred_proj (str) – extracted default-proj from initial token

connect_repository() None[source]

Connect to the bank repo, making it exclusive to the current process.

Two scenarios:
  • the path is empty -> create a new bank

  • the path is not empty -> detect a bank repo.

In any cases, lock the directory to prevent multiple accesses.

Raises
create_test_blob(data: str) Object[source]

Create a small hashed object, to be stored into a bank.

Parameters
  • data – any type of data to be stored. In PCVS context, it is mainly json-formatted strings.

  • data – str

Returns

the pygit2-hashed representation id

Return type

pygit2.Object

disconnect_repository() None[source]

Free the bank repo, to be reused by other instance.

exists() bool[source]

Check if the bank is stored in PATH_BANK file.

Verification is made either on name or path.

Returns

True if both the bank exist and globally registered

Return type

bool

extract_data(key, start, end, format)[source]

Extract information from the bank given specifications.

Note

This function is still WIP.

Parameters
  • key (str) – the requested key

  • start (date) – start time

  • end (date) – end time

  • format (Not relevant yet) – Not relevant yet

Raises

ProjectNameError – Targeted project does not exist

finalize_snapshot(tag: str) None[source]

Finalize result submission into the bank.

After walking through build directory, finalize the Git tree to insert a commit on top of the created tree.

Parameters

tag (str) – overridable default project (if different)

insert(treebuild: TreeBuilder, path: List[str], obj: any) Object[source]

Associate an object to a given tag (=path).

The result is stored into the parent subtree (treebuild). The path is an array of subrefixes, identifying the subtree where the object will be stored under the bank. This function associates the path & the object together, write the result in the parent and returns its Oid.

This function is called recursively to build the whole tree. The stop condition is when the function reaches the file (=basename), which create the real blob object.

Parameters
  • treebuild (Pygit2.TreeBuilder) – the parent Oid where this association will be stored

  • path (list of str) – the subpath where to store the object

  • obj (any) – the actual data to store

Returns

the actual parent id

Return type

Pygit2.Oid

list_projects() List[str][source]

Given the bank, list projects with at least one run.

In a bank, each branch is a project, just list available branches. master branch is not a valid project.

Returns

A list of available projects

Return type

list of str

load_config_from_file(path: str) None[source]

Load the configuration file associated with the archive to process.

Parameters

path (str) – the configuration file path

load_config_from_str(s: str) None[source]

Load the configuration data associated with the archive to process.

Parameters

s (str) – the configuration data

property name: str

Get bank name.

Returns

the exact label (without default-project suffix)

Return type

str

name_exist() bool[source]

Check if the bank name is registered into PATH_BANK file.

Returns

True if the name (lowered) is in the keys()

Return type

bool

path_exist() bool[source]

Check if the bank path is registered into PATH_BANK file.

Returns

True if the path is known.

Return type

bool

property preferred_proj: Optional[str]

Get default-project tag.

Returns

the exact project (without bank label prefix)

Return type

str

property prefix: Optional[str]

Get path to bank directory.

Returns

absolute path to directory

Return type

str

save_from_archive(tag: str, archivepath: str) None[source]

Extract results from the archive, if used to export results.

This is basically the same as BanK.save_from_buildir() except the archive is extracted first.

Parameters
  • tag (str) – overridable default project (if different)

  • archivepath (str) – archive path

save_from_buildir(tag: str, buildpath: str) None[source]

Extract results from the given build directory & store into the bank.

Parameters
  • tag (str) – overridable default project (if different)

  • buildpath (str) – the directory where PCVS stored results

save_test_from_json(jtest: str) Object[source]

Store data to a bank directly from JSON representation.

This is mainly used when a bank is directly connected to a run instance, not intermediate file is required.

Parameters

jtest (str) – the JSON-formatted test result

Returns

the blob object id

Return type

Pygit2.Oid

save_to_global() None[source]

Store the current bank into PATH_BANK file.

show() None[source]

Print the bank on stdout.

Note

This function does not use log.IOManager

Store a new bank to the global system.

Parameters
  • name (str) – bank label

  • path (str) – path to bank directory

pcvs.backend.bank.flush_to_disk() None[source]

Update the PATH_BANK file with in-memory object.

Raises

IOError – Unable to properly manipulate the tree layout

pcvs.backend.bank.init() None[source]

Bank interface detection.

Called when program initializes. Detects defined banks in PATH_BANK

pcvs.backend.bank.list_banks() dict[source]

Accessor to bank dict (outside of this module).

Returns

dict of available banks.

Return type

dict

Remove a bank from the global management system.

Parameters

name (str) – bank name