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

metrics: show: debug info on parsing problems #4370

Merged
merged 1 commit into from
Aug 17, 2020

Conversation

pared
Copy link
Contributor

@pared pared commented Aug 10, 2020

Thank you for the contribution - we'll try to review it as soon as possible. πŸ™

Fixes #4356

def __init__(self, metrics):
lines = "\n".join(
f"{rev}: {', '.join(str(p) for p in paths)}"
for rev, paths in metrics.items()
Copy link
Member

Choose a reason for hiding this comment

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

output might become a bit long with this I guess. I wonder would be the best to just mention that -v is available? Also, considering that -v is still needed to understand what is actually going on, I guess.

In that case we could simplify the logic a bit - boolean flag below would be enough instead of a full dict.

if isinstance(metrics, (int, float)):
return metrics

if not isinstance(metrics, dict):
logger.debug(
f"Could not parse metric '{path}' at '{rev}' due to its "
f"unsupported type: '{type(metrics).__name__}'"
Copy link
Member

Choose a reason for hiding this comment

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

we should print key here, ideally even full xpath within the file.

@@ -178,6 +178,11 @@ def __init__(self):
)


class NoMetricsParsedError(DvcException):
def __init__(self,):
super().__init__("Coul not parse any metric. Use `-v` to investigate.")
Copy link
Member

Choose a reason for hiding this comment

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

@jorgeorpinel could you please review the message?

Copy link
Contributor

Choose a reason for hiding this comment

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

Question: is this error output per bad metrics/plots file? Or only when all of the metrics/plots files are bad?

Copy link
Contributor

Choose a reason for hiding this comment

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

How about something like "The metrics/plots file could not be parsed." for now?

Not sure we need the "use -v" part. What other info specific to this problem can the user get that way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jorgeorpinel this error will only be thrown on occasion when there have been metrics found, but none could be parsed, so it should be rather rare. -v will allow user to see debug messages introduced in this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we keep the message as-is, there's a typo in Could

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pmrowla fixed

@pared pared force-pushed the 4356_no_metrics_problem branch 2 times, most recently from f8739d5 to 3c962c5 Compare August 12, 2020 11:26
class NoMetricsParsedError(DvcException):
def __init__(self,):
super().__init__(
"Could not parse any metric. Use `-v` to investigate."
Copy link
Member

Choose a reason for hiding this comment

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

Could not parse metrics files. Use -v option to see more details.

cc @jorgeorpinel - let's get this message right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed the message

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey sorry guys just noticed this mention. I did suggest "The metrics/plots file could not be parsed." before in #4370 (comment) though. I don't think we need to mention -v, that applies to every error message.

Comment on lines 116 to 119
if metrics_found:
raise NoMetricsParsedError()
else:
raise NoMetricsError()
Copy link
Member

@efiop efiop Aug 12, 2020

Choose a reason for hiding this comment

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

Let's not create a yet another exception type here, since it is really the same error with just a tiny difference. Let's just raise NoMetricsError with an explicit message,

dvc/repo/metrics/show.py Outdated Show resolved Hide resolved
dvc/repo/metrics/show.py Outdated Show resolved Hide resolved
Comment on lines 53 to 54
f"Could not parse '{key}' metric from '{path}' at '{rev}' "
f"due to its unsupported type: '{type(val).__name__}'"
Copy link
Member

Choose a reason for hiding this comment

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

Let's use a lazy notation, since there might be a lot of metrics present.

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.

DVC metrics show doesn't find metrics files
5 participants