34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
import json
|
|
import sys
|
|
|
|
with open('/root/.hermes/profiles/spark/models_dev_cache.json') as f:
|
|
cache = json.load(f)
|
|
|
|
target = "poolside/laguna-xs-2.1:free"
|
|
|
|
def find_model(data, target, path="", max_depth=10):
|
|
if max_depth < 0:
|
|
return {"found": False, "path": path, "reason": "max depth"}
|
|
if isinstance(data, dict):
|
|
if target in data:
|
|
return {"found": True, "path": path or "root", "value": data[target]}
|
|
# Check for nested provider:pool naming
|
|
for k, v in data.items():
|
|
if isinstance(v, (dict, list)):
|
|
result = find_model(v, target, f"{path}.{k}" if path else k, max_depth-1)
|
|
if result.get('found'):
|
|
return result
|
|
# Check if key contains target
|
|
if isinstance(k, str) and target in k:
|
|
return {"found": True, "path": path or "root", "key_match": k}
|
|
elif isinstance(data, list):
|
|
for i, item in enumerate(data):
|
|
if isinstance(item, (dict, list)):
|
|
result = find_model(item, target, f"{path}[{i}]", max_depth-1)
|
|
if result.get('found'):
|
|
return result
|
|
return {"found": False, "path": path}
|
|
|
|
result = find_model(cache, target)
|
|
print(json.dumps(result, indent=2)) |