Skip to main content

semantic-benchmark

Reusable Python helpers for semantic benchmark descriptions, main RO-Crate creation, and RoHub provenance workflows.

Install

pip install semantic-benchmark

Install optional features with extras:

pip install "semantic-benchmark[rocrate]"
pip install "semantic-benchmark[rohub]"
pip install "semantic-benchmark[all]"

To install the latest unreleased version directly from GitHub:

pip install "semantic-benchmark[all] @ git+https://github.com/Simulation-Benchmarks/semantic-benchmark.git"

Provided Modules

  • semantic_benchmark.semantics: dataclasses and BenchmarkLoader for JSON-LD benchmark descriptions.
  • semantic_benchmark.rohub: RoHub configuration, upload, download, annotation, and query helpers.
  • semantic_benchmark.rocrate: main RO-Crate creation and validation helpers.
  • semantic_benchmark.runner: shared parameter-file, workspace, resource staging, archive, logging, and main RO-Crate helpers for project benchmark runners.

semantic_benchmark.semantics is available from the base installation. semantic_benchmark.rocrate requires the rocrate extra. semantic_benchmark.rohub requires the rohub extra.

The root semantic_benchmark package re-exports the semantic classes for backwards compatibility. The legacy semantic_benchmark.semantic module also remains as a compatibility shim.

Loaded numerical variables and parameters expose both unit (the original JSON-LD value) and unit_iri (the full IRI expanded through the document's namespace bindings). Consumers should use unit_iri when creating links.

semantic_benchmark.rohub.download_benchmark_resources(...) downloads the requested benchmark resources from a RoHub research object. The semantic file is selected from the Annotation Collection resource in list_resources(). Passing path="benchmark" (CLI: --path benchmark) exports the complete research object using ros_export_to_rocrate(..., use_format="zip") and extracts its contents directly into benchmark/. If path / --path is omitted, the crate is extracted into the current directory. The directory is created if needed, and the temporary ZIP is removed afterward. The returned mapping contains the research object identifier under RO-Crate and the annotation resource identifier under Annotation Collection for the requested downloads. The package also exposes the download-semantic-benchmark CLI.

upload-semantic-benchmark calls upload_provenance_rocrate(...) directly. It accepts --provenance_folderpath (the RO-Crate ZIP), --benchmark-name, --username, --password, and optional --code-repository-url and --use-production-rohub arguments. The software URL and version are read from the SoftwareApplication node in the RO-Crate ZIP.

semantic_benchmark.rocrate.create_main_ro(...) always validates the generated main crate against workflow-run-crate-0.5. The package writes the RO-Crate zip, unpacks it to a validation directory, and runs validate_rocrate(...). Main creation requires subcrate_paths, the exact reporter RO-Crate ZIPs from completed runs, and workflow_path, a YAML file used as the main workflow. The CLI accepts --workflow-path and one --subcrate-path per run. Each subcrate is the result of a CreateAction whose instrument is the YAML workflow; matched configuration values are action inputs and extracted metrics are action results. Main crate metadata comes from a YAML profile. --profile takes the exact YAML file path. Use --profile with the CLI, or pass main_profile to runner.prepare_benchmark(...). The returned benchmark object exposes the loaded values in benchmark.main_profile; pass that object to runner.create_main_rocrate(...).

benchmark = runner.prepare_benchmark(
    benchmark_file, benchmark_dir, unit_symbols,
    main_profile=benchmark_dir.parent / "provenance" / "profiles" / "main-rocrate-fenics.yml",
)
software_version = benchmark.main_profile.software_version

For a subcrate reporter invocation, use runner.build_subcrate_args(path_to_sub_crate_yml) to convert the YAML settings to Snakemake command-line arguments. The supplied path is used exactly.

For example, provenance/profiles/main-rocrate-fenics.yml may contain:

software-name: "FEniCS"
software-version: "0.9.0"
software-url: "https://zbmath.org/software/4314"
crate-license: "https://opensource.org/licenses/MIT"
agent-name: "Example Author"
agent-orcid: "https://orcid.org/0000-0000-0000-0000"
crate-name: "Plate benchmark provenance"
crate-description: "Provenance run of the plate benchmark"

The crate description is read directly from crate-description. The workflow path and the completed subcrate paths remain run-specific arguments.

Repository-specific projects can override the packaged RoHub defaults with:

import semantic_benchmark.rohub as rohub

rohub.configure_repository_settings(
    rohub_config={...},
)

Parameter sweeps with JSON-LD arrays

A parameter's has numerical value or has string value may be a scalar or an array of alternatives. For example, reference both of these nodes from the same parameter set's has part property:

[
  {
    "@id": "local:cell_type",
    "label": "cell_type",
    "has string value": ["triangle", "quadrilateral"]
  },
  {
    "@id": "local:degree",
    "label": "isoparametric_element_degree",
    "has numerical value": [1, 2]
  }
]

Use a JSON-LD context mapping these value properties to m4i:hasStringValue and m4i:hasNumericalValue, as in the existing examples. BenchmarkLoader.load() expands each parameter set independently into the Cartesian product: this example produces four configurations. Scalars are repeated in every combination. All loaded configuration parts contain scalar values, so solvers and runner.create_parameter_files() continue to receive ordinary scalar parameters. Processing-step configuration references expand identically for provenance.

A template identified as sweep produces identifiers sweep--1, sweep--2, etc., and corresponding parameters_sweep--1.json files. Its node IDs receive the same suffixes. Scalar-only sets and arrays with one distinct choice retain the original IDs and identifiers. Identifier collisions raise an error instead of overwriting output files.

JSON-LD arrays represent unordered RDF alternatives, so duplicate RDF values collapse. Expansion sorts parameter IRIs and RDF value spellings to give stable identifiers regardless of array order (this is lexical, not numerical ordering). Empty arrays have no value and are rejected for runtime parameters. The lower-level build_parameter_set() returns a template whose values may be lists; build_parameter_sets() and load() return expanded scalar configurations.

When testing this feature from a local checkout, install the modified package into the Python environment used by the benchmark runner:

python -m pip install -e ../semantic-benchmark

Run that command from a sibling benchmark repository. Add [all] to the local package path if the workflow also needs the optional provenance dependencies.

See the complete array example, which combines two radii, two cell types, and two element degrees into eight runs.

Metadata

Release files for semantic-benchmark 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for semantic-benchmark 0.5.2
File Size Uploaded Provenance Actions
semantic_benchmark-0.5.2.tar.gz 40.3 kB Without provenance Details for semantic_benchmark-0.5.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for semantic-benchmark 0.5.2
File Interpreter ABI Platform Actions
semantic_benchmark-0.5.2-py3-none-any.whl Python 3 none any Details for semantic_benchmark-0.5.2-py3-none-any.whl

Total release size: 80.1 kB

Release files / semantic_benchmark-0.5.2.tar.gz

Download URL semantic_benchmark-0.5.2.tar.gz
Size 40.3 kB
Tags Source
SHA-256 checksum
How to use checksums
985e4261865f9b35c811e0df1b0d9da042f27e331e87983ab516691fe4db7e93
BLAKE2b-256 checksum
How to use checksums
43fb06e233a7cdb90e0c8bc2cef34cf86b4815d2cd1cc9f22cad0a3c71bb2d16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / semantic_benchmark-0.5.2-py3-none-any.whl

Download URL semantic_benchmark-0.5.2-py3-none-any.whl
Size 39.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68eb127054d25c9b7dce15563ad1d82aeaafaacd4ab753c6b11f10450c41f877
BLAKE2b-256 checksum
How to use checksums
97ebb3f9b263dbef264cd882b0c2a889e75754f834c392e793545492dfb37290
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for semantic-benchmark 0.5.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page