Work offline and control caching

OntoEnv fetches remote ontologies over HTTP and caches them on disk. This page covers turning the network off entirely and tuning how long cached copies are trusted.

Turn off all network access

Offline mode makes OntoEnv use only what is already on disk. Unresolvable remote imports are reported rather than fetched.

$ ontoenv init ./ontologies --offline
$ ontoenv update -o
env = OntoEnv.connect("./ontology-env", offline=True)

# Or toggle it on an open environment:
env.set_offline(True)
print(env.is_offline())

Offline mode is saved with the environment, so later commands stay offline until you change it back:

$ ontoenv update --offline=false

Set the cache lifetime

A cached remote ontology is re-fetched by update once it is older than remote_cache_ttl_secs. The default is 86,400 seconds (24 hours).

# For one command
$ ontoenv update --remote-cache-ttl-secs 604800

# Persisted as the environment default
$ ontoenv config set remote_cache_ttl_secs 604800
env = OntoEnv.connect("./ontology-env", remote_cache_ttl_secs=604800)

env.set_remote_cache_ttl_secs(604800)
print(env.remote_cache_ttl_secs())

Refresh regardless of the cache

To re-read every known source even if its cached copy looks current:

$ ontoenv update --all
env.update(force=True)

To force just one source:

env.update("https://example.org/site.ttl", force=True)

Prepare an environment for an offline machine

Build the environment somewhere with a network, then copy the whole directory:

# On a networked machine
$ ontoenv init ./ontologies
$ ontoenv add https://brickschema.org/schema/1.4.4/Brick.ttl
$ ontoenv status

# Ship .ontoenv/ along with your project, then on the target machine:
$ ontoenv status --offline

Everything OntoEnv needs — the graphs and the index describing them — lives under .ontoenv/. On the offline machine, set offline so an accidental update cannot try to reach the network.

Verify nothing is missing before you go offline:

$ ontoenv list missing

An empty result means every owl:imports in the environment resolves to something already stored.