From 899308fdb1b0dfec55e615cebdcccc4fc5cff925 Mon Sep 17 00:00:00 2001 From: Gorodn Watts Date: Wed, 1 Jan 2025 02:22:08 -0500 Subject: [PATCH] Correctly create the SX Adaptor --- servicex/servicex_client.py | 9 ++++++--- tests/test_servicex_client.py | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/servicex/servicex_client.py b/servicex/servicex_client.py index b25a18db..6d99253e 100644 --- a/servicex/servicex_client.py +++ b/servicex/servicex_client.py @@ -254,9 +254,12 @@ def __init__(self, backend=None, url=None, config_path=None): elif backend: if backend not in self.endpoints: raise ValueError(f"Backend {backend} not defined in .servicex file") - self.servicex = ServiceXAdapter( - self.endpoints[backend].endpoint, - refresh_token=self.endpoints[backend].token, + ep = self.endpoints[backend] + self.servicex = ( + ep.adapter if ep.adapter is not None else ServiceXAdapter( + self.endpoints[backend].endpoint, + refresh_token=self.endpoints[backend].token, + ) ) self.query_cache = QueryCache(self.config) diff --git a/tests/test_servicex_client.py b/tests/test_servicex_client.py index e3c0ef70..b348d156 100644 --- a/tests/test_servicex_client.py +++ b/tests/test_servicex_client.py @@ -32,6 +32,7 @@ from servicex.query_cache import QueryCache from servicex.servicex_adapter import ServiceXAdapter from servicex.servicex_client import ServiceXClient +from servicex.configuration import Configuration, Endpoint @fixture @@ -79,3 +80,20 @@ def test_delete_transform(mock_cache, servicex_adaptor): sx = ServiceXClient(config_path="tests/example_config.yaml") sx.delete_transform("123-45-6789") servicex_adaptor.delete_transform.assert_called_once_with("123-45-6789") + + +def test_adaptor_created(mock_cache): + class my_adaptor: + pass + + my_backend = my_adaptor() + Configuration.register_endpoint( + Endpoint( + name="my-backend", + adapter=my_backend, + endpoint="", + ) + ) + + sx = ServiceXClient(config_path="tests/example_config.yaml", backend="my-backend") + assert sx.servicex == my_backend