ontometer_corpus.paths¶
Every filesystem location the corpus pipeline uses, in one place.
All locations derive from two inputs.
corpus_dir
Tracked corpus artifacts — the registry database, the fetch manifest, the
per-ontology tables and the dependency network: a clone of the corpus
repository.
store_dir
The object store: the raw ontology files themselves, content-addressed
under objects/, and everything rebuildable from them under cache/
(per-file structural sidecars and role tables, entity-level tables). Far
too large for a repository, and the one thing a fresh checkout has to
obtain separately.
Both are settable by flag (--corpus, --store) or by
environment (ONTOMETER_CORPUS, ONTOMETER_STORE), flag winning. Neither
has a default: a missing corpus directory is an error rather than an empty
corpus started in the working directory.
Attributes¶
CORPUS_ENV = 'ONTOMETER_CORPUS'
module-attribute
¶
STORE_ENV = 'ONTOMETER_STORE'
module-attribute
¶
STRUCTURE_VERSION = 1
module-attribute
¶
ROLES_VERSION = 1
module-attribute
¶
Classes¶
MissingStore
¶
MissingCorpus
¶
Bases: UsageError
Raised when no corpus directory is given; a click command exits 2 with the message.
Source code in ontometer_corpus/paths.py
CorpusPaths
dataclass
¶
Resolved locations for one pipeline run.
Source code in ontometer_corpus/paths.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
Attributes¶
corpus_dir
instance-attribute
¶
store_dir = None
class-attribute
instance-attribute
¶
db_path
property
¶
manifest_path
property
¶
network_nodes_path
property
¶
network_edges_path
property
¶
structural_metrics_path
property
¶
term_coupling_path
property
¶
namespace_usage_path
property
¶
Distinct terms per (file, namespace) by usage mode (ontometer_corpus.usage).
ontology_metrics_path
property
¶
Per-ontology metric table (ontometer_corpus.ontology_metrics).
ontology_abstractness_path
property
¶
concept_redeclarations_path
property
¶
Class labels declared in several homes (ontometer_corpus.network.redeclarations).
ontology_dates_path
property
¶
ontology_specialisations_path
property
¶
Ontology-level specialisation pairs; with the two tables above, enough for G(t).
objects_index_path
property
¶
One line per referenced object: hash, size, store-relative path.
fail_log
property
¶
dedup_log
property
¶
objects_dir
property
¶
The raw ontology files, content-addressed: objects/<hh>/<sha256><ext>.
structure_dir
property
¶
Per-file structural sidecars, keyed by raw-byte file_hash: cache/structure/v<N>.
cache_dir
property
¶
Everything rebuildable from the raw files: <store>/cache.
Per-file sidecars and role tables, and the entity-level tables, which run to millions of rows — one per term, per role, per edge — and so stay out of the corpus, which only holds per-ontology tables small enough to commit.
roles_dir
property
¶
Per-file term-role tables: cache/roles/v<N>.
scratch_dir
property
¶
Working space for the streaming parser.
A sibling of the object store rather than a subdirectory of it, so a half-written temporary file can never be mistaken for a stored object. It is deliberately not the system temp directory: that is frequently a tmpfs, and streaming a multi-hundred-megabyte ontology through RAM is the failure this path exists to avoid.
staging_dir
property
¶
Where store downloads land until their hash is checked.
Inside the store root (not under objects/), so moving a checked file
into place is an atomic rename on the same filesystem.
Methods:¶
__init__(corpus_dir, store_dir=None)
¶
roles_path(file_hash)
¶
Sharded per-ontology term-role table: cache/roles/v<N>/<hh>/<hash>.parquet.
cache_dirs()
¶
require_store_dir()
¶
Return the object-store root, or explain why the run cannot proceed.
Source code in ontometer_corpus/paths.py
sidecar_path(file_hash)
¶
Sharded sidecar location: cache/structure/v<N>/<hh>/<hash>.parquet.
resolve_object(retrieved_file)
¶
Turn a stored retrieved_file into a path on this machine.
Paths are recorded relative to the object-store root. An absolute path
is used as-is if it exists; otherwise it is re-anchored at objects/
under the configured store.
Source code in ontometer_corpus/paths.py
ensure_corpus_dir()
¶
resolve(corpus_dir=None, store_dir=None)
classmethod
¶
Build from explicit values, falling back to the environment.
Raises:
| Type | Description |
|---|---|
MissingCorpus
|
Neither corpus_dir nor |
Source code in ontometer_corpus/paths.py
describe()
¶
One block naming every location, for a run's opening banner.
Source code in ontometer_corpus/paths.py
Functions:¶
corpus_paths(command)
¶
Add --corpus and --store to a click command.
The command receives a resolved :class:CorpusPaths as its paths
keyword argument instead of the two raw options. A flag wins over its
environment variable (ONTOMETER_CORPUS, ONTOMETER_STORE). Without
a corpus directory the command exits with a usage error; without an object
store it is unset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
Callable[..., Any]
|
The command callback, taking |
required |
Returns:
| Type | Description |
|---|---|
Callable[..., Any]
|
The callback with both options attached; apply |