-
Notifications
You must be signed in to change notification settings - Fork 162
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
Only support downloading Auspice JSONs if dataset name can be parsed #1804
Changes from all commits
b7c165b
dbfce23
a9c4610
91d98b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import { NODE_VISIBLE, nucleotide_gene } from "../../util/globals"; | |
import { datasetSummary } from "../info/datasetSummary"; | ||
import { isColorByGenotype } from "../../util/getGenotype"; | ||
import { EmptyNewickTreeCreated } from "../../util/exceptions"; | ||
import { getDatasetNamesFromUrl, Dataset } from "../../actions/loadData"; | ||
import { Dataset } from "../../actions/loadData"; | ||
|
||
export const isPaperURLValid = (d) => { | ||
return ( | ||
|
@@ -623,15 +623,19 @@ export const entropyTSV = (dispatch, filePrefix, entropy) => { | |
/** | ||
* Write out Auspice JSON(s) for the current view. We do this by re-fetching the original | ||
* JSON because we don't keep a copy of the unprocessed data around. | ||
* | ||
* | ||
* Sidecar files are not fetched, but we can also download them if desired. | ||
* | ||
* | ||
* Note that we are not viewing a narrative, as the download button functionality is disabled | ||
* for narratives. | ||
*/ | ||
export const auspiceJSON = (dispatch) => { | ||
export const auspiceJSON = (dispatch, datasetNames) => { | ||
const filenames = []; | ||
for (const datasetName of getDatasetNamesFromUrl(window.location.pathname)) { | ||
if (!datasetNames.some(Boolean)) { | ||
console.error(`Unable to fetch empty dataset names: ${JSON.stringify(datasetNames)}`); | ||
return dispatch(errorNotification({message: "Unable to download Auspice JSON (see console for more info)"})) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Perhaps the intention here was There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, thanks for catching that. I meant
Yeah, I added this guard to get error notifications on unexpected use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed up in force-push There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Nice one. I don't know what I meant by suggesting |
||
} | ||
for (const datasetName of datasetNames) { | ||
if (!datasetName) continue; // e.g. no 2nd tree | ||
const filename = datasetName.replace('/', '_') + '.json'; | ||
filenames.push(filename); | ||
|
@@ -647,4 +651,4 @@ export const auspiceJSON = (dispatch) => { | |
}); | ||
} | ||
dispatch(infoNotification({message: `Preparing Auspice JSON(s) for download: ${filenames.join(', ')}`})); | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bug in auspice.us (?) where dragging on two trees results in them being added to the URL. As such,
datasetNames
contains 2 truthy values, and we allow the download, which then fails.Using
dev_multi_h3n2.json
andebola.json
(any two JSONs will do) we get a URL ofhttps://auspice-us-nextstrain-b-q2kkxc.herokuapp.com/dev/multi/h3n2:ebola
, and the following error when trying to download:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I did not realize that the URL gets updated in auspice.us when there's a two trees.
Looks like it's coming from the
changeURLMiddleware
in auspice:auspice/src/middleware/changeURL.js
Lines 236 to 243 in 6955728
I assume the URL should never be updated in auspice.us if you are calling this a bug? How is that configured?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe we just shouldn't rely on the URL parsing here to determine if download is supported. We can add a
disableAuspiceJsonDownload
config param to the extensions and have auspice.us explicitly disable the downloads.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auspice.us, once it's parsed the dropped files, initialises the Auspice viz via:
and the intention is that Auspice updates the pathname (URL) to the empty string via:
auspice/src/middleware/changeURL.js
Lines 231 to 234 in 6955728
and then the switch statement ends. But
""
is falsey, so we keep going in the switch statement and then, when there are two trees, we hit the case you linked above. I think checking ifpathnameShouldBe
is a property on the action rather than just the truthyness of its value is the correct fix.I think once the bugs identified here are fixed the URL parsing will still be appropriate. (The particular bug in this thread is, strictly speaking, separate to this PR, but it'd be good to just fix it here.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in a9c4610.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed in auspice.us test app that the URL does not update with multiple trees.