Spaces:
Runtime error
Runtime error
Adding handling for space error log in failure handling.
Browse files- failed_run.py +30 -8
failed_run.py
CHANGED
@@ -23,6 +23,13 @@ parser.add_argument(
|
|
23 |
required=True,
|
24 |
help="Model to benchmark.",
|
25 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
args = parser.parse_args()
|
27 |
|
28 |
# Updating request
|
@@ -31,16 +38,31 @@ dataset = load_dataset("EnergyStarAI/requests_debug", split="test", token=TOKEN)
|
|
31 |
# Set benchmark to failed
|
32 |
dataset.loc[dataset["model"].isin(args.model_name), ['status']] = "FAILED"
|
33 |
|
34 |
-
|
35 |
-
#
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
42 |
|
43 |
updated_dataset = Dataset.from_pandas(dataset)
|
44 |
updated_dataset.push_to_hub("EnergyStarAI/requests_debug", split="test", token=TOKEN)
|
45 |
|
46 |
print("Status set to FAILED")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
required=True,
|
24 |
help="Model to benchmark.",
|
25 |
)
|
26 |
+
parser.add_argument(
|
27 |
+
"--error_log",
|
28 |
+
default=None,
|
29 |
+
type=str,
|
30 |
+
required=False,
|
31 |
+
help="Location of space runtime error log -- note this is distinct from an optimum-benchmark log.",
|
32 |
+
)
|
33 |
args = parser.parse_args()
|
34 |
|
35 |
# Updating request
|
|
|
38 |
# Set benchmark to failed
|
39 |
dataset.loc[dataset["model"].isin(args.model_name), ['status']] = "FAILED"
|
40 |
|
41 |
+
try:
|
42 |
+
# Read error message
|
43 |
+
with open(f"{args.run_dir}/error.log", 'r') as file:
|
44 |
+
error_message = file.read()
|
45 |
+
# Add a new column for the error message if necessary
|
46 |
+
if "error_message" not in dataset.columns:
|
47 |
+
dataset["error_message"] = ""
|
48 |
+
dataset.loc[dataset["model"].isin(args.model_name), ['error_message']] = error_message
|
49 |
+
except FileNotFoundError as e:
|
50 |
+
print(f"Could not find {args.run_dir}/error.log")
|
51 |
|
52 |
updated_dataset = Dataset.from_pandas(dataset)
|
53 |
updated_dataset.push_to_hub("EnergyStarAI/requests_debug", split="test", token=TOKEN)
|
54 |
|
55 |
print("Status set to FAILED")
|
56 |
+
|
57 |
+
if args.error_log:
|
58 |
+
print("Attempting to save space runtime error log at EnergyStarAI/error_logs")
|
59 |
+
try:
|
60 |
+
api.upload_file(
|
61 |
+
path_or_fileobj=args.error_log,
|
62 |
+
path_in_repo=args.error_log,
|
63 |
+
repo_id="EnergyStarAI/error_logs",
|
64 |
+
repo_type="dataset",
|
65 |
+
)
|
66 |
+
except Exception as e:
|
67 |
+
print("That didn't work. Error:")
|
68 |
+
print(e)
|