Skip to content

Commit

Permalink
Correctly create the SX Adaptor
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonwatts committed Jan 1, 2025
1 parent ed9f9f2 commit 899308f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
9 changes: 6 additions & 3 deletions servicex/servicex_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions tests/test_servicex_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 899308f

Please sign in to comment.