just_dna_enricher.cli.cache_commands¶
just_dna_enricher.cli.cache_commands ¶
The cache group: status, pull, prepare, prune and rebuild over caches.CACHE_LANES (RM260 split
this out of the former single-file cli.py).
cache_status_ ¶
Say which snapshots are present, where, and which release each holds.
Reads only: nothing is downloaded, so this is safe on a machine with no network and it is the first thing to run when a pass reports that a source was skipped.
Source code in enricher/src/just_dna_enricher/cli/cache_commands.py
cache_pull_ ¶
cache_pull_(
only: list[str] = typer.Option(
[],
"--only",
help="Pull just these caches (repeatable). Default: every publishable one.",
),
use: str = typer.Option(
"unstated",
"--use",
help="Declared use for the licence-gated snapshots. They forbid sale, so they are SKIPPED when unstated and REFUSED when commercial — downloading is taking the data.",
),
) -> None
Download the published parquet snapshots from HuggingFace into the local caches.
The provisioning step a hosted deployment runs, so no pass ever reaches a source live per request.
A cache already here is compared with the release its repo publishes, one small read per lane
(RM420): a cache that came from a pull of that repo and holds another release is re-pulled, and one
built on this machine is left alone and named with both labels, since it may not be uploaded yet.
So this is re-runnable and cheap; an interrupted pull fetches only what it lacks, and a truncated
file is removed and refetched (RM339). When the hub cannot be read, the cache serves as it is.
enrich never reads the hub for a cache that is already whole.
A lane with nothing published says so and names its reason, which is a field on the registry
rather than a comment: PharmVar's and PubMind's are refusals, ACMG's and MANE's are permissions
nobody has established. Build those with cache rebuild.
Source code in enricher/src/just_dna_enricher/cli/cache_commands.py
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 | |
cache_prepare_ ¶
cache_prepare_(
only: list[str] = typer.Option(
[],
"--only",
help="Prepare just these caches (repeatable). Default: every one.",
),
use: str = typer.Option(
"unstated",
"--use",
help=f"Declared use: one of {sorted(VALID_DECLARED_USE)}.",
),
pin: list[str] = typer.Option(
[],
"--pin",
help="lane=release, repeatable, for the lanes that are built rather than pulled.",
),
source: list[str] = typer.Option(
[],
"--source",
help="lane=path, repeatable: build from a file you already hold.",
),
) -> None
Leave this machine with every cache it can have — pull what is published, build what is not.
The complement of cache pull, and the one command a deployment actually wants. pull
fetches the published snapshots and stops; four lanes are not published for recorded reasons —
PharmVar's personal key, PubMind's NoDerivatives, NCBI's policy over MANE, ACMG's supplementary
material — so a machine that only pulled is missing four caches and the checks that read them
skip themselves. This runs each lane by the route it has.
The route is a property of the lane, never a flag. A published lane pulls, because building it would spend an operator's bandwidth re-deriving bytes somebody already made; an unpublished one builds, because that is the only route there will ever be. Asking for the choice would be asking an operator to restate the licensing story.
A cache that is already present is left alone unless it came from a pull and its repo now
publishes another release, exactly as cache pull treats one (RM420), so this is idempotent and
cheap to re-run. Re-cutting a snapshot that exists is cache rebuild,
which writes somewhere else on purpose — a build straight into a live cache is visible half-done
to anything reading it, and a short parquet still has a footer.
The Python counterpart is just_dna_enricher.caches.prepare_caches, which this calls.
Source code in enricher/src/just_dna_enricher/cli/cache_commands.py
cache_prune_ ¶
cache_prune_(
only: list[str] = typer.Option(
[],
"--only",
help="Prune just these caches (repeatable). Default: every published one.",
),
yes: bool = typer.Option(
False,
"--yes",
help="Delete without asking. Without it this prints the plan and stops.",
),
) -> None
Say what a published snapshot repo carries that its lane is not made of, and offer to delete it.
Deletion is never a side effect of publishing, and this is the command that makes that
affordable (RM186). A published repo accumulates: the publisher adds and does not remove, so a
layout change leaves the old spelling in place, and just-dna-seq/clinvar still carries the
159 MB single-file clinvar.parquet from before the per-chromosome split. Provisioning already
refuses to download it — the glob is what defends this tier — but any consumer globbing
data/*.parquet, the dataset viewer included, still gets two schemas under one relation.
Nothing here is a sweep. A file is a candidate only if the lane's own glob excludes it or a
LayoutShift declares it retired; README.md, .gitattributes, release.json, LICENSE.txt
and sidecar directories are never touched. Without --yes this reads and prints and does nothing
else, which is the mode to run first.
Source code in enricher/src/just_dna_enricher/cli/cache_commands.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
cache_rebuild_ ¶
cache_rebuild_(
out: Path = typer.Option(
Path(CACHES_DIRNAME),
"--out",
file_okay=False,
help="Base directory. Each lane is built into <base>/<lane>/, never in place. The default is under data/, which this workspace git-ignores wholesale.",
),
only: list[str] = typer.Option(
[],
"--only",
help="Rebuild just these caches (repeatable). Default: every one that can be.",
),
use: str = typer.Option(
"unstated",
"--use",
help=f"Declared use: one of {sorted(VALID_DECLARED_USE)}.",
),
pin: list[str] = typer.Option(
[],
"--pin",
help="lane=release, repeatable. e.g. --pin mane=1.5 --pin civic=2026-08-01.",
),
source: list[str] = typer.Option(
[],
"--source",
help="lane=path, repeatable: build from a file you already hold instead of downloading. Required for acmg; the offline off-switch for clinvar, constraint, clinpgx, drug_labels, pubmind and strchive. mane and civic take three files each and refuse it.",
),
publish: bool = typer.Option(
False,
"--publish",
help="Also upload each rebuilt snapshot to its HuggingFace repo.",
),
dry_run: bool = typer.Option(
False,
"--dry-run",
help="Download, build and upload nothing: say per lane what a run would do, the release this machine holds and, with --publish, the one published. A snapshot already built into <out>/<lane> (a run without --publish) has its upload rehearsed.",
),
) -> None
Rebuild every cache this tier builds — acquire, convert, and optionally publish (RM176).
The one endpoint over eleven builders. Each per-lane X build command stays, and this calls
the same download_*/build_* functions they do, so there is one conversion algorithm with two
callers rather than two that have to agree. What differs is only flag plumbing: a per-lane command
offers the local-file inputs an operator holds, and a rebuild pass by definition holds none.
Every lane is built into <base>/<lane>/, never in place over a resolved cache. A rebuild
takes minutes and an enrich reading a half-written snapshot mid-flight would see a real but
incomplete table — the failure a resolver cannot detect, because a short parquet is still a
parquet. Point the caches at the new base when the run is done, or copy each directory across.
An outcome is three-valued. ACMG needs a workbook that is Elsevier supplementary material, PharmVar a personal key, CIViC a release date to pin — none of those is a failure, and a nightly rebuild reporting errors for them would be reporting the licences working as designed. They are printed as not run, with the reason, and the exit code counts only real failures.
Source code in enricher/src/just_dna_enricher/cli/cache_commands.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | |