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

Introduce public summary. Remove "no step" / "step" logic from plots. #331

Merged

Conversation

daavoo
Copy link
Contributor

@daavoo daavoo commented Oct 18, 2022

"no step" / "step" logic was initially introduced to support different logging formats between step and not step updates.

For live.log_image, "step" mode now overwrites the path instead of creating subfolder by step. Closes #326

For live.log, the "no step" was meant not to generate the .tsv file but only the .json.
Added a public property summary so "no step" scenarios can work as follows:

live = Live()

live.summary["foo"] = 1
live.make_summary()

This is a similar design used by wandb (https://docs.wandb.ai/guides/track/log#summary-metrics), where the latest values are in summary by default but single scalars are supposed to be added via manual summary modification instead of log

@daavoo daavoo force-pushed the 326-plots-make-output-structure-consistent-between-plot-types branch 4 times, most recently from 5a1ce90 to ec75b91 Compare October 19, 2022 14:50
@daavoo daavoo requested a review from dberenbaum October 19, 2022 14:53
@daavoo daavoo marked this pull request as ready for review October 19, 2022 14:53
@pared pared self-requested a review October 20, 2022 09:39
@shcheklein
Copy link
Member

thanks @daavoo, interface is getting better!

QQ: so, how will it look like for the example-get-started repo, for example? We'll need to modify summary to log "scalars"?Also, can rename the file?

(it feels we are optimizing for DL scenarios a bit too much?)

@daavoo
Copy link
Contributor Author

daavoo commented Oct 21, 2022

QQ: so, how will it look like for the example-get-started repo, for example?

If you leave the code as it is right now, everything will be the same with the exception that a .tsv file will be additionally created in dvclive/plots/metrics.

We'll need to modify summary to log "scalars"?

If you don't want to generate a single-value .tsv plot file, yes.

Also, can rename the file?

Output files have already been renamed to metrics in #322
Are you referring to the property summary?

tests/plots/test_sklearn.py Outdated Show resolved Hide resolved
tests/plots/test_image.py Outdated Show resolved Hide resolved
tests/test_main.py Outdated Show resolved Hide resolved
@skshetry
Copy link
Member

Should make_summary be called write_summary or just log_summary?

@dberenbaum
Copy link
Collaborator

Can you easily separate the log_image changes from the rest? I think that's easy to merge, but the other part seems a little more divisive .

This is a similar design used by wandb (https://docs.wandb.ai/guides/track/log#summary-metrics), where the latest values are in summary by default but single scalars are supposed to be added via manual summary modification instead of log

What about params? Those are non-step values that get logged via a logger method, although I think we discussed setting them available by dict modification.

It seems this PR is only halfway towards what wandb and mlflow do, since they both have step = 0 by default, whereas this leaves some in-between state where the default is step = None and there is no step value in metrics.json, but dvclive writes out the tsv files with step = 0. Would it simplify logic internally to default to step = 0?

it feels we are optimizing for DL scenarios a bit too much?

Assuming a step-based workflow is what both mlflow and wandb do, so I can understand the push to do the same. However, I don't like that dvclive would then be generating single-point tsv plots from all the metrics. Maybe we can leave in some logic for step 0/None to ignore writing to tsv until set_step is called/wait until there is a change in a metric before writing it to tsv (and possibly not add step 0 to metrics.json, although I'm less worried about this)?

@dberenbaum
Copy link
Collaborator

Should make_summary be called write_summary or just log_summary?

Hmm, no strong opinion, but should this method also be either made private or documented?

@daavoo
Copy link
Contributor Author

daavoo commented Oct 24, 2022

What about params? Those are non-step values that get logged via a logger method, although I think we discussed setting them available by dict modification.

I think params should be handled like summary here (and wandb.config https://docs.wandb.ai/guides/track/config).

It seems this PR is only halfway towards what wandb and mlflow do, since they both have step = 0 by default, whereas this leaves some in-between state where the default is step = None and there is no step value in metrics.json, but dvclive writes out the tsv files with step = 0. Would it simplify logic internally to default to step = 0?

Not sure I see the problem.

there is no step value in metrics.json can only happen if the user doesn't update the step value. In this no step scenario I see no issue with not having step in metrics.json

Maybe we can leave in some logic for step 0/None to ignore writing to tsv until set_step is called/wait until there is a change in a metric before writing it to tsv (and possibly not add step 0 to metrics.json, although I'm less worried about this)?

The idea is that, for no-step workflow, we document the following (instead of calling live.log_metric):

live = Live()

live.summary["foo"] = 1
live.make_summary()

This won't generate .tsv but only update metrics.json. I was just mentioning in ivan answer that even without changing the code the result would be similar, but I mean to say that we should change the code in example-get-started to the snippet above.

Hmm, no strong opinion, but should this method also be either made private or documented?

Method should be public to document the snippet above

@daavoo daavoo force-pushed the 326-plots-make-output-structure-consistent-between-plot-types branch 2 times, most recently from 09a22bb to 8850ddf Compare October 24, 2022 11:04
@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (1.0@876cf20). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@          Coverage Diff           @@
##             1.0     #331   +/-   ##
======================================
  Coverage       ?   95.35%           
======================================
  Files          ?       36           
  Lines          ?     1702           
  Branches       ?      153           
======================================
  Hits           ?     1623           
  Misses         ?       57           
  Partials       ?       22           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@daavoo daavoo force-pushed the 326-plots-make-output-structure-consistent-between-plot-types branch from 8850ddf to d91ec1d Compare October 24, 2022 11:21
@daavoo daavoo self-assigned this Oct 24, 2022
@daavoo daavoo force-pushed the 326-plots-make-output-structure-consistent-between-plot-types branch 2 times, most recently from 8a3f41f to e115105 Compare October 24, 2022 16:09
@dberenbaum
Copy link
Collaborator

The idea is that, for no-step workflow, we document the following (instead of calling live.log_metric):

live = Live()

live.summary["foo"] = 1
live.make_summary()

I don't mind supporting it, but I wouldn't expect that the summary dict is a primary workflow, and I wouldn't introduce it in our example-get-started project. wandb doesn't introduce this in their get started materials, and I think they generally assume users are fine with logging to step=0 by default. I think we should either keep no-step logic or live with some ugly output in example-get-started (primarily the step-0 tsv files/plots).

However, I don't like that dvclive would then be generating single-point tsv plots from all the metrics. Maybe we can leave in some logic for step 0/None to ignore writing to tsv until set_step is called/wait until there is a change in a metric before writing it to tsv (and possibly not add step 0 to metrics.json, although I'm less worried about this)?

there is no step value in metrics.json can only happen if the user doesn't update the step value. In this no step scenario I see no issue with not having step in metrics.json

Why is there a step logged to the tsv file? This seems more important than metrics.json since it generates new directories, files, and plots that aren't useful.

Would it simplify logic internally to default to step = 0?

What I meant here is there still seems to be some "no step" logic that we could drop if we default to self._step = 0:

https://github.com/iterative/dvclive/blob/e115105495746f73721aa14a76fc431b46f05761/src/dvclive/live.py#L162

https://github.com/iterative/dvclive/blob/e115105495746f73721aa14a76fc431b46f05761/src/dvclive/live.py#L165-L167

https://github.com/iterative/dvclive/blob/e115105495746f73721aa14a76fc431b46f05761/src/dvclive/live.py#L260-L261

@daavoo daavoo force-pushed the 326-plots-make-output-structure-consistent-between-plot-types branch from e115105 to d89c29a Compare October 26, 2022 09:00
@daavoo
Copy link
Contributor Author

daavoo commented Oct 26, 2022

I think they generally assume users are fine with logging to step=0 by default. I think we should either keep no-step logic or live with some ugly output in example-get-started (primarily the step-0 tsv files/plots).

I don't see it that way. I think the difference is that our example-get-started focuses on "no step" scenario whereas any other experiment tracker focuses on "step" scenarios first (or even only).

The introduction to wandb.log (https://docs.wandb.ai/guides/track/log) is clearly oriented towards a "step" scenario and yet the summary workflow has a dedicated section (https://docs.wandb.ai/guides/track/log#summary-metrics)

@dberenbaum
Copy link
Collaborator

Discussed with @daavoo and agreed to:

  1. Keep using live.log() as the primary workflow for step and no-step scenarios but without any special syntax for no-step scenarios. This means no-step workflows will still generate tsv files and have step: 0 in the summary. This is no different than mlflow and wandb and doesn't seem to bother people.
  2. Introduce live.summary["foo"] = 1 from this PR as a special case (for example, a step scenario where some metrics are not step-based).

@daavoo daavoo requested a review from pared October 27, 2022 09:35
It was initially introduced for supporting different logging format between step and not step updates.

For `live.log_image`, "step" mode now overwrites the path instead of creating subfolder by step.

For `live.log`, the "no step" was meant to not generate the `.tsv` file but only the `.json`.
Added a public property `summary` so "no step" scenarios can work as follows:

```
live = Live()

live.summary["foo"] = 1
live.make_summary()
```

Closes #326

Apply suggestions from code review

Co-authored-by: Paweł Redzyński <[email protected]>
@daavoo daavoo force-pushed the 326-plots-make-output-structure-consistent-between-plot-types branch from d89c29a to 2df8518 Compare October 27, 2022 09:52
@daavoo
Copy link
Contributor Author

daavoo commented Oct 27, 2022

Merging it. Again, we can get back and change stuff found during docs review

@daavoo daavoo merged commit 243ae28 into 1.0 Oct 27, 2022
@daavoo daavoo deleted the 326-plots-make-output-structure-consistent-between-plot-types branch October 27, 2022 16:39
@dberenbaum
Copy link
Collaborator

Sorry, forgot to approve this one.

daavoo added a commit that referenced this pull request Oct 31, 2022
…s. (#331)

It was initially introduced for supporting different logging format between step and not step updates.

For `live.log_image`, "step" mode now overwrites the path instead of creating subfolder by step.

For `live.log`, the "no step" was meant to not generate the `.tsv` file but only the `.json`.
Added a public property `summary` so "no step" scenarios can work as follows:

```
live = Live()

live.summary["foo"] = 1
live.make_summary()
```

Closes #326

Apply suggestions from code review

Co-authored-by: Paweł Redzyński <[email protected]>

Co-authored-by: Paweł Redzyński <[email protected]>
daavoo added a commit that referenced this pull request Nov 4, 2022
…s. (#331)

It was initially introduced for supporting different logging format between step and not step updates.

For `live.log_image`, "step" mode now overwrites the path instead of creating subfolder by step.

For `live.log`, the "no step" was meant to not generate the `.tsv` file but only the `.json`.
Added a public property `summary` so "no step" scenarios can work as follows:

```
live = Live()

live.summary["foo"] = 1
live.make_summary()
```

Closes #326

Apply suggestions from code review

Co-authored-by: Paweł Redzyński <[email protected]>

Co-authored-by: Paweł Redzyński <[email protected]>
daavoo added a commit that referenced this pull request Nov 4, 2022
…s. (#331)

It was initially introduced for supporting different logging format between step and not step updates.

For `live.log_image`, "step" mode now overwrites the path instead of creating subfolder by step.

For `live.log`, the "no step" was meant to not generate the `.tsv` file but only the `.json`.
Added a public property `summary` so "no step" scenarios can work as follows:

```
live = Live()

live.summary["foo"] = 1
live.make_summary()
```

Closes #326

Apply suggestions from code review

Co-authored-by: Paweł Redzyński <[email protected]>

Co-authored-by: Paweł Redzyński <[email protected]>
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.

6 participants