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

Workbench: validate metadata that is used to open invest models #1370

Merged
merged 10 commits into from
Aug 16, 2023

Conversation

davemfish
Copy link
Contributor

@davemfish davemfish commented Aug 11, 2023

This PR adds some validation before rendering data from the recent jobs store, to avoid rendering a card for a model that no longer exists in the current version of invest, and to skip over jobs that are somehow missing critical pieces of data.

It also adds error handling for trying to load a datastack from a deprecated model.

Fixes #1275 and fixes #1286

Checklist

  • Updated HISTORY.rst and link to any relevant issue (if these changes are user-facing)
  • Updated the user's guide (if needed)
  • Tested the affected models' UIs (if relevant)

@davemfish davemfish marked this pull request as ready for review August 11, 2023 20:58
@davemfish davemfish changed the title Bugfix/wb 1285 jobs data Workbench: validate metadata that is used to open invest models Aug 11, 2023
@davemfish davemfish requested a review from emlys August 13, 2023 16:09
@@ -82,7 +82,6 @@ export function fetchDatastackFromFile(payload) {
headers: { 'Content-Type': 'application/json' },
})
.then((response) => response.json())
.catch((error) => logger.error(error.stack))
Copy link
Member

Choose a reason for hiding this comment

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

Just making sure I understand - this error would now be caught farther up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right. It felt better to add the user-facing alert message to UI component, so that's where the error-handling is now.

logger.error(error);
alert( // eslint-disable-line no-alert
t(
'No InVEST model data can be parsed from the file:\n {{filepath}}',
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this message could provide any more information to help the user solve the problem. Maybe something like

File could not be opened as an InVEST model run. Are you sure this is a valid datastack for a current InVEST model?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it's not perfect but I'm kind of at a loss for how to improve it. This is from the "Load Parameters" button on a model's sidebar, so we're not really opening a "model run" here. If "datastack" had a clear meaning to users then I'd agree we could say, "this is not a valid datastack", but I'm afraid that term is mostly insider-jargon.

My hope is that anyone who sees this message will just realize they clicked on the wrong file or something. If they really don't know what file they should be looking for, then that's a larger design flaw and we should try to add some guidance before the user reaches this alert. We have a tooltip that tries to do that now.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see what you mean. Yeah, this should be fine for now.

Copy link
Member

@emlys emlys left a comment

Choose a reason for hiding this comment

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

@davemfish this all makes sense! Just one suggestion about the alert message.

@davemfish
Copy link
Contributor Author

@davemfish this all makes sense! Just one suggestion about the alert message.

thanks for reviewing @emlys ! I replied to your comments; back to you.

@emlys emlys merged commit f14f60e into natcap:main Aug 16, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants