fm_weck package

Subpackages

Submodules

fm_weck.cache_mgr module

fm_weck.cache_mgr.ask_and_clear(cache_location: str)[source]
fm_weck.cache_mgr.clear_cache(cache_location: str)[source]

fm_weck.capture module

class fm_weck.capture.Capture(target: TextIOBase, stream: Literal['stdout', 'stderr', 'stdin'] = 'stdout')[source]

Bases: object

fm_weck.cli module

class fm_weck.cli.ShellCompletion[source]

Bases: object

static properties_completer(prefix, parsed_args, **kwargs)[source]
static tool_completer(prefix, parsed_args, **kwargs)[source]
static versions_completer(prefix, parsed_args, **kwargs)[source]
class fm_weck.cli.ToolQualifier(qualifier: str)[source]

Bases: object

tool: str | Path
version: str | None
fm_weck.cli.add_shared_args_for_client(parser)[source]
fm_weck.cli.add_shared_args_for_run_modes(parser)[source]
fm_weck.cli.add_shared_args_for_zenodo_modes(parser)[source]
fm_weck.cli.add_tool_arg(parser, nargs: str | None = '?')[source]
fm_weck.cli.check_client_options(timelimit_arg, output_path=None)[source]
fm_weck.cli.cli(raw_args: list[str])[source]
fm_weck.cli.get_version_for_competition_year(tool_path: Path, year: int) str | None[source]

Find the tool version used in a competition for the given year. Searches for SV-COMP or Test-Comp participation entries.

Parameters:
  • tool_path – Path to the tool’s YAML file

  • year – Competition year (e.g., 2025)

Returns:

Version string if found, None otherwise

fm_weck.cli.list_known_properties()[source]
fm_weck.cli.list_known_tools()[source]
fm_weck.cli.log_no_image_error(tool, config)[source]
fm_weck.cli.main_clear_cache(args: Namespace)[source]
fm_weck.cli.main_client(args: Namespace)[source]
fm_weck.cli.main_client_expert(args: Namespace)[source]
fm_weck.cli.main_client_get_run(args: Namespace)[source]
fm_weck.cli.main_client_query_files(args: Namespace)[source]
fm_weck.cli.main_config(args: Namespace)[source]
fm_weck.cli.main_install(args: Namespace)[source]
fm_weck.cli.main_manual(args: Namespace)[source]
fm_weck.cli.main_publish(args: Namespace)[source]
fm_weck.cli.main_pull(args: Namespace)[source]
fm_weck.cli.main_push(args: Namespace)[source]
fm_weck.cli.main_run(args: Namespace)[source]
fm_weck.cli.main_runexec(args: Namespace)[source]
fm_weck.cli.main_server(args: Namespace)[source]
fm_weck.cli.main_shell(args: Namespace)[source]
fm_weck.cli.main_smoke_test(args: Namespace)[source]
fm_weck.cli.main_versions(args: Namespace)[source]
fm_weck.cli.parse(raw_args: list[str]) Tuple[Callable[[], None], Namespace][source]
fm_weck.cli.resolve_property(prop_name: str) Path[source]
fm_weck.cli.resolve_property_for_server(prop_name: str) Path | str[source]
fm_weck.cli.resolve_tool(tool: ToolQualifier) Path[source]
fm_weck.cli.set_log_options(loglevel: str | None, logfile: str | None, config: dict[str, Any])[source]

fm_weck.config module

class fm_weck.config.Config[source]

Bases: object

The config singleton holds the configuration for the weck tool.

as_absolute_path(*args, **kwargs) Path[source]

Makes sure relative Paths in the config are relative to the config file.

property cache_location: Path

Makes sure relative Paths in the config are relative to the config file.

defaults() dict[str, Any][source]
from_defaults_or_none(key: str) Any[source]
get(key: str, default: _T = None) _T[source]
get_checksum_db() Path[source]
get_shelve_path_for_benchexec() Path[source]
get_shelve_path_for_property(path: Path) Path[source]
get_shelve_space_for(fm_data: FmToolVersion) Path[source]
is_dry_run() bool[source]
load(config: Path | None = None) dict[str, Any][source]
make_script_available(target_name: str = 'run_with_overlay.sh') Path | None[source]
mounts() Iterable[Tuple[Path, Path]][source]
set_default_image(image: str) None[source]
set_dry_run(dry_run: bool) None[source]
fm_weck.config.parse_fm_data(fm_data: Path, version: str | None) FmToolVersion[source]

fm_weck.engine module

class fm_weck.engine.Docker(image: str | FmImageConfig)[source]

Bases: Engine

class DockerBuildCommand(containerfile: Path, needs_sudo: bool = False)[source]

Bases: BuildCommand

engine()[source]
base_command()[source]
benchexec_capabilities()[source]
image_from(containerfile: Path)[source]
setup_command()[source]
class fm_weck.engine.Engine(image: str | FmImageConfig)[source]

Bases: ABC

class BuildCommand(containerfile: Path, **kwargs)[source]

Bases: ABC

base_image(image: str)[source]
build()[source]
build_args: List[str] = []
containerfile: Path
engine()[source]
inspect_image(image: str)[source]
load_image(image: str | Path)[source]
packages(packages: Iterable[str])[source]
save_image(image: str, output_path: Path)[source]
tag_exists(tag: str) bool[source]
tag_image(image: str, tag: str)[source]
add_benchexec_capabilities: bool = False
add_container_long_opt(arg: list[str])[source]

Add a long option to the container command. If the first element of the list does not start with “–”, it will be prepended. Example: add_container_long_opt([”–option”, “value”]) -> –option value add_container_long_opt([“option”, “value”]) -> –option value

add_environment()[source]
add_mounting_capabilities: bool = True
assemble_command(command: Iterable[str]) list[str][source]
assemble_smoke_test_command(command: list[str | Path]) list[str | Path][source]
base_command()[source]
abstractmethod benchexec_capabilities()[source]
dry_run: bool = False
static extract_image(fm: str | Path, version: str, config: dict) str[source]
from_config() Engine[source]
from_config(fm: Path, version: str, config: Config)
from_config(fm: str, version: str, config: Config)
from_config(fm: FmToolVersion, config: Config)
get_workdir() str[source]
handle_io: bool = True
image: str | None = None
abstractmethod image_from(containerfile: Path) BuildCommand[source]
interactive: bool = False
interactive_command()[source]
mount(source: str, target: str)[source]
mounting_capabilities()[source]
overlay_tool_dir: str | None = None
print_output_to_stdout: bool = True
run(*command: str, timeout_sec: float | None = None) RunResult[source]
set_log_file(log_file: Path)[source]
set_output_dir(output_dir: Path)[source]
setup_command()[source]
use_overlay(overlay_dir: str)[source]
work_dir: Path = PosixPath('/home/cwd')
class fm_weck.engine.Podman(image: str | FmImageConfig)[source]

Bases: Engine

class PodmanBuildCommand(containerfile: Path)[source]

Bases: BuildCommand

benchexec_capabilities()[source]
image_from(containerfile: Path)[source]
class fm_weck.engine.Runexec(image: str | FmImageConfig)[source]

Bases: Engine

base_command()[source]
benchexec_capabilities()[source]
image_from(containerfile: Path)[source]
run(*command, timeout_sec: float | None = None) RunResult[source]
setup_command()[source]

fm_weck.exceptions module

class fm_weck.exceptions.Failure(kind: str, message: str, detail: str | None = None)[source]

Bases: object

detail: str | None = None
kind: str
message: str
exception fm_weck.exceptions.NoImageError[source]

Bases: Exception

exception fm_weck.exceptions.RunFailedError(exit_code, command, output=None)[source]

Bases: Exception

exception fm_weck.exceptions.ZenodoError[source]

Bases: Exception

fm_weck.exceptions.failure_from_exception(e: BaseException) Failure[source]
fm_weck.exceptions.failure_to_error_code(failure: Failure)[source]

fm_weck.file_util module

fm_weck.file_util.copy_ensuring_unix_line_endings(src: Path, dst: Path) None[source]
fm_weck.file_util.ensure_linux_style(path: str) str[source]

Ensure that the given path uses Linux-style forward slashes.

fm_weck.image_mgr module

class fm_weck.image_mgr.ImageMgr[source]

Bases: object

The image manager singleton is responsible for preparing the images for the container.

check_if_doi_exists_locally(engine: Engine, doi: str) str[source]

Check if an image tagged with the given DOI already exists locally.

Returns:

The DOI if it does not exist locally, otherwise empty string.

load_image(engine: Engine, image_tar: Path, tag: str | None = None) None[source]
prepare_image(engine: Engine, image: FmImageConfig) str[source]
prepare_image_for_zenodo(engine: Engine, image_name: str) tuple[str, str, Path][source]

Prepare an image for Zenodo upload, by retreiving the image tarball.

Returns:

A tuple containing the normalized image name and tarball path.

Raises:

ValueError – If the image is invalid or does not exist.

static print_dockerfile_warning()[source]
tag_image(engine: Engine, image: str, tag: str) None[source]

fm_weck.run_result module

class fm_weck.run_result.RunResult(command: tuple[str, ...] | list[str], exit_code: int, raw_output: str)[source]

Bases: object

as_benchexec_run()[source]
command: tuple[str, ...] | list[str]
determine_result(tool: BaseTool2 | FmToolVersion) str[source]
exit_code: int
raw_output: str

fm_weck.runexec_mode module

fm_weck.runexec_mode.run_runexec(benchexec_package: Path | None, use_image: str | None, configuration: Config, extra_container_args: list[list[str]], command: list[str], mount_rw: list[Path] | None = None) RunResult | None[source]

fm_weck.runexec_util module

fm_weck.runexec_util.mountable_absolute_paths_of_command(cwd: Path, command: List[str]) Iterable[Path][source]

Iterate over all arguments in command and find those that are paths. The paths are returned as absolute paths, that already exist on the host.

fm_weck.serve module

fm_weck.serve.check_cache_entry(shelve_space: Path, checksum: str, config: Config) bool[source]
fm_weck.serve.install_fm_tool(fm_tool: Path | FmToolVersion, version: str | None, configuration: Config, install_path: Path) None[source]
fm_weck.serve.map_doi(fm_data: FmToolVersion, tool_path: Path)[source]
fm_weck.serve.run_guided(fm_tool: Path | FmToolVersion, version: str | None, configuration: Config, prop: Path | None, program_files: list[Path], additional_args: list[str], witness: Path | None = None, data_model: DataModel | None = None, offline_mode: bool = False, log_output_to: Path | None = None, output_files_to: Path | None = None, timeout_sec: float | None = None, print_tool_output_to_console: bool = True) RunResult[source]
fm_weck.serve.run_manual(fm_tool: Path | FmToolVersion, version: str | None, configuration: Config, command: list[str], offline_mode: bool = False, use_overlay: bool = False, log_output_to: Path | None = None, output_files_to: Path | None = None, timeout_sec: float | None = None, print_tool_output_to_console: bool = True) RunResult[source]
fm_weck.serve.setup_fm_tool(fm_tool: Path | FmToolVersion, version: str | None, configuration: Config, offline_mode: bool = False) Tuple[FmToolVersion, Path][source]
fm_weck.serve.update_checksum(shelve_space: Path, checksum: str, config: Config)[source]

fm_weck.smoke_test_mode module

exception fm_weck.smoke_test_mode.NoSmokeTestFileError[source]

Bases: SmokeTestError

Exception raised when no smoke test file is found.

exception fm_weck.smoke_test_mode.SmokeTestError[source]

Bases: Exception

Custom exception for smoke test errors.

exception fm_weck.smoke_test_mode.SmokeTestFileIsEmptyError[source]

Bases: SmokeTestError

Exception raised when the smoke test file is empty.

exception fm_weck.smoke_test_mode.SmokeTestFileIsNotExecutableError(smoke_test_file: Path)[source]

Bases: SmokeTestError

Exception raised when the smoke test file is not executable.

smoke_test_file: Path
fm_weck.smoke_test_mode.locate_and_check_smoke_test_file(shelve_space: Path) str[source]

Check if the smoke test file exists, is executable, and is not empty.

Parameters:

shelve_space – Path to the shelve space directory.

Returns:

The relative path to the smoke test file as a string.

Raises:
fm_weck.smoke_test_mode.run_smoke_test(fm_data, shelve_space, config)[source]
fm_weck.smoke_test_mode.run_smoke_test_gitlab_ci(fm_data: FmToolVersion, tool_dir: Path)[source]

Run smoke test in GitLab CI mode. This mode directly installs required packages using apt instead of building/pulling images.

Parameters:
  • fm_data – The FmToolVersion object containing tool information

  • tool_dir – The directory containing the tool’s smoketest.sh script

fm_weck.tmp_file module

class fm_weck.tmp_file.NTempFile(name, mode='wb')[source]

Bases: object

Custom temporary file context manager. It creates a temporary file and deletes it after the context manager is closed. The file is not kept open in order to achieve compatibility with Windows.

Inspired by https://stackoverflow.com/a/63173312

write(data)[source]

Write data to the temporary file.

fm_weck.version_listing module

class fm_weck.version_listing.VersionListing(tool_paths: list)[source]

Bases: object

print_versions()[source]
tool_and_version: dict[str, list] = {}

fm_weck.zenodo module

class fm_weck.zenodo.TokenAuth(token: str)[source]

Bases: Auth

auth_flow(request)[source]

Execute the authentication flow.

To dispatch a request, yield it:

` yield request `

The client will .send() the response back into the flow generator. You can access it like so:

` response = yield request `

A return (or reaching the end of the generator) will result in the client returning the last response obtained from the server.

You can dispatch as many requests as is necessary.

class fm_weck.zenodo.ZenodoMgr(engine, access_token: str | None, image: str | None, doi: str | None, is_sandbox: bool = False, config: Config | None = None)[source]

Bases: object

Zenodo API manager.

Parameters:
  • engine (object) – The fm-weck engine object.

  • access_token (str, optional) – The access token for authentication with the API. Defaults to None.

  • image (str, optional) – The image to be published. Required if no doi is given. Defaults to None.

  • doi (str, optional) – The DOI of the image to be pulled. Required if no image is given. Defaults to None.

Raises:

ValueError – If a chosen image is invalid or does not exist.

static load_zenodo_token(config)[source]

Load the Zenodo token from the Zenodo config file.

Raises:

ZenodoError – If no Zenodo token is found.

publish()[source]

Publish an image on Zenodo.

Raises:

ZenodoError – If Zenodo API returns an error.

pull(download_path: str | None, force_pull: bool = False)[source]

Download an image from Zenodo using its DOI.

Raises:
  • ValueError – If no DOI is provided.

  • ZenodoError – If Zenodo API returns an error.

push()[source]

Upload an image to Zenodo and leave it in draft mode (unpublished).

Raises:

ZenodoError – If Zenodo API returns an error.

static save_zenodo_token(config, token)[source]
class fm_weck.zenodo.ZenodoSession(access_token: str | None = None, is_sandbox: bool = False)[source]

Bases: object

check_existing_records(metadata: dict)[source]

Check if a record with the same name already exists in the depositions. If it exists, prompt whether the image should be uploaded as a new version.

Returns:

The deposition ID in case of a positive prompt response, or an empty string.

delete_deposition(deposition_id: str)[source]
download(doi: str, download_path: str | None, no_progress_bar: bool = False) Path[source]

Download an image from Zenodo using its DOI.

download_with_progress_bar(url: str)[source]
get_upload_metadata(image_name: str, image_version: str) dict[source]
prepare_new_version_upload(metadata: dict, deposition_id: str) None[source]

Set up the metadata for the new version and delete the old versions’ files from that version.

publish(image_info: tuple)[source]

Publish an image on Zenodo.

resolve_download_info(doi: str) str[source]

Extract the download URL from the deposition metadata.

Returns:

The download URL of the image.

save_image(image_name: str, image: bytes, save_path)[source]
upload(image_info: tuple[str, str, Path]) str[source]

Upload an image to Zenodo and leave it in draft mode (unpublished).

upload_with_progress_bar(image_path, upload_name, bucket_url)[source]

Module contents