Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preserve summary metrics on resume #756

Merged
merged 1 commit into from
Dec 16, 2023
Merged

preserve summary metrics on resume #756

merged 1 commit into from
Dec 16, 2023

Conversation

dberenbaum
Copy link
Contributor

Dvclive was not preserving summary metrics when resume=True.

@dberenbaum dberenbaum requested a review from a team December 15, 2023 14:21
Comment on lines 610 to +618
def read_step(self):
if Path(self.metrics_file).exists():
latest = self.read_latest()
return latest.get("step", 0)
return 0
latest = self.read_latest()
return latest.get("step", 0)

def read_latest(self):
with open(self.metrics_file, encoding="utf-8") as fobj:
return json.load(fobj)
if Path(self.metrics_file).exists():
with open(self.metrics_file, encoding="utf-8") as fobj:
return json.load(fobj)
return {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just refactoring so I could use read_latest elsewhere without having to check if the summary metrics file exists.


assert read_history(dvclive, "metric") == (steps, metrics)
assert read_latest(dvclive, "metric") == (steps[-1], metrics[-1])
if resume:
assert dvclive.read_latest()["summary"] == 1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this PR, the summary metric would have been lost

@dberenbaum
Copy link
Contributor Author

Test failure is unrelated (see this comment)

@@ -24,9 +26,14 @@ def test_resume(tmp_dir, resume, steps, metrics):
for new_metric in [0.7, 0.6]:
dvclive.log_metric("metric", new_metric)
dvclive.next_step()
dvclive.end()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ: is this one actually needed or it's just for a symmetry?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for symmetry/best practice. I think the original year might have been from before we had and end method.

@shcheklein
Copy link
Member

We have a test failure, needs to be fixed. Otherwise good catch, thanks @dberenbaum !

@dberenbaum
Copy link
Contributor Author

dberenbaum commented Dec 16, 2023

@shcheklein See the comment above about the test failure being unrelated. We will keep having that test failure until both of these happen:

  1. hf: warn of deprecating internal callback #740 is merged.
  2. fix typo in dvclive callback huggingface/transformers#27983 is released.

We in fact had the test failure for a long time, but we weren't testing the frameworks in CI until recently.

@dberenbaum dberenbaum merged commit 6a92946 into main Dec 16, 2023
10 of 11 checks passed
@dberenbaum dberenbaum deleted the resume-metrics branch December 16, 2023 11:24
@dberenbaum dberenbaum mentioned this pull request Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants