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

Remove old endpoints, add tests #523

Merged
merged 7 commits into from
Sep 10, 2024
Merged

Conversation

r-ash
Copy link
Collaborator

@r-ash r-ash commented Sep 6, 2024

This PR will

  • Remove old unused endpoints
  • Write tests for new endpoints

Note I left the time series endpoints as they are for now. When you tidy that up perhaps we should remove those? Though not too much harm leaving them in

@r-ash r-ash force-pushed the remove-old-endpoints branch from 0613dc5 to 6c549dc Compare September 6, 2024 12:55
Comment on lines -552 to -555
## Update some labels to match what naomi requires
## TODO: Some of this is shared between model running and here so we
## should use use common code when we merge this back into hintr.
## This endpoint currently isn't called see mrc-592.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is unrelated, but just tidied this up whilst I was here

Comment on lines 176 to 178
## This is kind of gross but logic is, if setFilters is not included
## in an effect, then use all the available filters. So have to replicate
## this here for validation
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@M-Kusumgar this is true right?

Copy link
Contributor

Choose a reason for hiding this comment

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

this is not true, https://github.com/mrc-ide/hint/blob/mrc-4856/src/app/static/src/app/store/plotSelections/utils.ts#L59 we initialise filterRefs as empty unless by "available" you mean setFilters on a default effect.

Basically all plots need to have at least one setFilters on the defaultEffect or one of the options in a plot control otherwise nothing shows up on the UI

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! Should have looked at that code, thanks for the link. I've updated the test using proper information from here. This has simplified this function a bit too!

@r-ash r-ash force-pushed the remove-old-endpoints branch from 724f7ef to eb91c31 Compare September 9, 2024 11:19
@r-ash r-ash requested a review from M-Kusumgar September 9, 2024 13:12
These are failing for annoying to diagnose reasons, but we don't
actually need this code to run on mac.
Copy link
Contributor

@M-Kusumgar M-Kusumgar left a comment

Choose a reason for hiding this comment

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

Mostly looks good to me! i had a couple of questions just to make sure im understanding this correctly!

Comment on lines 176 to 178
## This is kind of gross but logic is, if setFilters is not included
## in an effect, then use all the available filters. So have to replicate
## this here for validation
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not true, https://github.com/mrc-ide/hint/blob/mrc-4856/src/app/static/src/app/store/plotSelections/utils.ts#L59 we initialise filterRefs as empty unless by "available" you mean setFilters on a default effect.

Basically all plots need to have at least one setFilters on the defaultEffect or one of the options in a plot control otherwise nothing shows up on the UI

Comment on lines +220 to +221
## Testthat skips if only calling custom expect function, so add this
## noddy test to force it to run.
Copy link
Contributor

Choose a reason for hiding this comment

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

wow thats annoying

Comment on lines 192 to 194
if (isTRUE(filter_types[[filter_id]])) {
break
}
Copy link
Contributor

Choose a reason for hiding this comment

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

sorry bit confused by this, is this a truthy check on whether the key exists in filter_types and why do we break if the key does exist?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

o damn more silly mistakes here. This is supposed to be if use_shape_regions is true for this filter then skip the check of the options

expect_option_exists(all_option_ids,
effects$setFilterValues[[state_filter_id]],
paste(context, "setFilterValues"),
effect$id)
Copy link
Contributor

Choose a reason for hiding this comment

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

where is effect$id coming from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agh this is some old junk from previous loop which I missed. Should be state_filter_id now, thanks.

Copy link
Contributor

@M-Kusumgar M-Kusumgar left a comment

Choose a reason for hiding this comment

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

happy to approve after that debug is removed, had an optional comment about testing the behaviour of the setFilters effect!

if (isTRUE(filter_types[[filter_id]]$use_shape_regions)) {
## If we're referring to a filter which uses regions from
## shape file, we have no options in metadata. So skip this check.
browser()
Copy link
Contributor

Choose a reason for hiding this comment

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

rogue debug?

Comment on lines 168 to 174
set_filters <- effects$setFilters
if (length(effects$setFilters) == 0) {
set_filters <- default_effects$setFilters
}
expect(length(set_filters) > 0,
paste(context, "setFilters must be set in plot setting or",
"default settings."))
Copy link
Contributor

Choose a reason for hiding this comment

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

while this is currently true for all plots, this is not necessarily true, feel free to leave this in, but you can technically do more with the metadata.

For example, say there was a plot control A and a plot control B and a default effect C. You can have it so that only A contains a setFilters effect for all its settings and B, C do not contain a setFilters. Then when your test gets to plot control B, it will fail this test but every option from plot control A still specifies setFilters so everything in the UI would be fine

if you want to properly test this behaviour i would go one level up, pull our combined setFilters (combined from all combinations of all available plot controls + default effect) and test that none of those combined setFilters are empty. that would test it out properly but up to you whether you want to do this or not

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, added a note about this (feeling a bit lazy!)

Copy link
Contributor

Choose a reason for hiding this comment

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

no problem!

@r-ash r-ash requested a review from M-Kusumgar September 10, 2024 14:26
@r-ash r-ash merged commit 5582cd8 into tmp-epic-plot-cleanup Sep 10, 2024
10 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
Development

Successfully merging this pull request may close these issues.

2 participants