get_obs_products method supports product_type parameter as string or list#2995
Conversation
|
Hi there! |
|
Hi @davidglt , please rebase your branch. It seems there is a conflict in CHANGES.rst file. |
|
Hi there! Cheers, |
|
I'm not exactly sure what went wrong with the rebase here, I suspect it might not been rebased on the correct branch. Given that there are new conflicts I do a rebase again and will report back the command history I will have used. |
2d0bebd to
7b88527
Compare
|
Given that there were a lot of incorrect edits for the changelog, I removed those commits during the rebase and instead added a single clean on once the rest has been rebased. Here are the commands: Make sure you have the astropy/astroquery repo added as a git remote (I call this Have a fresh version of the main repo:
Interactive rebase on
Once the rebase is done, I edited the changelog file and added that commit. Now, the important part (which might have been the step that didn't worked previously) is to force push the branch back to github. I call the ESAC fork
|
bsipocz
left a comment
There was a problem hiding this comment.
Please add a test that covers the list case for product_type input. Also see the inline comments as I suspect the a bug, but also suggest a shorter solution for the enhancement.
| if show_messages: | ||
| self.get_status_messages() | ||
|
|
||
| def __check_list_strings(self, list): |
There was a problem hiding this comment.
I would strongly advise calling the parameter something else than list to avoid overriding the list()
| def __check_list_strings(self, list): | ||
| if list is None: | ||
| return False | ||
| if list and all(isinstance(elem, str) for elem in list): |
There was a problem hiding this comment.
a single string is iterable and this will return True, is that the logic you want to do here?
|
|
||
| if self.__check_list_strings(product_type): | ||
| if type(product_type) is list: | ||
| tap_product_type = ",".join(str(elem) for elem in product_type) | ||
| else: | ||
| tap_product_type = product_type | ||
| else: | ||
| tap_product_type = None |
There was a problem hiding this comment.
this function is only used in this one place, so I would instead suggest something in-place here along the line of the following few line. Arguably this doesn't gracefully handle the case when the input list is not full of strings, but the docs calls for strings, so duct-typeing should be sufficient. And with this the extra private function is not needed either.
| if self.__check_list_strings(product_type): | |
| if type(product_type) is list: | |
| tap_product_type = ",".join(str(elem) for elem in product_type) | |
| else: | |
| tap_product_type = product_type | |
| else: | |
| tap_product_type = None | |
| if isinstance(product_type, list): | |
| tap_product_type = ",".join(str(elem) for elem in product_type) | |
| elif isinstance(product_type, str): | |
| tap_product_type = product_type | |
| else: | |
| tap_product_type = None |
There was a problem hiding this comment.
Brigitta, thank you very much for your comments and patience!
I was not using the --force in the push, my fault :)
About this method "check_list_strings" is used as in other submodules (ex. hubble), but you’re right, in jwst no, I can delete it and check the entries directly in "get_obs_products".
Cheers,
David
|
Also, @davidglt - if you add the email address you made the commits with to your github profile, these commits will properly show up as your contributions. |
7b88527 to
6e9dfbd
Compare
|
Hi Brigitta, I am working to implement a new test for the product_type parameter as string or list |
|
Hi Brigitta, Thanks! |
|
Thanks @davidglt! we still need to include the entry in the changelog. |
I'm travelling in the coming week so PR reviews and merges may be delayed. Sorry about that. |
78d03ec to
d7bcbbc
Compare
|
Hi Brigitta, |
|
Hi Brigitta, |
bsipocz
left a comment
There was a problem hiding this comment.
Please add a test for product_type being a list.
Hi @davidglt , I will help you with the test. |
|
Hello!
Cheers, |
We have done an online test in docs/esa/jwst/jwst.rst, do you want an offline test too or is that enough? |
Hi Brigitta, |
bsipocz
left a comment
There was a problem hiding this comment.
Some minor comments about the tests, happy to merge as is and leave that for a future cleanup, or wait here.
| is_url=True) | ||
| params_dict['planeid'] = plane_ids | ||
|
|
||
| if type(product_type) is list: |
There was a problem hiding this comment.
| if type(product_type) is list: | |
| if isinstance(product_type, list): |
| shutil.rmtree(output_file_full_path_dir) | ||
|
|
||
| # Test product_type paramater with a list | ||
| output_file_full_path_dir = os.getcwd() + os.sep + "temp_test_jwsttap_get_obs_products_1" |
There was a problem hiding this comment.
I see that all these are inherited from above, so these are generic cleanup comments, not necessary to address them for merging this particular PR:
os.path.joindoes this much nicer than creating the output string like this.- the try except below is not really necessary for the tests. If the test fail with OSError, then I presume the developer/maintainer knows how to read the traceback.
- It may be worth to do parametrization of the
product_typeinstead of copying practically the same code (e.g. look for the usage ofpytest.mark.parametrizein e.g the esasky tests) - overall, it is better if tests are made smaller, so e.g. here if there is copied code, it may instead land in a separate test as opposed to be added after an already existing one.
|
Hi @bsipocz , |
|
@jespinosaar - Yes, that sounds good to me. I'll rebase to fix the conflict, and then merge this one as is. |
…he product_type attribute
…) in get_obs_products method. Improve the product_type comments in get_obs_products method.
d0f7e1a to
bb734e0
Compare
|
Thank you! |
The get_obs_products method now checks the input argument product_type with the method _check_list_strings and allows using strings or lists