File size: 1,275 Bytes
5c0ffc8
 
 
24a8076
5c0ffc8
 
 
 
 
24a8076
 
 
5c0ffc8
 
 
24a8076
5c0ffc8
 
 
 
 
 
 
 
 
 
cf2f2ff
5c0ffc8
 
 
cf2f2ff
5c0ffc8
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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()