File size: 1,863 Bytes
ca2da1c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c60e715
 
 
 
43cbda0
c60e715
 
216eab8
ca2da1c
 
 
005d6f3
ca2da1c
c60e715
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ba4adc5
216eab8
005d6f3
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
54
55
56
57
58
59
60
61
62
import argparse
import os

from datasets import load_dataset, Dataset
from huggingface_hub import HfApi


TOKEN = os.environ.get("DEBUG")
api = HfApi(token=TOKEN)

parser = argparse.ArgumentParser()
parser.add_argument(
    "--run_dir",
    default=None,
    type=str,
    required=True,
    help="Path to the run directory.",
)
parser.add_argument(
    "--model_name",
    default=None,
    type=str,
    required=True,
    help="Model to benchmark.",
)
parser.add_argument(
    "--reason",
    default=None,
    type=str,
    required=False,
    help="Reason for failure -- to update in the requests file",
)

args = parser.parse_args()

# Updating request
dataset = load_dataset("AIEnergyScore/requests_debug", split="test", token=TOKEN).to_pandas()

## Set benchmark to failed

# If we have a custom reason for failure, add that instead of generic FAILED.
if args.reason:
    dataset.loc[dataset["model"].isin([args.model_name]), ['status']] = args.reason
else:
    # TODO: This doesn't have to be try-except, we could actually check if the file is there...
    try:
        # Read error message
        with open(f"{args.run_dir}/error.log", 'r') as file:
            for f in file.readlines():
                if 'Traceback (most recent call last):' in f:
                    error_message = f
                    dataset.loc[dataset["model"].isin([args.model_name]), ['status']] = "FAILED"
                    print("Status set to FAILED")
                else:
                    dataset.loc[dataset["model"].isin([args.model_name]), ['status']] = "COMPLETED"
        # Add a new column for the error message if necessary
    except FileNotFoundError as e:
        print(f"Could not find {args.run_dir}/error.log")
    
updated_dataset = Dataset.from_pandas(dataset)
updated_dataset.push_to_hub("AIEnergyScore/requests_debug", split="test", token=TOKEN)