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

Sidecars don't work when changing dataset via the sidebar (under certain conditions) #1855

Open
jameshadfield opened this issue Sep 12, 2024 · 4 comments
Labels
bug Something isn't working source: office hours Issue mentioned during office hours

Comments

@jameshadfield
Copy link
Member

When changing between two datasets via the sidebar dropdown UI, each with a tip frequencies sidecar, we saw someone get a warning banner indicating a failure to normalise frequencies and the sidebar option is not available. The relevant code for the sidebar is:

const allowNormalization = this.props.frequencies.loaded && this.props.tree.loaded &&
checkIfNormalizableFromRawData(
this.props.frequencies.data,
this.props.frequencies.pivots,
this.props.tree.nodes,
this.props.tree.visibility
);
if (!allowNormalization) {
return (
<SidebarSubtitle>(Frequencies cannot be normalized)</SidebarSubtitle>
);

and checkIfNormalizableFromRawData seems to always return true (!)

const allowNormalization = true;
return allowNormalization;

implying a race condition around this.props.frequencies.loaded && this.props.tree.loaded.

Reloading the page works as expected.

I don't have any reproducible datasets (have asked for them), and note that changing https://nextstrain.org/seasonal-flu/h3n2/ha/3y to 2y (via sidebar) works as expected. Perhaps it's dataset specific (hard to understand after skimming the relevant code) or using an old version of auspice (normalisation checking was removed in 7b9495b in 2001)

@jameshadfield jameshadfield added bug Something isn't working source: office hours Issue mentioned during office hours labels Sep 12, 2024
@joverlee521
Copy link
Contributor

I can reproduce locally by changing the dataset via one of the dropdowns that is not the last one, e.g. changing from http://localhost:4000/flu/seasonal/h1n1pdm/ha/12y to na via sidebar triggers the warning.

@jameshadfield
Copy link
Member Author

jameshadfield commented Sep 13, 2024

This bug is only observed when using the Auspice server (i.e. not within nextstrain.org). Steps to reproduce:

  1. provision appropriate datasets
nextstrain remote download nextstrain.org/seasonal-flu/h3n2/ha/2y
nextstrain remote download nextstrain.org/seasonal-flu/h3n2/na/2y
nextstrain remote download nextstrain.org/seasonal-flu/h3n2/ha/3y
  1. Within auspice, load seasonal-flu/h3n2/ha/2y
  2. Use the sidebar to change "ha" to "na".
  3. The error is shown and the entire frequencies panel is missing. The console has a more useful error: TypeError: rawJSON.pivots is undefined

@jameshadfield
Copy link
Member Author

Notes from a briefly looking into this (have to jump to other things now):

In the above example, we use an incomplete URL to fetch the tip frequencies:

this.apiCalls.tipFrequencies = /charon/getDataset?prefix=seasonal-flu/h3n2/na&type=tip-frequencies

(note the missing "2y" from the path). The auspice server redirects to /charon/getDataset?prefix=/seasonal-flu/h3n2/na/2y and thus returns the main dataset JSON. Because this is a valid JSON, we don't have a fetch error and end up with a frequencies parsing error.

There seem to be two potential solutions: have the server redirect and respect the type query (I presume this is what nextstrain.org does, must check), or redesign how we formulate the api calls (addresses) for sidecars.

The server behaves the same way for root-sequence & measurements URLs, so these should also be tested.

@jameshadfield jameshadfield changed the title Normalise frequencies error when changing datasets via sidebar Sidecars don't work when changing dataset via the sidebar (under certain conditions) Sep 13, 2024
@jameshadfield
Copy link
Member Author

Nextstrain org redirect flow:

/charon/getDataset?prefix=seasonal-flu/h3n2/na&type=tip-frequencies is a 307 to /charon/getDataset?prefix=seasonal-flu/h3n2/na/2y&type=tip-frequencies

Auspice (localhost) is:

/charon/getDataset?prefix=seasonal-flu/h3n2/na&type=tip-frequencies is a 302 to charon/getDataset?prefix=/seasonal-flu/h3n2/na/2y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working source: office hours Issue mentioned during office hours
Projects
None yet
Development

No branches or pull requests

2 participants