Skip to content

Commit 5893449

Browse files
committed
Add history back
1 parent ca28a54 commit 5893449

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/art/local/backend.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import math
3+
from datetime import datetime
34

45
from art.utils.deploy_model import (
56
LoRADeploymentJob,
@@ -241,7 +242,7 @@ async def _delete_checkpoints(
241242
)
242243
steps_to_keep.append(best_step)
243244
except FileNotFoundError:
244-
pass
245+
print(f'"{output_dir}/history.jsonl" not found')
245246
except pl.exceptions.ColumnNotFoundError:
246247
print(f'No "{benchmark}" metric found in history')
247248
delete_checkpoints(output_dir, steps_to_keep)
@@ -445,6 +446,17 @@ def _log_metrics(
445446
metrics = {f"{split}/{metric}": value for metric, value in metrics.items()}
446447
step = step if step is not None else self.__get_step(model)
447448

449+
with open(f"{get_model_dir(model=model, art_path=self._path)}/history.jsonl", "a") as f:
450+
f.write(
451+
json.dumps(
452+
{
453+
k: v for k, v in metrics.items() if v == v
454+
} # Filter out NaN values
455+
| {"step": step, "recorded_at": datetime.now().isoformat()}
456+
)
457+
+ "\n"
458+
)
459+
448460
# If we have a W&B run, log the data there
449461
if run := self._get_wandb_run(model):
450462
# Mark the step metric itself as hidden so W&B doesn't create an automatic chart for it

0 commit comments

Comments
 (0)