Choose what gets loaded

Pointing OntoEnv at a directory picks up every RDF file underneath it, including test fixtures, drafts, and vendored copies. Two independent filter layers narrow that down.

Layer

Matches on

CLI flags

Python arguments

File filters

File paths, gitignore-style globs

-i/--includes, -e/--excludes

includes=, excludes=

Ontology filters

Ontology IRIs, regular expressions

--include-ontology, --exclude-ontology

include_ontologies=, exclude_ontologies=

File filters run first and decide what gets parsed. Ontology filters run after parsing, once the declared IRI is known.

Filter by file path

Globs support *, ?, and **. A bare directory expands to dir/** automatically.

# Only Turtle files
$ ontoenv init ./ontologies --includes '*.ttl'

# Everything except the test fixtures
$ ontoenv init . --excludes 'lib/tests' 'target'
env = OntoEnv.connect(
    "./ontology-env",
    search_directories=["."],
    includes=["*.ttl", "*.xml"],
    excludes=["lib/tests", "target"],
)
env.update()

The default include list is ['*.ttl', '*.xml', '*.n3'].

Filter by ontology IRI

Use these when the file layout does not tell you what you need to know — for example when one directory holds both your ontologies and vendored ones.

Includes act as a whitelist: if any include pattern is set, an ontology must match one of them. Excludes run last and prune whatever slipped through.

$ ontoenv init . \
    --include-ontology '^https://example\.com/' \
    --exclude-ontology 'experimental'
env = OntoEnv.connect(
    "./ontology-env",
    search_directories=["."],
    include_ontologies=[r"^https://example\.com/"],
    exclude_ontologies=[r"experimental"],
)

These are regular expressions, not globs, and they are matched against the full ontology IRI.

Reject files without an ontology declaration

By default a file with no owl:Ontology declaration is skipped with a warning. To make it an error:

$ ontoenv init ./ontologies --require-ontology-names
env = OntoEnv.connect("./ontology-env", require_ontology_names=True)

Change filters on an existing environment

Filters are saved in .ontoenv/config.json and re-applied by every later command. Path-based lists can be edited through ontoenv config:

$ ontoenv config list
$ ontoenv config add locations ./more-ontologies
$ ontoenv config remove locations ./old-path
$ ontoenv config add includes '*.n3'

locations, includes, and excludes are list-valued, so they take config add / config remove rather than config set. The ontology-IRI regex lists (include_ontologies, exclude_ontologies) have no config support — edit .ontoenv/config.json directly, or pass the flags on the next command.

From Python, passing a value to connect overrides the saved one; omitting it keeps the saved one. Passing an empty list is an explicit override that clears the setting:

# Keep everything as saved
env = OntoEnv.connect("./ontology-env")

# Override the saved search directories
env = OntoEnv.connect("./ontology-env", search_directories=["./vendor"])

# Explicitly clear them
env = OntoEnv.connect("./ontology-env", search_directories=[])

Changing filters does not rescan anything by itself. The new settings apply on the next update():

env = OntoEnv.connect("./ontology-env", excludes=["vendor"])
env.update()   # now the exclusion takes effect

See also

Configuration for every setting and its default.