Get list of unique products#3096
Conversation
| products = self.get_product_list(observations) | ||
| unique_products = self._remove_duplicate_products(products) | ||
| if len(unique_products) < len(products): | ||
| log.info("To return all products, use `Observations.get_product_list`") |
There was a problem hiding this comment.
This log message could be slightly more informative if you include the numbers, for example "{len(products) - len(unique_products)} duplicate products removed; To return all products, use Observations.get_product_list"
There was a problem hiding this comment.
Ah never mind, the other log message captures that info! You're way ahead of me :)
|
This looks good! Thanks @snbianco ! |
bsipocz
left a comment
There was a problem hiding this comment.
Looks good, thanks! I would suggest a follow-up docs cleanup PR that would make the links better.
| """ | ||
| Given a "Product Group Id" (column name obsid), returns a list of associated data products with | ||
| unique dataURIs. Note that obsid is NOT the same as obs_id, and inputting obs_id values will result in | ||
| an error. See column documentation `here <https://masttest.stsci.edu/api/v0/_productsfields.html>`__. |
There was a problem hiding this comment.
Nitpicking, but it would be nice to avoid (and also clean up) these types of here links. Some reading in the topics: https://heyoka.medium.com/dont-use-click-here-f32f445d1021
We have a bunch of these already, mostly in the mast module, so I don't hold merging up, but I would really encourage a cleanup.
Added implementation, a test, and documentation for a new function (
Observations.get_unique_product_list). Given observations, the function returns a list of associated data products, each with a unique data URI. This is essentially a wrapper toObservations.get_product_listthat removes duplicate rows before returning.Because
get_product_listis a query method, it should be async and return a response that is then parsed into a Table. Because we need the actual result Table to remove the duplicates, I wasn't able to add this functionality as a parameter to the original function. It's possible that theMast.Caom.Productsservice could filter out duplicates at some point, but I think this is the best solution for now.