import requests import json import math import sys import os def search_site(SITE): os.makedirs(f"data/{SITE}", exist_ok=True) filename = f"data/{SITE}/nodes.json" if not os.path.exists(filename): with open(filename, "wb") as f: r = requests.get(f"https://public-api.grid5000.fr/stable/sites/{SITE}/clusters") assert r.status_code == 200 f.write(r.content) with open(filename, "r") as f: data = json.load(f) nodes = data["items"] # assert input(f"{len(nodes)} nodes found. Confirm ? [y/N] ") in ["Y", "y"] for node in nodes: uid = node["uid"] filename = f"data/{SITE}/node-{uid}.json" if not os.path.exists(filename): with open(filename, "wb") as f: r = requests.get(f"https://public-api.grid5000.fr/stable/sites/{SITE}/clusters/{uid}/nodes.json") assert r.status_code == 200 f.write(r.content) with open(filename, "r") as f: data = json.load(f) item = data["items"][0] nb_procs = item["architecture"]["nb_procs"] nb_cores = item["architecture"]["nb_cores"] platform_type = item["architecture"]["platform_type"] proc_vendor = item["processor"]["vendor"] microarch = item["processor"]["microarchitecture"] proc_desc = item["processor"]["model"] +" "+str(item["processor"].get("version", "")) queue = { "production": "prod", "default": "deft", "testing": "test", }[[q for q in node["queues"] if q != "admin"][0]] if nb_procs == 2 and math.log2(nb_cores).is_integer() and platform_type == "x86_64" and proc_vendor.lower() == "intel": print( f"{SITE}/{uid}".ljust(24) +f"(x{len(data['items'])})".ljust(5) +f": {nb_procs}p {nb_cores}c ({queue})".ljust(15) +f": {proc_desc: <24} [{microarch}]" ) if len(sys.argv) > 1: for site in sys.argv[1:]: search_site(site) else: search_site("rennes")