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

BUG: fix SIA2 session inheritance #490

Merged
merged 2 commits into from
Oct 11, 2023

Conversation

bsipocz
Copy link
Member

@bsipocz bsipocz commented Sep 26, 2023

To close #487

@bsipocz bsipocz added this to the v1.4.3 milestone Sep 26, 2023
@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

Merging #490 (41b80f1) into main (75bcb73) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #490   +/-   ##
=======================================
  Coverage   80.01%   80.01%           
=======================================
  Files          52       52           
  Lines        6039     6039           
=======================================
  Hits         4832     4832           
  Misses       1207     1207           
Files Coverage Δ
pyvo/dal/sia2.py 76.96% <100.00%> (ø)

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

@bsipocz
Copy link
Member Author

bsipocz commented Sep 26, 2023

If I see correctly, all CI failures are due to dc.g-vo.org being offline.

@msdemlei
Copy link
Contributor

msdemlei commented Sep 27, 2023 via email

@@ -221,7 +219,7 @@ def search(self, pos=None, band=None, time=None, pol=None,
instrument=instrument, data_type=data_type,
calib_level=calib_level, target_name=target_name,
res_format=res_format, maxrec=maxrec,
session=session, **kwargs).execute()
session=self._session, **kwargs).execute()
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if this concern is a big deal, but if someone right now sends passes their own session when calling the search method, that would be silently ignored. The alternative is to look for the session into kwargs and use that one if available. At least temporarily.

Copy link
Member Author

Choose a reason for hiding this comment

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

Shouldn't they have used that session in their instance init? (as far as I see we basically pass on self._session at this point in the other classes, too (though sometimes it happens in the create_query method, rather than this high up.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is an interesting question. I understand the concern but feel like breaking someone's existing behavior is unlikely. If we find this is a problem moving forward, we can come back and address it again. The use of kwargs throughout this code makes tracking some of the parameters challenging.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree about kwargs. If I'm not mistaken, these arguments are intended primarily for the requests underlying library so it's easy for someone to specify things like timeout, headers, etc with call. Maybe that's too confusing and we need to add a request attribute map in the service class for that more expert-use purpose.

The bottom line is that we are essentially removing sessions from the list of arguments, silently without giving any warning. There might not be any users of this feature, but if there are, they will have a very hard time understanding what is going on.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've tried to trace some of these kwagrs, and they ended up being an rendered out to be attributes, most of not being used at all. So, if the aim is to pass them along all the way to request, then I would suggest to add a request_kwargs parameter that accepts an dict.

But changing it all at this point would potentially painful for users (though I would say any errors would be easy to fix, or in fact directly highlighting bugs in their usage.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm OK with request_kwargs. And a deprecation warning when kwargs is not empty? A pain, I know, but the right etiquette.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll check, even the deprecation decorators may work, I just never tried them for ** cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

I feel I'm just a broken record with the same ideas (#466) 😅

Copy link
Contributor

@tomdonaldson tomdonaldson left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@tomdonaldson tomdonaldson merged commit 6405cb4 into astropy:main Oct 11, 2023
11 checks passed
@bsipocz bsipocz deleted the BUG_SIA2_session branch October 20, 2023 17:45
@bsipocz bsipocz modified the milestones: v1.4.3, v1.5 Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: SIA2Service.search() method has separate session
4 participants