Conversation
… data
Choosing 'download' on the share form built an astropy Table from an empty
row list, which has no columns, so sorting it by timestamp raised
ValueError: {'timestamp'} is not a subset of table columns.
This is reachable from both share routes. The DataProduct list share form
offers 'download' but renders no share-box checkboxes, so the selection is
always empty there and the download always failed. On the target photometry
list the same happened whenever no boxes were ticked.
download_data() now returns None when the selection matches no photometry,
and the view reports that to the user instead of raising.
Fixes TOMToolkit#1631
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1631
Choosing "download" on the share form builds an astropy
Tablefrom a list of row dicts. When the selection is empty that list is empty, so the table has no columns at all, andtable.sort(['timestamp'])raisesValueError: {'timestamp'} is not a subset of table columns. That surfaces as a 500, which is the traceback in the issue.It turns out this isn't specific to FITS files, or to data products at all. Two routes reach
DataShareView:dataproducts:sharefrom the data product list, anddataproducts:share_allfrom the target photometry list. Theshare-boxcheckboxes that fill the selection are only rendered inphotometry_datalist_for_target.html, so on the data product page the selection is always empty and download fails every time regardless of what the file is. The reporter's URL,/dataproducts/data/3/share/, is that route. The photometry page fails the same way if you submit without ticking anything.Both cases have the same cause, so there's one guard for them.
download_data()now returnsNonewhen the selection matches no photometry, and the view reports that withmessages.errorinstead of raising.sharing_feedback_handlermoved inside theelsebranch, which looks like an unrelated change but isn't: the download branch used to return unconditionally so it could never reach that call, and without the moveresponsewould be unbound on the new path.There's a second half I deliberately left alone.
download_dataignoresproduct_identirely, so "download" on a data product can't do what the button implies even once it stops erroring. Whether that option should be removed from that form (get_sharing_destination_options(include_download=False)already exists) or should stream the file instead felt like that was the team's call. Happy to fix if you wantTesting
Three tests added to
TestShareDataProducts, covering the empty selection on both routes and the normal case still downloading. Both empty-selection tests fail with the originalValueErrorwhen the two source files are reverted todev, so they genuinely guard the bug rather than passing on their own. The CSV test asserts on parsed rows rather than raw substrings, because a timestamp like21:47:17.512345contains a brightness-looking17.5.