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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
1.4.3 (unreleased)
==================

- Fix session inheritance in SIA2. [#490]


1.4.2 (2023-08-16)
==================
Expand Down
10 changes: 4 additions & 6 deletions pyvo/dal/sia2.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def search(url, pos=None, band=None, time=None, pol=None,
_SIA2_PARAMETERS

"""
service = SIA2Service(url)
service = SIA2Service(url, session=session)
return service.search(pos=pos, band=band, time=time, pol=pol,
field_of_view=field_of_view,
spatial_resolution=spatial_resolution,
Expand All @@ -130,8 +130,7 @@ def search(url, pos=None, band=None, time=None, pol=None,
facility=facility, collection=collection,
instrument=instrument, data_type=data_type,
calib_level=calib_level, target_name=target_name,
res_format=res_format, maxrec=maxrec,
session=session, **kwargs)
res_format=res_format, maxrec=maxrec, **kwargs)


search.__doc__ = search.__doc__.replace('_SIA2_PARAMETERS',
Expand Down Expand Up @@ -200,8 +199,7 @@ def search(self, pos=None, band=None, time=None, pol=None,
spectral_resolving_power=None, exptime=None,
timeres=None, publisher_did=None, facility=None, collection=None,
instrument=None, data_type=None, calib_level=None,
target_name=None, res_format=None, maxrec=None, session=None,
**kwargs):
target_name=None, res_format=None, maxrec=None, **kwargs):
"""
Performs a SIA2 search against a SIA2 service

Expand All @@ -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) 😅



class SIA2Query(DALQuery, AxisParamMixin):
Expand Down