Spaces:
Runtime error
Runtime error
meg-huggingface
commited on
Commit
·
c60e715
1
Parent(s):
005d6f3
Adding handling to say that something takes too long
Browse files- failed_run.py +27 -15
- parse_requests.py +6 -2
failed_run.py
CHANGED
|
@@ -23,27 +23,39 @@ parser.add_argument(
|
|
| 23 |
required=True,
|
| 24 |
help="Model to benchmark.",
|
| 25 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
args = parser.parse_args()
|
| 28 |
|
| 29 |
# Updating request
|
| 30 |
dataset = load_dataset("AIEnergyScore/requests_debug", split="test", token=TOKEN).to_pandas()
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
updated_dataset = Dataset.from_pandas(dataset)
|
| 49 |
updated_dataset.push_to_hub("AIEnergyScore/requests_debug", split="test", token=TOKEN)
|
|
|
|
| 23 |
required=True,
|
| 24 |
help="Model to benchmark.",
|
| 25 |
)
|
| 26 |
+
parser.add_argument(
|
| 27 |
+
"--reason",
|
| 28 |
+
default=None,
|
| 29 |
+
type=str,
|
| 30 |
+
required=True,
|
| 31 |
+
help="Reason for failure -- to update in the requests file",
|
| 32 |
+
)
|
| 33 |
|
| 34 |
args = parser.parse_args()
|
| 35 |
|
| 36 |
# Updating request
|
| 37 |
dataset = load_dataset("AIEnergyScore/requests_debug", split="test", token=TOKEN).to_pandas()
|
| 38 |
|
| 39 |
+
## Set benchmark to failed
|
| 40 |
+
|
| 41 |
+
# If we have a custom reason for failure, add that instead of generic FAILED.
|
| 42 |
+
if args.reason:
|
| 43 |
+
dataset.loc[dataset["model"].isin([args.model_name]), ['status']] = args.reason
|
| 44 |
+
else:
|
| 45 |
+
# TODO: This doesn't have to be try-except, we could actually check if the file is there...
|
| 46 |
+
try:
|
| 47 |
+
# Read error message
|
| 48 |
+
with open(f"{args.run_dir}/error.log", 'r') as file:
|
| 49 |
+
for f in file.readlines():
|
| 50 |
+
if 'Traceback (most recent call last):' in f:
|
| 51 |
+
error_message = f
|
| 52 |
+
dataset.loc[dataset["model"].isin([args.model_name]), ['status']] = "FAILED"
|
| 53 |
+
print("Status set to FAILED")
|
| 54 |
+
else:
|
| 55 |
+
dataset.loc[dataset["model"].isin([args.model_name]), ['status']] = "COMPLETED"
|
| 56 |
+
# Add a new column for the error message if necessary
|
| 57 |
+
except FileNotFoundError as e:
|
| 58 |
+
print(f"Could not find {args.run_dir}/error.log")
|
| 59 |
|
| 60 |
updated_dataset = Dataset.from_pandas(dataset)
|
| 61 |
updated_dataset.push_to_hub("AIEnergyScore/requests_debug", split="test", token=TOKEN)
|
parse_requests.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
import os
|
| 2 |
from datasets import load_dataset, Dataset
|
| 3 |
|
|
|
|
| 4 |
TOKEN = os.environ.get("DEBUG")
|
| 5 |
-
requests_dataset = load_dataset("
|
| 6 |
|
| 7 |
def normalize_task(task):
|
| 8 |
# Makes assumption about how the task names are being written, and called.
|
|
@@ -13,4 +14,7 @@ requests_dset = requests_dataset.to_pandas()
|
|
| 13 |
|
| 14 |
for model, task in requests_dset[['model','task']].loc[requests_dset['status'] == 'PENDING'].to_dict(orient= 'split', index=False)['data']:
|
| 15 |
print("%s,%s" % (model, normalize_task(task)))
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
from datasets import load_dataset, Dataset
|
| 3 |
|
| 4 |
+
skip_statuses = ['COMPLETED', 'FAILED', 'RUNNING']
|
| 5 |
TOKEN = os.environ.get("DEBUG")
|
| 6 |
+
requests_dataset = load_dataset("AIEnergyScore/requests_debug", split="test")
|
| 7 |
|
| 8 |
def normalize_task(task):
|
| 9 |
# Makes assumption about how the task names are being written, and called.
|
|
|
|
| 14 |
|
| 15 |
for model, task in requests_dset[['model','task']].loc[requests_dset['status'] == 'PENDING'].to_dict(orient= 'split', index=False)['data']:
|
| 16 |
print("%s,%s" % (model, normalize_task(task)))
|
| 17 |
+
|
| 18 |
+
# Custom errors we will rerun.
|
| 19 |
+
for model, task in requests_dset[['model','task']].loc[~requests_dset['status'].isin(skip_statuses)].to_dict(orient= 'split', index=False)['data']:
|
| 20 |
+
print("%s,%s" % (model, normalize_task(task)))
|