MCPcopy Create free account
hub / github.com/internetarchive/openlibrary / commit_batch

Function commit_batch

scripts/bwb_opds_imports.py:362–366  ·  view source on GitHub ↗
(batch_name: str, olbooks: list[dict[str, Any]], batch_size: int = 1000)

Source from the content-addressed store, hash-verified

360
361
362def commit_batch(batch_name: str, olbooks: list[dict[str, Any]], batch_size: int = 1000) -> None:
363 batch = Batch.find(batch_name) or Batch.new(batch_name)
364 items = [{"ia_id": b["source_records"][0], "data": b} for b in olbooks]
365 for i in range(0, len(items), batch_size):
366 batch.add_items(items[i : i + batch_size])
367
368
369def main(

Callers 1

mainFunction · 0.85

Calls 5

rangeFunction · 0.85
lenFunction · 0.85
add_itemsMethod · 0.80
findMethod · 0.45
newMethod · 0.45

Tested by

no test coverage detected