Source¶
Base¶
Provide a base interface for downloadable sources.
- class benchbuild.source.base.BaseSource(*args, **kwargs)[source]¶
Bases:
Expandable
,Versioned
,ContextAwareSource
,Protocol
Composition of source protocols.
- class benchbuild.source.base.ContextAwareSource(*args, **kwargs)[source]¶
Bases:
Protocol
- class benchbuild.source.base.ContextFreeMixin[source]¶
Bases:
object
Make a context-free source context-aware.
This will setup default implementations that avoids interaction with any context.
- class benchbuild.source.base.Expandable(*args, **kwargs)[source]¶
Bases:
Protocol
- property is_expandable: bool¶
Returns true, if this source should take part in version expansion.
Some sources may only be treated as virtual and would not take part in the version expansion of an associated project.
- class benchbuild.source.base.Fetchable(*args, **kwargs)[source]¶
Bases:
Protocol
- property key: str¶
Return the source’s key property.
This provides you with a key component that identifes a single source. It should (no guarantee) be unique among all sources for this project.
While this make no further assumption, but a good candidate is a file-system name/path.
- property local: str¶
The source location (path-like) after fetching it from its remote.
- property remote: str | Dict[str, str]¶
The source location in the remote location.
- class benchbuild.source.base.FetchableSource(local, remote)[source]¶
Bases:
ContextFreeMixin
Base class for fetchable sources.
- Subclasses have to provide the following protocols:
Expandable
Fetchable
Versioned
- explore()[source]¶
Explore revisions of this source.
This provides access to all revisions this source can offer. BenchBuild own filters will not block any revision here.
Custom sources or source filters can opt in to block revisions anyways.
- Returns:
The list of versions to explore.
- Return type:
List[str]
- abstract fetch()[source]¶
Fetch the necessary source files into benchbuild’s cache.
- Return type:
LocalPath
- property is_expandable: bool¶
- property key: str¶
- property local: str¶
- property remote: str | Dict[str, str]¶
- abstract version(target_dir, version)[source]¶
Fetch the requested version and place it in the target_dir
- Parameters:
target_dir (str) – The filesystem path where the version should be placed in.
version (str) – The version that should be fetched from the local cache.
- Returns:
[description]
- Return type:
str
- class benchbuild.source.base.NoSource(local, remote)[source]¶
Bases:
FetchableSource
- class benchbuild.source.base.Revision(project_cls, _primary, *variants)[source]¶
Bases:
object
A revision captures all variants that form a single project revision.
A project may have an arbitrary number of input sources that are required for it’s defined workloads, e.g., test input files, optional dependencies, or submodules.
BenchBuild considers each source to have different version numbers, encoded as “Variants”. The complete set of “Variants” for a project then forms a project revision.
- has_variant(name)[source]¶
Check if a variant with the given source name exists.
- Parameters:
name (
str
) – The local name of the source.- Return type:
bool
- Returns:
True, should a variant with the given name exists
-
project_cls:
Type
[Project]¶
- sorted()[source]¶
Return an ordered list of Variants from this revision.
The order is defined by the order in the SOURCE attribute of the associated project class.
- Return type:
Sequence
[Variant
]
- source_by_name(name)[source]¶
Return the source object that matches the key.
- Parameters:
name (
str
) – The local name of the source.- Return type:
- Returns:
the found source object
- Raises:
KeyError, if we cannot find the source with this name. –
- class benchbuild.source.base.Variant(owner, version)[source]¶
Bases:
object
Provide a ‘string’-like wrapper around source version information.
Use this, whenever you need a ‘version’ string somewhere in benchbuild. In terms of output/logging or use as program arguments, this should not carry more semantics than a simple version string.
However, this wrapper is linked to its ‘owner’. The owner serves as the back-reference to the source code where it originated from.
This can serve as a ‘hook’ to deal with version information the same way as a program variant like a specific configuraiton.
-
owner:
FetchableSource
¶
-
version:
str
¶
-
owner:
- class benchbuild.source.base.Versioned(*args, **kwargs)[source]¶
Bases:
Protocol
- benchbuild.source.base.enumerate_revisions(project_cls, context_free_enumerator=<function _default_enumerator>, context_aware_enumerator=<function _default_caw_enumerator>)[source]¶
Enumerates the given sources.
The enumeration requires two phases. 1. A phase for all sources that do not require a context to evaluate. 2. A phase for all sources that require a static context.
- Return type:
Sequence
[Revision
]
- benchbuild.source.base.primary(*sources)[source]¶
Return the implicit ‘main’ source of a project.
We define the main source as the first source listed in a project.
If you define a new project and rely on the existence of a ‘main’ source code repository, make sure to define it as the first one.
- Return type:
TypeVar
(SourceT
)
- benchbuild.source.base.product(*sources)[source]¶
Return the cross product of the given sources.
- Return type:
Iterable
[Tuple
[Variant
,...
]]- Returns:
An iterable containing the cross product of all source variants.
- benchbuild.source.base.revision_from_str(revs, project_cls)[source]¶
Create a Revision from a sequence of revision strings.
A valid Revision can only be created, if the number of valid revision strings is equivalent to the number of sources. A valid revision string is one that has been found in the a source’s version. It is required that each revision string is found in a different source version.
We assume that the first source is the primary source of the revision.
- Parameters:
revs (
Sequence
[RevisionStr
]) – sequence of revision strings, e.g. a commit-hash.*sources – sources of a project.
- Return type:
- Returns:
A variant context.
- benchbuild.source.base.secondaries(*sources)[source]¶
Return the complement to the primary source of a project.
- Return type:
Sequence
[TypeVar
(SourceT
)]- Returns:
A list of all sources not considered primary.
- benchbuild.source.base.sources_as_dict(*sources)[source]¶
Convert fetchables to a dictionary.
The dictionary will be indexed by the Fetchable’s local attribute.
Git¶
Declare a git source.
- class benchbuild.source.git.Git(remote, local, clone=True, limit=10, refspec='HEAD', shallow=True, version_filter=<function Git.<lambda>>)[source]¶
Bases:
FetchableSource
Fetch the downloadable source via git.
- fetch()[source]¶
Clone the repository, if needed.
This will create a git clone inside the global cache directory.
- Parameters:
version (Optional[str], optional) – [description]. Defaults to None.
- Returns:
[description]
- Return type:
str
- version(target_dir, version='HEAD')[source]¶
Create a new git worktree pointing to the requested version.
- Parameters:
target_dir (str) – The filesystem path where the new worktree should live.
version (str) – The desired version the new worktree needs to point to. Defaults to ‘HEAD’.
- Returns:
[description]
- Return type:
str
- class benchbuild.source.git.GitSubmodule(remote, local, clone=True, limit=10, refspec='HEAD', shallow=True, version_filter=<function Git.<lambda>>)[source]¶
Bases:
Git
- property is_expandable: bool¶
Submodules will not participate in version expansion.
HTTP¶
Declare a http source.
- class benchbuild.source.http.HTTP(local, remote)[source]¶
Bases:
FetchableSource
Fetch the downloadable source via http.
- fetch_version(version)[source]¶
Fetch via http using given version string.
- Parameters:
version (
str
) – the version string to pull via http.- Return type:
LocalPath
- Returns:
local path to fetched version.
- class benchbuild.source.http.HTTPMultiple(local, remote, files)[source]¶
Bases:
HTTP
Fetch and download multiple files via HTTP.
- class benchbuild.source.http.HTTPUntar(local, remote)[source]¶
Bases:
HTTP
Fetch and download source via http and auto-unpack using GNU tar
- version(target_dir, version)[source]¶
Setup the given version of this HTTPUntar source.
This will fetch the given version from the remote source and unpack the archive into the build directory using tar.
The location matches the behavior of other sources. However, you need to consider that benchbuild will return a directory instead of a file path.
When using workloads, you can refer to a directory with the SourceRootRenderer using
benchbuild.command.source_root
. :rtype:LocalPath
Example
You specify a remote version 1.0 of an archive compression.tar.gz and a local name of “compression.tar.gz”. The build directory will look as follows:
<builddir>/1.0-compression.dir/ <builddir>/1.0-compression.tar.gz <builddir>/compression.tar.gz -> ./1.0-compression.tar.dir
The content of the archive is found in the directory compression.tar.gz. Your workloads need to make sure to reference this directory (e.g. using tokens), e.g.,
source_root("compression.tar.gz")
RSync¶
Module: source¶
Declarative API for downloading sources required by benchbuild.