pcvs.orchestration.publishers module
- class pcvs.orchestration.publishers.BuildDirectoryManager(build_dir='.')[source]
Bases:
object
This class is intended to serve a build directory from a single entry point. Any module requiring to deal with resources from a run should be compliant with this interface. It provides basic mechanism to load/save any past, present or future executions.
- clean(*args)[source]
Prepare the build directory for a new execution by removing anything not relevant for a new run.
Please not this function will erase anything not relative to PCVS. As an argument, one may specify a specific prefix to be removed. Paths should relative to root build directory.
- Return type:
- clean_archives()[source]
Prepare the build directory for a new execution by moving any previous archive to the backup directory named after NAME_BUILD_ARCHIVE_DIR.
- Return type:
- property config: MetaConfig
Return the configuation associated with the current build directory
- Returns:
config struct
- Return type:
class:MetaConfig
- create_archive(timestamp=None)[source]
Generate an archive for the build directory.
This archive will be stored in the root directory..
- Parameters:
timestamp (Datetime, optional) – file suffix, defaults to current timestamp
- Returns:
the archive path name
- Return type:
- finalize()[source]
Close & release the current instance.
It should not be used to save tests after this call.
- get_config()[source]
Return the loaded configuration for the current build directory.
- Returns:
a dict representantion of yaml config
- Return type:
- init_results(per_file_max_sz=0)[source]
Initialize the result handler.
This function is not called directly from the __init__ method as this isntance may be used for both reading & writing into the destination directory. This function implies storing a new execution.
- Parameters:
per_file_max_sz (int, optional) – max file size, defaults to unlimited
- load_config()[source]
Load config stored onto disk & populate the current instance.
- Returns:
the loaded config
- Return type:
class:MetaConfig
- classmethod load_from_archive(archive_path)[source]
Populate the instance from an archive.
This object is initially built to load data from a build directory. This way, the object is mapped with an existing archive.
Warning
This method does not support (yet) to save tests after an archive has been loaded (as no output directory has been configured).
- Parameters:
archive_path (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- prepare(reuse=False)[source]
Prepare the dir for a new run.
This function is not included as part of the __init__ function as this instance may be used both for reading & writing into the destination directory. This function implies all previous results be be cleared off.
- Parameters:
reuse (bool, optional) – keep previously generated YAML test-files, defaults to False
- property results
Getter to the result handler, for direct access
- Returns:
the result handler
- Return type:
class:ResultFileManager
- save_config(config)[source]
Save the config & store it directly into the build directory.
- Parameters:
config (class:MetaConfig) – config
- Return type:
- save_extras(rel_filename, data='', dir=False, export=False)[source]
Register a specific build-relative path, to be saved into the directory.
The only entry-point to save a resource into it. Resources can be files (with or without content) or directory.
If export is set to True, resource (file or whole directory) will also be copied to the final archive.
- Parameters:
- Return type:
- property scratch_location
Returns where third-party artifacts must be stored
- Returns:
the scratch directory
- Return type:
- class pcvs.orchestration.publishers.ResultFile(filepath, filename)[source]
Bases:
object
A instance manages a pair of file dedicated to load/store PCVS job results on disk.
A job result is stored in two different files whens given to a single ResultFile: * <prefix>.json, containing metadata (rc, command…) * <prefix>.bz2 BZ2-compressed job data.
a MAGIC_TOKEN is used to detect file/data corruption.
- MAGIC_TOKEN = 'PCVS-START-RAW-OUTPUT'
- property content
- property metadata_prefix
Getter to the actual metadata file name
- Returns:
filename
- Return type:
- retrieve_test(id=None, name=None)[source]
Find jobs based on its id or name and return associated Test object.
Only id OR name should be set (not both). To handle multiple matches, this function returns a list of class:Test.
- class pcvs.orchestration.publishers.ResultFileManager(prefix='.', per_file_max_ent=0, per_file_max_sz=0)[source]
Bases:
object
Manages multiple class:ResultFile. Main purpose is to manage files to ensure files stored on disk remain consistent.
- browse_tests()[source]
Iterate over every job stored into this build directory.
- Returns:
an iterable of Tests
- Return type:
List of tests
- Yield:
Test
- Return type:
Iterator[Test]
- build_bidir_map_data()[source]
Rebuild global views from partial storage on disk.
For optimization reasons, information that may be rebuilt are not stored on disk to save space.
- Return type:
- file_format = 'jobs-{}'
- finalize()[source]
Flush & close the current manager.
This instance should not be used again after this call.
- increment = 0
- map_id(id)[source]
Comnvert a job ID into its class:Test representation.
- Parameters:
id (int) – job id
- Returns:
the associated Test object or None if not found
- Return type:
class:Test or None
- property maps
Returns available views from the current instance.
- Returns:
the maps
- Return type:
- retrieve_test(id)[source]
Build the Test object mapped to the given job id.
If such ID does not exist, it will return None.
- Parameters:
id (_type_) – _description_
- Returns:
_description_
- Return type:
List[Test]
- retrieve_tests_by_name(name)[source]
Locate a test by its name.
As multiple matches could occur, this function return a list of class:Test
- save(job)[source]
Add a new job to be saved to the result directory.
May not be flushed righ away to disk, some caching may be used to improve performance. While adding the Test to low-level manager, this function also updates view & maps accordingly.
- Parameters:
job (class:Test) – the job element to store
- subtree_view(subtree)[source]
Get a subset of the ‘tree’ view. Any LABEL/subtree combination is valid.
- property total_cnt
Returns the total number of jobs from that directory (=run).
- Returns:
number of jobs
- Return type: