Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
OntoEnv Python Bindings
Installation
pip install ontoenv
Usage
# creates a new environment in the current directory, or loads
# an existing one. To use a different directory, pass the 'path'
# argument: OntoEnv(path="/path/to/env")
# OntoEnv() will discover ontologies in the current directory and
# its subdirectories
=
# add an ontology from a file path.
# env.add returns the name of the ontology, which is its URI
# e.g. "https://brickschema.org/schema/1.4-rc1/Brick"
=
# When you add from a URL whose declared ontology name differs (for example a
# versioned IRI served at a versionless URL), ontoenv records that alias. You
# can later refer to the ontology by either the canonical name or the original
# URL when resolving imports or querying.
# get the graph of the ontology we just added
# env.get_graph returns an rdflib.Graph
=
# get the full closure of the ontology, including all of its imports
# returns a tuple (rdflib.Graph, list[str])
, =
# you can also add ontologies from a URL
=
=
# you can add an in-memory rdflib.Graph directly
=
=
# if you have an rdflib.Graph with an owl:Ontology declaration,
# you can transitively import its dependencies into the graph
=
# this graph just has one triple: the ontology declaration for Brick
# this will load all of the owl:imports of the Brick ontology into 'g'
Namespace prefixes
OntoEnv can extract namespace prefix mappings from ontology source files.
Prefixes come from both parser-level declarations (@prefix in Turtle,
PREFIX in SPARQL-style syntaxes) and SHACL sh:declare entries.
# Get all namespaces across the entire environment
=
# {'owl': 'http://www.w3.org/2002/07/owl#', 'brick': 'https://brickschema.org/schema/Brick#', ...}
# Get namespaces for a single ontology
=
# Include namespaces from transitive owl:imports
=
From the CLI:
ontoenv namespaces # all namespaces
ontoenv namespaces https://example.org/my-ontology # single ontology
ontoenv namespaces https://example.org/my-ontology --closure # with imports
ontoenv namespaces --json # JSON output
Custom graph store
If you want OntoEnv to write graphs into an existing Python-backed store, pass a graph_store
object that implements a small protocol:
...
...
...
...
... # optional, returns {"num_graphs": ..., "num_triples": ...}
Example:
=
=
graph_store is currently incompatible with recreate and create_or_use_cached.
RDFLib store with Rust SPARQL
If you want to use ontoenv as an rdflib store directly, use OntoEnvStore. This gives you
normal rdflib.Graph and rdflib.Dataset objects, but executes SPARQL through the Rust
backend instead of rdflib's Python query engine.
Use env.snapshot_as_dataset() to get a read-only rdflib.Dataset view of the env.
The default backend="auto" picks the zero-copy rdf5d snapshot when a persistent
.ontoenv/store.r5tu exists and otherwise falls back to an in-memory copy. Pass
backend="rdf5d" to require the fast path (raises for temporary or graph_store=
envs) or backend="copy" to always materialize.
=
=
=
=
Importing ontoenv also registers the rdflib plugin name "ontoenv", so this works too:
=
See demo_rdflib_store.py for a complete runnable example.
CLI Entrypoint
Installing ontoenv also provides the Rust-backed ontoenv command-line tool:
pip install ontoenv
ontoenv --help
The CLI is identical to the standalone ontoenv-cli binary; see the top-level README for usage.