From c7c3bb9e0bf4f360877f6ab7e7e13608d09b8f26 Mon Sep 17 00:00:00 2001 From: msdemlei Date: Thu, 8 Feb 2024 06:21:15 -0800 Subject: [PATCH 1/3] Adding session to service interface --- pyvo/registry/regtap.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/pyvo/registry/regtap.py b/pyvo/registry/regtap.py index e6a1b532..1ada2226 100644 --- a/pyvo/registry/regtap.py +++ b/pyvo/registry/regtap.py @@ -417,7 +417,7 @@ def __repr__(self): f"description={self.capability_description!r}, " f"url={self.access_url!r})") - def to_service(self): + def to_service(self, *, session=None): if self.type == "vr:webbrowser": return _BrowserService(self.access_url, self.capability_description) @@ -434,9 +434,13 @@ def to_service(self): if service_class == sia2.SIA2Service: return service_class(self.access_url, capability_description=self.capability_description, - check_baseurl=False) + check_baseurl=False, + session=session) else: - return service_class(self.access_url, capability_description=self.capability_description) + return service_class( + self.access_url, + capability_description=self.capability_description, + session=session) def supports(self, standard_id): """returns true if we believe the interface should be able to talk @@ -802,9 +806,10 @@ def get_interface(self, *, return candidates[0] - def get_service(self, service_type: str = None, *, - lax: bool = False, - keyword: str = None): + def get_service(self, service_type = None, *, + lax = False, + keyword = None, + session = None): """ return an appropriate DALService subclass for this resource that can be used to search the resource using service_type. @@ -849,6 +854,10 @@ def get_service(self, service_type: str = None, *, service. Use list_interfaces to find such a unique description fragment. + session : object + optional requests session to use to communicate with the service + constructed. + Returns ------- `pyvo.dal.DALService` @@ -863,7 +872,7 @@ def get_service(self, service_type: str = None, *, list_interfaces : return a list with all the available services. """ return self.get_interface(service_type=service_type, lax=lax, std_only=True, - keyword=keyword).to_service() + keyword=keyword).to_service(session=session) @property def service(self): From 58c30ba1589edffe188db1d455357b93726bbc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Tue, 27 Aug 2024 15:51:26 -0700 Subject: [PATCH 2/3] DOC: adding changelog and fix style --- CHANGES.rst | 3 +++ pyvo/registry/regtap.py | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 9d2b53bb..b7c78bfb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -61,6 +61,9 @@ Deprecations and Removals - Added `'sia1'` as servicetype for registry searches. [#583] +- Adding ``session`` kwarg to allow to pass a session along when turning + an Interface into a service via ``Interface.to_service``. [#590] + 1.5.2 (2024-05-22) ================== diff --git a/pyvo/registry/regtap.py b/pyvo/registry/regtap.py index 1ada2226..1b096a46 100644 --- a/pyvo/registry/regtap.py +++ b/pyvo/registry/regtap.py @@ -806,10 +806,10 @@ def get_interface(self, *, return candidates[0] - def get_service(self, service_type = None, *, - lax = False, - keyword = None, - session = None): + def get_service(self, service_type: str = None, *, + lax: bool = False, + keyword: str = None, + session: object = None): """ return an appropriate DALService subclass for this resource that can be used to search the resource using service_type. From adc5c7e08bbdf1e66eeaad61d5b2fdd0b58a9395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Tue, 27 Aug 2024 15:58:45 -0700 Subject: [PATCH 3/3] DOC: some service type cleanup --- pyvo/registry/regtap.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pyvo/registry/regtap.py b/pyvo/registry/regtap.py index 1b096a46..0feaf8f0 100644 --- a/pyvo/registry/regtap.py +++ b/pyvo/registry/regtap.py @@ -940,15 +940,16 @@ def search(self, *args, **keys): the DAL service type would expect. See the documentation for the appropriate service type: - ============ ========================================= + ============ =========================================== Service type Use the argument syntax for - ============ ========================================= + ============ =========================================== catalog :py:meth:`pyvo.dal.scs.SCSService.search` - image :py:meth:`pyvo.dal.sia.SIAService.search` - spectrum :py:meth:`pyvo.dal.ssa.SSAService.search` + sia :py:meth:`pyvo.dal.sia.SIAService.search` + sia2 :py:meth:`pyvo.dal.sia2.SIA2Service.search` + ssa :py:meth:`pyvo.dal.ssa.SSAService.search` line :py:meth:`pyvo.dal.sla.SLAService.search` database *not yet supported* - ============ ========================================= + ============ =========================================== Raises ------