fab.artefacts module#

This module contains Artefacts Getter classes which return Artefact Collections from the Artefact Store.

These classes are used by the run method of Step classes to retrieve the artefacts which need to be processed. Most steps have sensible defaults and can be configured with user-defined getters.

class fab.artefacts.ArtefactStore#

Bases: dict

This object stores artefacts (which can be of any type). Each artefact is indexed by a string.

reset()#

Clears the artefact store (but does not delete any files).

class fab.artefacts.ArtefactsGetter#

Bases: ABC

Abstract base class for artefact getters.

class fab.artefacts.CollectionGetter(collection_name)#

Bases: ArtefactsGetter

A simple artefact getter which returns one Artefact Collection from the artefact_store.

Example:

`CollectionGetter('preprocessed_fortran')`
Parameters:

collection_name – The name of the artefact collection to retrieve.

class fab.artefacts.CollectionConcat(collections)#

Bases: ArtefactsGetter

Returns a concatenated list from multiple Artefact Collections (each expected to be an iterable).

An ArtefactsGetter can be provided instead of a collection_name.

Example:

# The default source code getter for the Analyse step might look like this.
DEFAULT_SOURCE_GETTER = CollectionConcat([
    'preprocessed_c',
    'preprocessed_fortran',
    SuffixFilter('all_source', '.f90'),
])
Parameters:

collections (Iterable[Union[str, ArtefactsGetter]]) – An iterable containing collection names (strings) or other ArtefactsGetters.

class fab.artefacts.SuffixFilter(collection_name, suffix)#

Bases: ArtefactsGetter

Returns the file paths in a Artefact Collection (expected to be an iterable), filtered by suffix.

Example:

# The default source getter for the FortranPreProcessor step.
DEFAULT_SOURCE = SuffixFilter('all_source', '.F90')
Parameters:
  • collection_name (str) – The name of the artefact collection.

  • suffix (Union[str, List[str]]) – A suffix string including the dot, or iterable of.

class fab.artefacts.FilterBuildTrees(suffix, collection_name='build trees')#

Bases: ArtefactsGetter

Filter build trees by suffix.

Returns one list of files to compile per build tree, of the form Dict[name, List[AnalysedDependent]]

Example:

# The default source getter for the CompileFortran step.
DEFAULT_SOURCE_GETTER = FilterBuildTrees(suffix='.f90')
Parameters:
  • suffix (Union[str, List[str]]) – A suffix string, or iterable of, including the preceding dot.

  • collection_name (str) – The name of the artefact collection where we find the source trees. Defaults to the value in fab.constants.BUILD_TREES. (default: 'build trees')