import os | |
import pandas as pd | |
import ipfshttpclient | |
from pull_data import DATA_DIR | |
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" | |
def compute_tools_accuracy(): | |
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) | |
# 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() | |