just_dna_enricher.drug_labels_build¶
just_dna_enricher.drug_labels_build ¶
Build the regulator drug-label snapshot the label cross-check reads ([dev], RM166).
ClinPGx publishes drugLabels.zip on the same endpoint summaryAnnotations.zip comes from, and
clinpgx_build downloads exactly one of the twelve archives that endpoint serves. This is the
second: 59 KB holding LICENSE.txt, README.pdf, drugLabels.tsv (1,433 rows when probed on
2026-08-05) and drugLabels.byGene.tsv (238 rows, a pivot of the same labels by gene symbol — it
carries no fact the label table does not, so nothing here reads it).
Its own release.json, never the annotation lane's. clinpgx_build's module docstring records
that relationships.zip was a year newer than clinicalAnnotations.zip, so assuming ClinPGx's
archives refresh in lockstep is a mistake this lane has already made once — and RM175 found the reason
that particular gap was so wide, which was that ClinPGx had stopped rebuilding the annotation archive
under that name altogether. drugLabels.zip carries
its own CREATED_<date>.txt and it is what labels this snapshot — clinpgx_drug_labels_<date>,
distinct from the annotation lane's clinpgx_<date> because the two archives are two surfaces with
two denominators (@two-surfaces-two-denominators).
Every cell is stored verbatim. Seven of the fifteen columns are flag-shaped — a blank or one
constant string (Prescribing Info, Cancer Genome) — and coercing them to booleans would have this
builder decide that Biomarker Flag is one, which it is not: it carries three values, On FDA
Biomarker List and Formerly on FDA Biomarker List beside the blank. So nothing is coerced, a blank
becomes None, and the reader decides what a cell means (@verbatim-except-order).
No --offline, and the licence gate lives at the CLI. A builder's off-switch is passing the local
archive instead of downloading one, and check_declared_use gates the fetch — which is the command,
not this module (@acquisition-gate-is-not-a-read-gate). clinpgx build puts the gate in the command
body for the same reason and this follows it rather than inventing a third answer.
DrugLabelBuildResult
dataclass
¶
DrugLabelBuildResult(
out_dir: Path,
parquet_path: Path,
release_file: Path,
label_count: int,
created_date: str | None,
dataset: str | None,
source_url: str,
source_sha256: str,
license_sha256: str | None,
regulators: list[str] = list(),
testing_levels: list[str] = list(),
)
Where the snapshot landed, what it holds, and what it came from.
download_drug_labels_zip ¶
Stream drugLabels.zip to dest (atomic .part rename), returning (path, sha256).
Core httpx with the hash taken while streaming, the shape every bulk builder here uses —
download.py is HuggingFace snapshot provisioning and net.py is pacing for live API clients,
so neither is what a one-file download reaches for.
httpx's exceptions do not leave this function (@client-exception-contract): a retired
endpoint is a 404, and it must reach the CLI as DRUG-LABEL BUILD FAILED: … rather than as a raw
HTTPStatusError traceback. The half-written .part goes with it.
Source code in enricher/src/just_dna_enricher/drug_labels_build.py
build_drug_label_snapshot ¶
build_drug_label_snapshot(
zip_path: Path,
out_dir: Path,
*,
source_url: str = DEFAULT_DRUG_LABELS_URL,
source_sha256: str | None = None,
) -> DrugLabelBuildResult
drugLabels.zip → data/drug_labels.parquet + LICENSE.txt + release.json.
Rows are sorted by label_id so a rebuild is byte-identical (Principle 7); built_at is the only
per-run byte and it lives in release.json, outside the parquet.
Source code in enricher/src/just_dna_enricher/drug_labels_build.py
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 259 260 261 | |