Skip to content

Commit

Permalink
feat: local registry timestamp
Browse files Browse the repository at this point in the history
The timestamp of when the metric is saved is added as a second column to each per-round metric csv in the local registry.
  • Loading branch information
GustavBaumgart committed Jun 1, 2023
1 parent 5abf5f6 commit 5f3b035
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/python/flame/registry/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from collections import defaultdict
from pathlib import Path
import shutil

import time

from flame.common.util import get_ml_framework_in_use, MLFramework
from flame.config import Hyperparameters
Expand Down Expand Up @@ -75,13 +75,14 @@ def setup_run(self) -> None:

def save_metrics(self, epoch: int, metrics: Optional[dict[str, float]]) -> None:
"""Save metrics in a model registry."""
curr_time = time.time()
for metric in metrics:
filename = os.path.join(self.registry_path, METRICS, metric)
exists = os.path.exists(filename)
with open(filename, "a+") as file:
csv_writer = csv.writer(file)
csv_writer.writerow(["round", metric]) if not exists else None
csv_writer.writerow([epoch, metrics[metric]])
csv_writer.writerow(["round", "time", metric]) if not exists else None
csv_writer.writerow([epoch, curr_time, metrics[metric]])

def save_params(self, hyperparameters: Optional[Hyperparameters]) -> None:
"""Save hyperparameters in a model registry."""
Expand Down

0 comments on commit 5f3b035

Please sign in to comment.