dvclive icon indicating copy to clipboard operation
dvclive copied to clipboard

log_metric: raise helpful error if a nested metric is logged and parent key exists as a metric

Open dberenbaum opened this issue 2 years ago • 2 comments

This could happen without treating step as a metric. For example, even without step, you could get the same error for epoch here if you include epoch-level metrics.

We should fail in log_metric if a nested metric (foo/bar) is logged and any of the parent keys already exists in the summary.

Originally posted by @daavoo in https://github.com/iterative/dvclive/issues/490#issuecomment-1458800074

dberenbaum avatar Mar 07 '23 20:03 dberenbaum

See https://github.com/iterative/dvclive/pull/490#issuecomment-1458747287 for more context.

dberenbaum avatar Mar 07 '23 20:03 dberenbaum

Summary: If you have already logged a metric like {"step": 0} and try to log a nested metric like {"step": {"loss": 0.5}}, you will get an error like:

  File "/Users/dave/Code/dvclive/src/dvclive/utils.py", line 35, in nested_update
    d[k] = nested_update(d.get(k, {}), v)
AttributeError: 'int' object has no attribute 'get'

dberenbaum avatar Mar 07 '23 20:03 dberenbaum