Setup repo with Phi 3
This commit is contained in:
34
tools/generate-registry.py
Normal file
34
tools/generate-registry.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
import json
|
||||
|
||||
def collect_models(models_root):
|
||||
registry = []
|
||||
for root, dirs, files in os.walk(models_root):
|
||||
if "model.yaml" in files:
|
||||
model_path = os.path.join(root, "model.yaml")
|
||||
try:
|
||||
with open(model_path, 'r', encoding='utf-8') as f:
|
||||
model_data = yaml.safe_load(f)
|
||||
registry.append(model_data)
|
||||
except Exception as e:
|
||||
print(f"❌ Failed to parse {model_path}: {e}", file=sys.stderr)
|
||||
return registry
|
||||
|
||||
if __name__ == "__main__":
|
||||
repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
models_root = os.path.join(repo_root, "models")
|
||||
output_path = os.path.join(repo_root, "registry.json")
|
||||
|
||||
if not os.path.isdir(models_root):
|
||||
print(f"❌ Models directory not found: {models_root}")
|
||||
sys.exit(1)
|
||||
|
||||
registry = collect_models(models_root)
|
||||
|
||||
with open(output_path, 'w', encoding='utf-8') as f:
|
||||
json.dump(registry, f, indent=2, ensure_ascii=False)
|
||||
|
||||
print(f"✅ Registry written to {output_path} with {len(registry)} models.")
|
||||
Reference in New Issue
Block a user