wire docs/scripts/export_library.py, update all docstring examples refs #1

- export_library.py: BIB_DB → conf.path("db.bib")
- Update ~20 docstring usage examples across src/ to show
  config-based defaults (Store(), DuckDBContext(database=path("db.aco")))
  instead of hardcoded paths, so copy-paste stays correct
This commit is contained in:
kert
2026-03-12 14:36:58 -04:00
parent 962dc48509
commit 7e923abc7c
19 changed files with 25 additions and 24 deletions

View File

@@ -15,7 +15,9 @@ import json
import sys import sys
from pathlib import Path from pathlib import Path
BIB_DB = Path("data/bib.sqlite") from conf import path as _conf_path
BIB_DB = _conf_path("db.bib")
OUT_PATH = Path("docs/static/library.json") OUT_PATH = Path("docs/static/library.json")

View File

@@ -13,7 +13,7 @@ Four contexts, one interface::
from aco.lake import DuckDBContext, IcebergContext from aco.lake import DuckDBContext, IcebergContext
# Local dev — embedded DuckDB, no Iceberg # Local dev — embedded DuckDB, no Iceberg
ctx = DuckDBContext(database="notebooks/aco.duckdb") ctx = DuckDBContext(database=path("db.aco")) # path from conf
# Iceberg on Nessie — versioned catalog, S3 storage # Iceberg on Nessie — versioned catalog, S3 storage
ctx = IcebergContext( ctx = IcebergContext(

View File

@@ -31,7 +31,7 @@ Usage::
from aco.lake import DuckDBContext, IcebergContext from aco.lake import DuckDBContext, IcebergContext
# Local dev — same as today # Local dev — same as today
ctx = DuckDBContext(database="notebooks/aco.duckdb") ctx = DuckDBContext(database=path("db.aco")) # path from conf
cache = readmissions.pipeline.run(ctx.load) cache = readmissions.pipeline.run(ctx.load)
# Iceberg on Nessie (versioned, S3-backed) # Iceberg on Nessie (versioned, S3-backed)
@@ -151,7 +151,7 @@ class DuckDBContext(Context):
from aco.lake import DuckDBContext from aco.lake import DuckDBContext
ctx = DuckDBContext(database="notebooks/aco.duckdb") ctx = DuckDBContext(database=path("db.aco")) # path from conf
# Load a table # Load a table
encounters = ctx.load("core.encounter") encounters = ctx.load("core.encounter")

View File

@@ -46,7 +46,7 @@ Usage::
from aco.pipe import readmissions from aco.pipe import readmissions
# Local dev — direct execution # Local dev — direct execution
ctx = DuckDBContext(database="notebooks/aco.duckdb") ctx = DuckDBContext(database=path("db.aco")) # path from conf
results = execute(readmissions.pipeline, ctx) results = execute(readmissions.pipeline, ctx)
# Iceberg on Nessie — direct execution via PyIceberg # Iceberg on Nessie — direct execution via PyIceberg
@@ -118,7 +118,7 @@ def execute(
from aco.lake.engine import execute from aco.lake.engine import execute
from aco.pipe import readmissions from aco.pipe import readmissions
ctx = DuckDBContext(database="notebooks/aco.duckdb") ctx = DuckDBContext(database=path("db.aco")) # path from conf
results = execute(readmissions.pipeline, ctx) results = execute(readmissions.pipeline, ctx)
# Access specific result # Access specific result

View File

@@ -7,7 +7,7 @@ Usage::
from aco.lake import DuckDBContext, sync from aco.lake import DuckDBContext, sync
ctx = DuckDBContext(database="notebooks/aco.duckdb") ctx = DuckDBContext(database=path("db.aco")) # path from conf
# Sync to Databricks (parquet + COPY INTO) # Sync to Databricks (parquet + COPY INTO)
report = sync( report = sync(

View File

@@ -23,7 +23,7 @@ Usage::
# Or with an explicit DuckDB connection (for fidelity with real data) # Or with an explicit DuckDB connection (for fidelity with real data)
import duckdb import duckdb
con = duckdb.connect("notebooks/aco.duckdb", read_only=True) con = duckdb.connect(path("db.aco"), read_only=True) # path from conf
sql_map = transpile( sql_map = transpile(
readmissions.pipeline, readmissions.pipeline,
con, con,

View File

@@ -22,7 +22,7 @@ Usage::
from bcda.client import Client from bcda.client import Client
from bcda.store import Store from bcda.store import Store
store = Store("data/bcda") store = Store()
with Client(client_id="...", client_secret="...") as c: with Client(client_id="...", client_secret="...") as c:
key = store.export(c, types=["Patient", "Coverage"]) key = store.export(c, types=["Patient", "Coverage"])

View File

@@ -41,7 +41,7 @@ Usage
from bib import connect, COLLECTIONS, Tag, Rule from bib import connect, COLLECTIONS, Tag, Rule
store = connect() # default: data/bib.sqlite store = connect() # default from stack.toml
store.ensure_collections(COLLECTIONS) store.ensure_collections(COLLECTIONS)
# Upsert a citation # Upsert a citation

View File

@@ -10,7 +10,7 @@ Usage::
from bib.store import Store from bib.store import Store
from bib import translate from bib import translate
store = Store("data/bib.sqlite") store = Store()
page = translate.cms_website( page = translate.cms_website(
"https://www.cms.gov/.../rvu26a", "https://www.cms.gov/.../rvu26a",
module="pfs", module="pfs",

View File

@@ -22,7 +22,7 @@ Usage::
# [Tag(meta, cclf-ip-s3.1), Tag(meta, cclf-ip-s5.1.1)] # [Tag(meta, cclf-ip-s3.1), Tag(meta, cclf-ip-s5.1.1)]
# Tag all Zotero items referenced by a pipeline # Tag all Zotero items referenced by a pipeline
store = Store("data/bib.sqlite") store = Store()
report = tag_items_from_pipeline(pipeline, store) report = tag_items_from_pipeline(pipeline, store)
# Generate a reference block for a docstring # Generate a reference block for a docstring

View File

@@ -15,7 +15,7 @@ Usage::
from bib.store import Store from bib.store import Store
from bib.spider import crawl, crawl_all from bib.spider import crawl, crawl_all
s = Store("data/bib.sqlite") s = Store()
found = crawl(s, "ABCD1234") found = crawl(s, "ABCD1234")
# → ['KEY1', 'KEY2', ...] # → ['KEY1', 'KEY2', ...]

View File

@@ -9,7 +9,7 @@ Usage::
from bib.store import Store from bib.store import Store
from bib.item import Rule from bib.item import Rule
s = Store("data/bib.sqlite") s = Store()
key = s.create(Rule(title="CY 2026 PFS Final Rule", fr_volume="90")) key = s.create(Rule(title="CY 2026 PFS Final Rule", fr_volume="90"))
item = s.get(key) item = s.get(key)
print(s.format_citation(key)) print(s.format_citation(key))

View File

@@ -10,9 +10,9 @@ Usage::
from bib.store import Store from bib.store import Store
from bib.sync import push_to_zotero from bib.sync import push_to_zotero
s = Store("data/bib.sqlite") s = Store()
items = s.list_items(tag="source:spider") items = s.list_items(tag="source:spider")
stats = push_to_zotero(items, zotero_db="zotero/data/zotero.sqlite") stats = push_to_zotero(items)
print(stats) print(stats)
# {'created': 5908, 'skipped': 12, 'tags': 23456, 'collections': 2} # {'created': 5908, 'skipped': 12, 'tags': 23456, 'collections': 2}
""" """

View File

@@ -5,7 +5,7 @@ Usage in a marimo cell::
from bib.store import Store from bib.store import Store
from bib.ui import library_browser from bib.ui import library_browser
store = Store("data/bib.sqlite") store = Store()
library_browser(store) library_browser(store)
""" """

View File

@@ -5,7 +5,7 @@ Usage in a marimo cell::
from bib.store import Store from bib.store import Store
from bib.ui import cite, bibliography from bib.ui import cite, bibliography
store = Store("data/bib.sqlite") store = Store()
# Inline citation # Inline citation
cite(store, "ABC12345") cite(store, "ABC12345")

View File

@@ -18,9 +18,8 @@ Usage::
from pfs.pipe import load_all from pfs.pipe import load_all
import duckdb import duckdb
con = duckdb.connect("notebooks/aco.duckdb") con = duckdb.connect(path("db.aco")) # path from conf
stats = load_all(con, zotero_db="zotero/data/zotero.sqlite", stats = load_all(con)
zotero_storage="zotero/data/storage")
for table, info in stats.items(): for table, info in stats.items():
print(f"{table}: {info['rows']} rows from {info['files']} files") print(f"{table}: {info['rows']} rows from {info['files']} files")
""" """

View File

@@ -29,7 +29,7 @@ Quick start::
# Batch ingest to a lake context # Batch ingest to a lake context
from aco.lake import DuckDBContext from aco.lake import DuckDBContext
ctx = DuckDBContext(database="notebooks/aco.duckdb") ctx = DuckDBContext(database=path("db.aco")) # path from conf
rex.ingest(["jan.txt", "feb.txt"], format="cms_mmr", context=ctx) rex.ingest(["jan.txt", "feb.txt"], format="cms_mmr", context=ctx)
""" """

View File

@@ -24,7 +24,7 @@ Usage::
# Multiple files → lake context # Multiple files → lake context
from aco.lake import DuckDBContext from aco.lake import DuckDBContext
ctx = DuckDBContext(database="notebooks/aco.duckdb") ctx = DuckDBContext(database=path("db.aco")) # path from conf
rex.ingest( rex.ingest(
paths=["jan_claims.txt", "feb_claims.txt"], paths=["jan_claims.txt", "feb_claims.txt"],
format="cms_mmr", format="cms_mmr",

View File

@@ -26,7 +26,7 @@ Usage::
from rex.store import Store from rex.store import Store
store = Store("data/rex") store = Store()
# Extract with state tracking # Extract with state tracking
key = store.extract_batch( key = store.extract_batch(