import os import pandas as pd import ipfshttpclient from pathlib import Path from utils import INC_TOOLS from tools import update_tools_accuracy ACCURACY_FILENAME = "tools_accuracy.csv" IPFS_SERVER = "/dns/registry.autonolas.tech/tcp/443/https" SCRIPTS_DIR = Path(__file__).parent ROOT_DIR = SCRIPTS_DIR.parent DATA_DIR = ROOT_DIR / "data" def compute_tools_accuracy(): print("Computing accuracy of tools") print("Reading tools parquet file") tools = pd.read_parquet(DATA_DIR / "tools.parquet") print(tools.head()) # Computing tools accuracy information print("Computing tool accuracy information") # Check if the file exists acc_data = None if os.path.exists(DATA_DIR / ACCURACY_FILENAME): acc_data = pd.read_csv(DATA_DIR / ACCURACY_FILENAME) acc_data = update_tools_accuracy(acc_data, tools, INC_TOOLS) # save acc_data into a CSV file print("Saving into a csv file") acc_data.to_csv(DATA_DIR / ACCURACY_FILENAME, index=False) print(acc_data.head()) # save the data into IPFS client = ipfshttpclient.connect(IPFS_SERVER) result = client.add(DATA_DIR / ACCURACY_FILENAME) print(f"HASH of the tools accuracy file: {result['Hash']}") if __name__ == "__main__": compute_tools_accuracy()