File size: 1,101 Bytes
4d3a37a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
51
52
53
import threading
import time

from utils import fetch_models, fetch_datasets, fetch_readme
from tqdm import tqdm


# Define global variables
models = None
datasets = None
readme_dict = {}


# Provide an API to get models
def get_models():
    return models


# Provide an API to get datasets
def get_datasets():
    return datasets


# Provide an API to get READMEs
def get_readme_dict():
    return readme_dict


# Start a thread to continuously update cards
def run():
    global models, datasets, readme_dict, cnt

    while True:
        new_models = fetch_models()
        new_datasets = fetch_datasets()

        # Add READMEs
        new_readme_dict = {}
        for model in new_models:
            new_readme_dict[model] = fetch_readme(model, "model")

        for dataset in new_datasets:
            new_readme_dict[dataset] = fetch_readme(dataset, "dataset")

        # Update global variables
        models = new_models
        datasets = new_datasets
        readme_dict = new_readme_dict


t = threading.Thread(target=run)
t.start()