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

Fixes in JWST login #2807

Merged
merged 18 commits into from Sep 25, 2023
Merged

Conversation

jespinosaar
Copy link
Contributor

Dear Astroquery team,

We realized the login feature in ESA TAP module was not working, as we are now using kwargs. This pull request aims to fix this issue. Thanks in advance for your support!

cc @esdc-esac-esa-int

@jespinosaar jespinosaar added this to the v0.4.7 milestone Aug 10, 2023
@codecov
Copy link

codecov bot commented Aug 10, 2023

Codecov Report

Merging #2807 (40c4098) into main (7956e9a) will increase coverage by 0.13%.
The diff coverage is 68.96%.

@@            Coverage Diff             @@
##             main    #2807      +/-   ##
==========================================
+ Coverage   66.34%   66.48%   +0.13%     
==========================================
  Files         235      235              
  Lines       18077    18077              
==========================================
+ Hits        11994    12019      +25     
+ Misses       6083     6058      -25     
Files Coverage Δ
astroquery/utils/tap/core.py 44.52% <0.00%> (ø)
astroquery/esa/jwst/core.py 80.70% <76.92%> (+4.82%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jespinosaar jespinosaar changed the title JWSTPCR-390: fixes in JWST login Fixes in JWST login Aug 10, 2023
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.

While it's very unlikely that we would routinely find any issues with the login machinery using tests (as we don't have any login credentials in CI, etc.), but I would generally in favour of having some test coverage that directly uses the remote service, rather than fully rely on mocking the expected responses.

This, and the rest of the in-line comments are just comments.

Comment on lines +380 to +381
>>> print(*(column.name for column in table.columns), sep="\n") # doctest: +IGNORE_OUTPUT
"public"
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I would leave this, at least this passes both locally, but also on CI, they way it was.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I skipped these tests, as they will fail when we release the new version. I will create an additional PR when we released, to make them available again.

@@ -898,8 +898,7 @@ def get_product(self, *, artifact_id=None, file_name=None):
output_file_name = self._query_get_product(artifact_id=artifact_id)
err_msg = str(artifact_id)
except Exception as exx:
raise ValueError('Cannot retrieve product for artifact_id '
+ artifact_id + ': %s' % str(exx))
raise ValueError('Cannot retrieve product for artifact_id ' + artifact_id + ': %s' % str(exx))
Copy link
Member

Choose a reason for hiding this comment

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

you've already cleaned up many of these error messages by switching to f-strings, maybe a few more could be done? (your choice, it isn't holding up the PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I have applied the same to other strings.

@@ -1086,7 +1082,7 @@ def __set_additional_parameters(self, param_dict, cal_level,

def __get_quantity_input(self, value, msg):
if value is None:
raise ValueError("Missing required argument: '"+str(msg)+"'")
raise ValueError(f"Missing required argument: '{str(msg)}'")
Copy link
Member

Choose a reason for hiding this comment

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

fyi, no need for the str() any more

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this

@jespinosaar
Copy link
Contributor Author

jespinosaar commented Aug 11, 2023

I agree that it would be a good idea to include remote tests for the login, but we need to find a secure way of including this test user. Anyway, I think we can include it in a different PR.

I will increase the codecov/patch today.

@jespinosaar
Copy link
Contributor Author

Ok, finally all the checks have passed!

@jespinosaar
Copy link
Contributor Author

Hi all, any news on this? Is it necessary to include more improvements? If not, can we merge it?

On the other hand, I think the pre-release procedure is not working as expected, can we create a new version after this is merged?

Thanks in advance!

Copy link
Contributor

@keflavich keflavich left a comment

Choose a reason for hiding this comment

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

@bsipocz lgtm. There's one minor unaddressed comment in the docs, but I think since tests are passing, it is an acceptable change. Mostly this is fixing a real issue, iiuc, and adding tests, with many scattered style changes mixed in.

@bsipocz
Copy link
Member

bsipocz commented Sep 18, 2023

Oh, I'm sorry this has fallen through the cracks. Last time I checked something didn't really work with the remote-data part, let me get back to that today, maybe push a commit and get this merged.

@jespinosaar
Copy link
Contributor Author

Oh, I'm sorry this has fallen through the cracks. Last time I checked something didn't really work with the remote-data part, let me get back to that today, maybe push a commit and get this merged.

Ok! just executed the remote tests and it seems to be working... Anyway, please let me know if you need anything else.

Related to the pre-released version, is this working? Could you please create a new version when merging this PR? thanks in advance!

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.

One minor fix, and this is good to go. Thanks @jespinosaar for the patience.

Comment on lines 63 to 70
@pytest.mark.remote_data
class RemoteData:

def test_login_error(self):
jwst = JwstClass()
with pytest.raises(HTTPError) as err:
jwst.login(user="dummy", password="dummy")
assert "Unauthorized" in err.value.args[0]
Copy link
Member

Choose a reason for hiding this comment

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

This class is not being picked up for testing.

(I'll push a fix for it)

@bsipocz
Copy link
Member

bsipocz commented Sep 25, 2023

I also needed to rebase this, so fixes to the docs builds are being picked up.

@bsipocz bsipocz merged commit 72510b4 into astropy:main Sep 25, 2023
10 checks passed
@jespinosaar
Copy link
Contributor Author

jespinosaar commented Sep 26, 2023

Many thanks for your support @bsipocz, as always! and for the pre-release!

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

3 participants