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

live.log_metric: Cast nan and inf to string. #677

Merged
merged 2 commits into from
Aug 18, 2023
Merged

Conversation

daavoo
Copy link
Contributor

@daavoo daavoo commented Aug 17, 2023

  • Support string metrics (forgot to support them when DVC added support)
  • Don't recast to float when sending to Studio.

Closes iterative/studio-support#93

I have manually tested end to end against Studio sending inf/nan from math, numpy, and torch.
The Vega plots in the frontend appear to handle just fine datapoints with those values (the datapoint is skipped).

@daavoo daavoo added bugfix A: studio Area: Studio integration labels Aug 17, 2023
@daavoo daavoo requested a review from dberenbaum August 17, 2023 15:05
@daavoo daavoo self-assigned this Aug 17, 2023
- Support string metrics (forgot to support them when DVC added support)
- Don't recast to float when sending to Studio.

Closes iterative/studio-support#93
@daavoo daavoo force-pushed the log-metric-string branch from 0ee7d4a to bc1e94e Compare August 17, 2023 15:08
@dberenbaum
Copy link
Collaborator

Code LGTM!

I have manually tested end to end against Studio sending inf/nan from math, numpy, and torch. The Vega plots in the frontend appear to handle just fine datapoints with those values (the datapoint is skipped).

Have you tested VS Code also?

Eventually, this may not be enough, but seems reasonable for now.

@dberenbaum
Copy link
Collaborator

Also, how do nan and inf get written before and after this PR?

@daavoo
Copy link
Contributor Author

daavoo commented Aug 18, 2023

Have you tested VS Code also?

Eventually, this may not be enough, but seems reasonable for now.

Yes.
The issue was only when posting Live experiments to Studio because the server was rejecting the request. VSCode / Regular commits were apparently not affected.

Also, how do nan and inf get written before and after this PR?

  • Before:
{
    "foo": NaN
}
step    foo
0       nan
  • After:
{
    "foo": "nan"
}
step    foo
0       nan

In theory, I could only patch the data sent to Studio.
However, I think always casting to string is safer to ensure consistency between Live experiments and commits and JSON compliance.

@daavoo daavoo merged commit 5297151 into main Aug 18, 2023
@daavoo daavoo deleted the log-metric-string branch August 18, 2023 09:25
@dberenbaum
Copy link
Collaborator

Should we add tests for plots in DVC, VS Code, and Studio to ensure we don't break it in the future?

@shcheklein
Copy link
Member

shcheklein commented Aug 18, 2023

VS Code is using JSON5 already and handles it well.

It's not an issue for DVC either since we embed the JS returned by DVC right into HTML and it works fine as expected.

It's an issue with serializing it to send to Studio BE, probably can be an issue on that end with saving it into PG (if that is JSON column), sending it to FE, and on FE (if doesn't use JSON5). So, a long chain of places to check and test (usually with simple fixes though).

@daavoo
Copy link
Contributor Author

daavoo commented Aug 23, 2023

Studio backend is tested and has a cast to string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: studio Area: Studio integration bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dvclive stops sending data to studio during training
3 participants