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

get_obs_products method supports product_type parameter as string or list #2995

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

davidglt
Copy link

The get_obs_products method now checks the input argument product_type with the method _check_list_strings and allows using strings or lists

@pep8speaks
Copy link

pep8speaks commented Apr 23, 2024

Hello @davidglt! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-05-13 08:16:59 UTC

@jespinosaar
Copy link
Contributor

cc @esdc-esac-esa-int

@jespinosaar jespinosaar added this to the v0.4.8 milestone Apr 23, 2024
davidglt pushed a commit to esdc-esac-esa-int/astroquery that referenced this pull request Apr 25, 2024
davidglt pushed a commit to esdc-esac-esa-int/astroquery that referenced this pull request Apr 25, 2024
davidglt pushed a commit to esdc-esac-esa-int/astroquery that referenced this pull request Apr 25, 2024
davidglt pushed a commit to esdc-esac-esa-int/astroquery that referenced this pull request Apr 25, 2024
davidglt pushed a commit to esdc-esac-esa-int/astroquery that referenced this pull request Apr 25, 2024
@davidglt
Copy link
Author

Hi there!
The last commit 61b8b14 only modifies from the file in the main branch the lines to include this PR information, but maybe I have something more wrong :)
Cheers,
David

@jespinosaar
Copy link
Contributor

Hi @davidglt , please rebase your branch. It seems there is a conflict in CHANGES.rst file.

@davidglt
Copy link
Author

Hi there!
After rebase, we have the same problem with the CHANGES.rst file

Cheers,
David

@bsipocz
Copy link
Member

bsipocz commented May 3, 2024

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.

@bsipocz bsipocz force-pushed the ESA_jwst-extend_get_obs_products branch from 2d0bebd to 7b88527 Compare May 3, 2024 02:21
@bsipocz
Copy link
Member

bsipocz commented May 3, 2024

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 astropy in my setup, but it maybe upstream in yours):

$ ~/munka/devel/astroquery [ESA_jwst-extend_get_obs_products|✚ 1…1⚑ 14] $ git remote -v
astropy	git@github.com:astropy/astroquery.git (fetch)
astropy	git@github.com:astropy/astroquery.git (push)
bsipocz	git@github.com:bsipocz/astroquery.git (fetch)
bsipocz	git@github.com:bsipocz/astroquery.git (push)
esdc-esac-esa-int	git@github.com:esdc-esac-esa-int/astroquery (fetch)
esdc-esac-esa-int	git@github.com:esdc-esac-esa-int/astroquery (push)

Have a fresh version of the main repo:

git fetch --all --prune

Interactive rebase on astropy/main. This will automatically get rid of the ~80 commits that you pulled in during the previous rebase. Also, in the interactive mode an editor will pop up. I removed all commits related to the changelog. The rebase was clean, I didn't need to resolve any conflicts, but if there are any, you read the instructions and do --continue until all commits are successfully rebased.

git rebase -i astropy/main

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 push esdc-esac-esa-int, you may have it as origin.

git push esdc-esac-esa-int HEAD:ESA_jwst-extend_get_obs_products -f

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@@ -83,6 +83,15 @@ def __init__(self, *, tap_plus_handler=None, data_handler=None, show_messages=Tr
if show_messages:
self.get_status_messages()

def __check_list_strings(self, list):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a single string is iterable and this will return True, is that the logic you want to do here?

Comment on lines 1006 to 1013

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bsipocz
Copy link
Member

bsipocz commented May 3, 2024

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.

@davidglt davidglt force-pushed the ESA_jwst-extend_get_obs_products branch from 7b88527 to 6e9dfbd Compare May 6, 2024 07:57
@davidglt
Copy link
Author

davidglt commented May 6, 2024

Hi Brigitta, I am working to implement a new test for the product_type parameter as string or list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants