osolmaz/ourmodels-data / scripts /validate_items.py
osolmaz's picture
download
raw
1.75 kB
from __future__ import annotations
from pathlib import Path
from local_hardware_items import (
ItemValidationError,
catalog_from_items,
load_items,
load_memory_price_sources,
)
ROOT = Path(__file__).resolve().parents[1]
ITEMS_DIR = ROOT / "data" / "items"
MEMORY_PRICE_SOURCES_PATH = ROOT / "data" / "memory_price_sources.csv"
BANDS = [
("under_3000", "<$3,000", 0, 3000),
("3000_5000", "$3,000–$5,000", 3000, 5000),
("5000_10000", "$5,000–$10,000", 5000, 10000),
("10000_25000", "$10,000–$25,000", 10000, 25000),
("25000_75000", "$25,000–$75,000", 25000, 75000),
("75000_plus", "$75,000+", 75000, None),
]
def main() -> int:
try:
items = load_items(ITEMS_DIR, bands=BANDS)
catalog = catalog_from_items(items)
memory_price_rows = load_memory_price_sources(
MEMORY_PRICE_SOURCES_PATH,
items,
)
except ItemValidationError as exc:
print("Item validation failed.")
print(exc)
return 1
item_count = len(items)
bandwidth_items = {
row["item_id"]
for row in catalog
if row.get("bandwidth_gbps") != ""
}
missing_bandwidth = sorted(
path.stem for path in ITEMS_DIR.glob("*.json")
if path.stem not in bandwidth_items
)
print(f"Validated {item_count} item files and {len(catalog)} catalog rows.")
print(f"Memory price rows: {len(memory_price_rows)}.")
print(f"Bandwidth values: {len(bandwidth_items)}/{item_count} item files.")
if missing_bandwidth:
print("Missing bandwidth values:")
for item_id in missing_bandwidth:
print(f"- {item_id}")
return 0
if __name__ == "__main__":
raise SystemExit(main())

Xet Storage Details

Size:
1.75 kB
·
Xet hash:
7e10c7646930458e0dfa152d5d19b08cdc477dfe8b617cf1491d973c1e79eccd

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.