From 8c7548b7c70574d35c0722f8ec17d46dd23e54cb Mon Sep 17 00:00:00 2001 From: augustin64 Date: Tue, 4 Jun 2024 16:56:10 +0200 Subject: [PATCH] Initial commit --- .gitignore | 2 ++ main.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 .gitignore create mode 100644 main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c57c319 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +data +available.md diff --git a/main.py b/main.py new file mode 100644 index 0000000..ad4a427 --- /dev/null +++ b/main.py @@ -0,0 +1,51 @@ +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"] + 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} (x{len(data['items'])}) : {nb_procs} procs, {nb_cores} cores (queues : {node['queues']}) : {microarch}") + + +if len(sys.argv) > 1: + for site in sys.argv[1:]: + search_site(site) +else: + search_site("rennes") +