| import argparse |
| import pandas as pd |
| from pathlib import Path |
| import datetime |
| import pickle |
|
|
| """ |
| Generate VC configuration for simulation |
| """ |
|
|
|
|
| def main(args): |
| cluster = args.cluster |
| date = args.date |
|
|
| if not Path(f"./{cluster}").exists(): |
| Path(f"./{cluster}").mkdir() |
|
|
| if cluster == "Philly": |
| df = pd.read_csv(Path(f"./philly_vc.csv")) |
| else: |
| file = Path(f"../../../data/{cluster}/cluster_gpu_number.csv") |
| df = pd.read_csv(file, parse_dates=["date"]) |
|
|
| if cluster == "Jupiter" and date == "July": |
| vcs = df.columns.values[1:-2] |
| nodes_num = df[df["date"] == datetime.datetime(2020, 7, 1)].values[0][1:-2] |
| nodes_num = nodes_num // 8 |
|
|
| assert len(nodes_num) == len(vcs) |
| dic = dict(zip(vcs, nodes_num)) |
| del dic["vc7Bz"] |
|
|
| with open(f"./{cluster}/vc_dict.pkl", "wb") as f: |
| pickle.dump(dic, f, pickle.HIGHEST_PROTOCOL) |
|
|
| if cluster == "Neptune" and date == "Sept": |
| vcs = df.columns.values[1:-1] |
| nodes_num = df[df["date"] == datetime.datetime(2020, 9, 1)].values[0][1:-1] |
| nodes_num = nodes_num // 8 |
|
|
| assert len(nodes_num) == len(vcs) |
| dic = dict(zip(vcs, nodes_num)) |
|
|
| del dic["vc7Bz"] |
| del dic["vcIoD"] |
| del dic["vcftk"] |
| del dic["vc5LC"] |
| del dic["vcEwI"] |
|
|
| |
| del dic["vcrsE"] |
| del dic["vcHyk"] |
| del dic["vcVvI"] |
|
|
| with open(f"./{cluster}/vc_dict.pkl", "wb") as f: |
| pickle.dump(dic, f, pickle.HIGHEST_PROTOCOL) |
|
|
| if cluster == "Saturn" and date == "Sept": |
| vcs = df.columns.values[1:-1] |
| nodes_num = df[df["date"] == datetime.datetime(2020, 9, 1)].values[0][1:-1] |
| nodes_num = nodes_num // 8 |
|
|
| assert len(nodes_num) == len(vcs) |
| dic = dict(zip(vcs, nodes_num)) |
|
|
| del dic["vc7Bz"] |
| del dic["vcHcQ"] |
| del dic["vck1d"] |
| del dic["vcj72"] |
| del dic["vcIya"] |
| del dic["vcygX"] |
| del dic["vcxqr"] |
| del dic["vcsgw"] |
|
|
| with open(f"./{cluster}/vc_dict.pkl", "wb") as f: |
| pickle.dump(dic, f, pickle.HIGHEST_PROTOCOL) |
|
|
| if cluster == "Uranus" and date == "Sept": |
| vcs = df.columns.values[1:-1] |
| nodes_num = df[df["date"] == datetime.datetime(2020, 9, 10)].values[0][1:-1] |
| nodes_num = nodes_num // 8 |
|
|
| assert len(nodes_num) == len(vcs) |
| dic = dict(zip(vcs, nodes_num)) |
|
|
| del dic["vc7Bz"] |
| del dic["vczGr"] |
| del dic["vciN1"] |
| del dic["vcV7h"] |
| del dic["vcRAl"] |
| del dic["vcvcM"] |
| del dic["vc1z2"] |
|
|
| del dic["vcHyk"] |
| del dic["vcRDh"] |
| del dic["vcFsC"] |
| del dic["vcVvI"] |
| del dic["vcxqr"] |
| del dic["vcsBT"] |
| del dic["vcygX"] |
|
|
| with open(f"./{cluster}/vc_dict.pkl", "wb") as f: |
| pickle.dump(dic, f, pickle.HIGHEST_PROTOCOL) |
|
|
| if cluster == "Earth" and date == "Sept": |
| vcs = df.columns.values[1:-1] |
| nodes_num = df[df["date"] == datetime.datetime(2020, 9, 10)].values[0][1:-1] |
| nodes_num = nodes_num // 8 |
|
|
| assert len(nodes_num) == len(vcs) |
| dic = dict(zip(vcs, nodes_num)) |
|
|
| |
| del dic["vcp4O"] |
| del dic["vcvcM"] |
| del dic["vcXrB"] |
| del dic["vc7hD"] |
| del dic["vcIya"] |
| del dic["vc8Sj"] |
|
|
| del dic["vcLJZ"] |
|
|
| del dic["vcxS0"] |
|
|
| with open(f"./{cluster}/vc_dict.pkl", "wb") as f: |
| pickle.dump(dic, f, pickle.HIGHEST_PROTOCOL) |
|
|
| if cluster == "Venus" and date == "Sept": |
| vcs = df.columns.values[1:-1] |
| nodes_num = df[df["date"] == datetime.datetime(2020, 9, 10)].values[0][1:-1] |
| nodes_num = nodes_num // 8 |
|
|
| assert len(nodes_num) == len(vcs) |
| dic = dict(zip(vcs, nodes_num)) |
|
|
| |
| del dic["vcEhP"] |
| del dic["vcIya"] |
| del dic["vcJLV"] |
| del dic["vcJkd"] |
| del dic["vcsBT"] |
|
|
| del dic["vcbIW"] |
| del dic["vc6YE"] |
| del dic["vcOhe"] |
| del dic["vccJW"] |
| del dic["vcP2J"] |
|
|
| with open(f"./{cluster}/vc_dict.pkl", "wb") as f: |
| pickle.dump(dic, f, pickle.HIGHEST_PROTOCOL) |
|
|
| if cluster == "Philly": |
| d = dict(zip(df["vc"].values, df["node num"].values)) |
|
|
| with open(f"./Philly/vc_dict_homo.pkl", "wb") as f: |
| pickle.dump(d, f, pickle.HIGHEST_PROTOCOL) |
|
|
|
|
| if __name__ == "__main__": |
| parser = argparse.ArgumentParser(description="VC Configuration Generator") |
| parser.add_argument("-c", "--cluster", default="Earth", type=str, help="Cluster Name") |
| parser.add_argument("-d", "--date", default="Sept", type=str, help="Month") |
| args = parser.parse_args() |
| main(args) |
|
|