Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
36 changes: 36 additions & 0 deletions app/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@
"threads",
}

LAPTOP_REQUIRED = {
"slug",
"name",
"brand",
"release_date",
"ram_gb",
"os",
"source_urls",
"verified",
}

DATE_RE = re.compile(r"^\d{4}-\d{2}-\d{2}$")


Expand Down Expand Up @@ -205,9 +216,12 @@ def validate() -> list[str]:
pdas = _load("pda")
gpus = _load("gpu")
cpus = _load("cpu")
laptops = _load("laptop")

brand_slugs = {rec["slug"] for _, rec in brands if "slug" in rec}
soc_slugs = {rec["slug"] for _, rec in socs if "slug" in rec}
cpu_slugs = {rec["slug"] for _, rec in cpus if "slug" in rec}
gpu_slugs = {rec["slug"] for _, rec in gpus if "slug" in rec}

for category, records in (
("brand", brands),
Expand All @@ -218,6 +232,7 @@ def validate() -> list[str]:
("pda", pdas),
("gpu", gpus),
("cpu", cpus),
("laptop", laptops),
):
_check_unique_slugs(category, records, errors)

Expand Down Expand Up @@ -330,6 +345,27 @@ def validate() -> list[str]:
if rec.get("manufacturer") not in brand_slugs:
errors.append(f"{fname}: manufacturer '{rec.get('manufacturer')}' not a known brand")

for fname, rec in laptops:
_check_required(fname, rec, LAPTOP_REQUIRED, errors)
_check_source_urls(fname, rec, errors)
_check_slug(fname, rec.get("slug"), errors)
if "release_date" in rec:
_check_date(fname, rec["release_date"], errors)
_check_range(fname, "ram_gb", rec.get("ram_gb"), 1, 256, errors)
if rec.get("storage_gb") is not None:
_check_range(fname, "storage_gb", rec.get("storage_gb"), 1, 65536, errors)
if rec.get("weight_g") is not None:
_check_range(fname, "weight_g", rec.get("weight_g"), 300, 6000, errors)
if "msrp_usd" in rec:
_check_range(fname, "msrp_usd", rec["msrp_usd"], 50, 50000, errors)
if rec.get("brand") not in brand_slugs:
errors.append(f"{fname}: brand '{rec.get('brand')}' not a known brand")
if rec.get("cpu") is not None and rec.get("cpu") not in cpu_slugs:
errors.append(f"{fname}: cpu '{rec.get('cpu')}' not a known CPU")
if rec.get("gpu") is not None and rec.get("gpu") not in gpu_slugs:
errors.append(f"{fname}: gpu '{rec.get('gpu')}' not a known GPU")
_check_variant_path(fname, rec, "laptop", errors, allow_flat=True)

return errors


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"slug": "acer-15-aspire-lite-al15-41-abhinavflac-815",
"base_model_slug": "acer-15-aspire-lite-al15-41",
"name": "Acer 15 Aspire Lite AL15-41",
"brand": "acer",
"release_date": "2021-01-01",
"ram_gb": 16,
"os": "Windows",
"verified": false,
"source_urls": [
"https://github.com/abhinavflac/laptops-specs-dataset"
],
"msrp_usd": 416,
"device_category": "General",
"cpu_name": "AMD Ryzen 5 5625U",
"gpu_name": "AMD Radeon Radeon",
"gpu_type": "Integrated",
"storage_gb": 512,
"display": {
"size_inch": 15.0,
"resolution": "1920x1080"
},
"variant": {
"source_dataset": "abhinavflac/laptops-specs-dataset",
"source_row": 815
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"slug": "acer-15-travelmate-tmp215-53-business-abhinavflac-704",
"base_model_slug": "acer-15-travelmate-tmp215-53-business",
"name": "Acer 15 TravelMate TMP215-53 Business",
"brand": "acer",
"release_date": "2021-01-01",
"ram_gb": 16,
"os": "Windows",
"verified": false,
"source_urls": [
"https://github.com/abhinavflac/laptops-specs-dataset"
],
"msrp_usd": 466,
"device_category": "General",
"cpu_name": "Intel Core I3 1115G4",
"gpu_name": "Intel Integrated Graphics Integrated Graphics",
"gpu_type": "Integrated",
"storage_gb": 512,
"display": {
"size_inch": 15.0,
"resolution": "1920x1080"
},
"variant": {
"source_dataset": "abhinavflac/laptops-specs-dataset",
"source_row": 704
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"slug": "acer-al15-41-aspire-lite-15-abhinavflac-733",
"base_model_slug": "acer-al15-41-aspire-lite-15",
"name": "Acer AL15-41 Aspire Lite 15",
"brand": "acer",
"release_date": "2021-01-01",
"ram_gb": 8,
"os": "Windows",
"verified": false,
"source_urls": [
"https://github.com/abhinavflac/laptops-specs-dataset"
],
"msrp_usd": 403,
"device_category": "General",
"cpu_name": "AMD Ryzen 5 5625U",
"gpu_name": "AMD Radeon Radeon",
"gpu_type": "Integrated",
"storage_gb": 512,
"display": {
"size_inch": 15.0,
"resolution": "1920x1080"
},
"variant": {
"source_dataset": "abhinavflac/laptops-specs-dataset",
"source_row": 733
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"slug": "acer-al15-41-aspire-lite-abhinavflac-459",
"base_model_slug": "acer-al15-41-aspire-lite",
"name": "Acer AL15-41 Aspire Lite",
"brand": "acer",
"release_date": "2021-01-01",
"ram_gb": 16,
"os": "Windows",
"verified": false,
"source_urls": [
"https://github.com/abhinavflac/laptops-specs-dataset"
],
"msrp_usd": 458,
"device_category": "General",
"cpu_name": "AMD Ryzen 5 5625U",
"gpu_name": "AMD Radeon Radeon",
"gpu_type": "Integrated",
"storage_gb": 1024,
"display": {
"size_inch": 15.0,
"resolution": "1920x1080"
},
"variant": {
"source_dataset": "abhinavflac/laptops-specs-dataset",
"source_row": 459
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"slug": "acer-aspire-lite-15-al15-41-abhinavflac-586",
"base_model_slug": "acer-aspire-lite-15-al15-41",
"name": "Acer Aspire Lite 15 AL15-41",
"brand": "acer",
"release_date": "2021-01-01",
"ram_gb": 8,
"os": "Windows",
"verified": false,
"source_urls": [
"https://github.com/abhinavflac/laptops-specs-dataset"
],
"msrp_usd": 337,
"device_category": "General",
"cpu_name": "AMD Ryzen 3 5300U",
"gpu_name": "AMD Radeon Radeon",
"gpu_type": "Integrated",
"storage_gb": 256,
"display": {
"size_inch": 15.0,
"resolution": "1920x1080"
},
"variant": {
"source_dataset": "abhinavflac/laptops-specs-dataset",
"source_row": 586
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"slug": "acer-travelmate-15-tmp215-53-abhinavflac-903",
"base_model_slug": "acer-travelmate-15-tmp215-53",
"name": "Acer TravelMate 15 TMP215-53",
"brand": "acer",
"release_date": "2021-01-01",
"ram_gb": 4,
"os": "Windows",
"verified": false,
"source_urls": [
"https://github.com/abhinavflac/laptops-specs-dataset"
],
"msrp_usd": 546,
"device_category": "General",
"cpu_name": "Intel Core I3 1115G4",
"gpu_name": "Intel Integrated Graphics Integrated Graphics",
"gpu_type": "Integrated",
"storage_gb": 256,
"display": {
"size_inch": 15.0,
"resolution": "1920x1080"
},
"variant": {
"source_dataset": "abhinavflac/laptops-specs-dataset",
"source_row": 903
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"slug": "acer-travelmate-tmp215-53-business-abhinavflac-705",
"base_model_slug": "acer-travelmate-tmp215-53-business",
"name": "Acer TravelMate TMP215-53 Business",
"brand": "acer",
"release_date": "2021-01-01",
"ram_gb": 16,
"os": "Windows",
"verified": false,
"source_urls": [
"https://github.com/abhinavflac/laptops-specs-dataset"
],
"msrp_usd": 482,
"device_category": "General",
"cpu_name": "Intel Core I3 1115G4",
"gpu_name": "Intel Integrated Graphics Integrated Graphics",
"gpu_type": "Integrated",
"storage_gb": 256,
"display": {
"size_inch": 15.0,
"resolution": "1920x1080"
},
"variant": {
"source_dataset": "abhinavflac/laptops-specs-dataset",
"source_row": 705
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"slug": "acer-travelmate-tmp215-53-abhinavflac-920",
"base_model_slug": "acer-travelmate-tmp215-53",
"name": "Acer TravelMate TMP215-53",
"brand": "acer",
"release_date": "2021-01-01",
"ram_gb": 8,
"os": "Windows",
"verified": false,
"source_urls": [
"https://github.com/abhinavflac/laptops-specs-dataset"
],
"msrp_usd": 732,
"device_category": "General",
"cpu_name": "Intel Core I5 1135G7",
"gpu_name": "Intel Iris Xe Iris Xe Graphics",
"gpu_type": "Integrated",
"storage_gb": 512,
"display": {
"size_inch": 15.0,
"resolution": "1920x1080"
},
"variant": {
"source_dataset": "abhinavflac/laptops-specs-dataset",
"source_row": 920
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"slug": "acer-15-aspire-lite-al15-52h-abhinavflac-700",
"base_model_slug": "acer-15-aspire-lite-al15-52h",
"name": "Acer 15 Aspire Lite AL15-52H",
"brand": "acer",
"release_date": "2022-01-01",
"ram_gb": 16,
"os": "Windows",
"verified": false,
"source_urls": [
"https://github.com/abhinavflac/laptops-specs-dataset"
],
"msrp_usd": 590,
"device_category": "General",
"cpu_name": "Intel Core I5 12450H",
"gpu_name": "Intel UHD UHD Graphics",
"gpu_type": "Integrated",
"storage_gb": 1024,
"display": {
"size_inch": 15.0,
"resolution": "1920x1080"
},
"variant": {
"source_dataset": "abhinavflac/laptops-specs-dataset",
"source_row": 700
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"slug": "acer-al15-52h-aspire-lite-15-abhinavflac-383",
"base_model_slug": "acer-al15-52h-aspire-lite-15",
"name": "Acer AL15-52H Aspire Lite 15 (12650HH / 16GB / 512GB / UHD Graphics / Windows)",
"brand": "acer",
"release_date": "2022-01-01",
"ram_gb": 16,
"os": "Windows",
"verified": false,
"source_urls": [
"https://github.com/abhinavflac/laptops-specs-dataset"
],
"msrp_usd": 747,
"device_category": "General",
"cpu_name": "Intel Core I7 12650H",
"gpu_name": "Intel UHD UHD Graphics",
"gpu_type": "Integrated",
"storage_gb": 512,
"display": {
"size_inch": 15.0,
"resolution": "1920x1080"
},
"variant": {
"source_dataset": "abhinavflac/laptops-specs-dataset",
"source_row": 383
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"slug": "acer-al15-52h-aspire-lite-15-abhinavflac-387",
"base_model_slug": "acer-al15-52h-aspire-lite-15",
"name": "Acer AL15-52H Aspire Lite 15 (12650HH / 16GB / 1024GB / UHD Graphics / Windows)",
"brand": "acer",
"release_date": "2022-01-01",
"ram_gb": 16,
"os": "Windows",
"verified": false,
"source_urls": [
"https://github.com/abhinavflac/laptops-specs-dataset"
],
"msrp_usd": 687,
"device_category": "General",
"cpu_name": "Intel Core I7 12650H",
"gpu_name": "Intel UHD UHD Graphics",
"gpu_type": "Integrated",
"storage_gb": 1024,
"display": {
"size_inch": 15.0,
"resolution": "1920x1080"
},
"variant": {
"source_dataset": "abhinavflac/laptops-specs-dataset",
"source_row": 387
}
}
Loading
Loading