diff --git a/examples/Uproot_UprootRaw_Dict.py b/examples/Uproot_UprootRaw_Dict.py index dcc0cc72..fd933fb0 100644 --- a/examples/Uproot_UprootRaw_Dict.py +++ b/examples/Uproot_UprootRaw_Dict.py @@ -6,9 +6,6 @@ def uproot_uproot_raw_dict(): query = UprootRaw([{"treename": "reco", "filter_name": "el_pt_NOSYS"}]) spec = { - 'General': { - 'ServiceX': "servicex-uc-af" - }, 'Sample': [{ 'Name': "Uproot_PythonFunction_Dict", 'RucioDID': "user.mtost:user.mtost.singletop.p6026.Jun13", diff --git a/pyproject.toml b/pyproject.toml index 716f1217..c0b46709 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,7 +92,7 @@ develop = [ "servicex[databinder,pandas,test,docs]", ] -[project.entry-points.'servicex.queries'] +[project.entry-points.'servicex.query'] FuncADL_Uproot = "servicex.func_adl.func_adl_dataset:FuncADLQuery_Uproot" FuncADL_ATLASr21 = "servicex.func_adl.func_adl_dataset:FuncADLQuery_ATLASr21" FuncADL_ATLASr22 = "servicex.func_adl.func_adl_dataset:FuncADLQuery_ATLASr22" diff --git a/servicex/__init__.py b/servicex/__init__.py index 565ab123..67c1cdba 100644 --- a/servicex/__init__.py +++ b/servicex/__init__.py @@ -34,11 +34,11 @@ from servicex.uproot_raw.uproot_raw import UprootRawQuery as UprootRaw from servicex.python_dataset import PythonQuery as PythonFunction from servicex.servicex_client import ServiceXClient, deliver -from .query import Query +from .query_core import Query from .models import ResultFormat, ResultDestination from .dataset_group import DatasetGroup from .dataset_identifier import RucioDatasetIdentifier, FileListDataset - +from . import query __all__ = [ "ServiceXClient", @@ -59,5 +59,6 @@ "General", "DefinitionList", "ServiceXSpec", - "deliver" + "deliver", + "query" ] diff --git a/servicex/databinder_models.py b/servicex/databinder_models.py index 0d796d4b..10027da1 100644 --- a/servicex/databinder_models.py +++ b/servicex/databinder_models.py @@ -34,7 +34,7 @@ ) from servicex.dataset_identifier import RucioDatasetIdentifier, FileListDataset -from servicex.query import Query as SXQuery, QueryStringGenerator +from servicex.query_core import Query as SXQuery, QueryStringGenerator from servicex.models import ResultFormat diff --git a/servicex/dataset_group.py b/servicex/dataset_group.py index 505e3425..d7d94f2a 100644 --- a/servicex/dataset_group.py +++ b/servicex/dataset_group.py @@ -30,7 +30,7 @@ from rich.progress import Progress -from servicex.query import Query +from servicex.query_core import Query from servicex.expandable_progress import ExpandableProgress from servicex.func_adl.func_adl_dataset import FuncADLQuery from servicex.models import TransformedResults, ResultFormat diff --git a/servicex/func_adl/func_adl_dataset.py b/servicex/func_adl/func_adl_dataset.py index e54cee24..372dd102 100644 --- a/servicex/func_adl/func_adl_dataset.py +++ b/servicex/func_adl/func_adl_dataset.py @@ -46,7 +46,7 @@ from func_adl import EventDataset, find_EventDataset from func_adl.object_stream import S from servicex.configuration import Configuration -from servicex.query import Query +from servicex.query_core import Query from servicex.func_adl.util import has_tuple from servicex.models import ResultFormat from servicex.query_cache import QueryCache diff --git a/servicex/python_dataset.py b/servicex/python_dataset.py index 3fee1819..5a36fef1 100644 --- a/servicex/python_dataset.py +++ b/servicex/python_dataset.py @@ -30,7 +30,7 @@ from base64 import b64encode from servicex.configuration import Configuration -from servicex.query import Query +from servicex.query_core import Query from servicex.models import ResultFormat from servicex.query_cache import QueryCache from servicex.servicex_adapter import ServiceXAdapter diff --git a/servicex/query/__init__.py b/servicex/query/__init__.py new file mode 100644 index 00000000..6ebc8d36 --- /dev/null +++ b/servicex/query/__init__.py @@ -0,0 +1,38 @@ +# Copyright (c) 2024, IRIS-HEP +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +import sys +if sys.version_info < (3, 10): + from importlib_metadata import entry_points +else: + from importlib.metadata import entry_points + +plugins = entry_points(group='servicex.query') +for _ in plugins: + globals()[_.name] = _.load() diff --git a/servicex/query.py b/servicex/query_core.py similarity index 100% rename from servicex/query.py rename to servicex/query_core.py diff --git a/servicex/servicex_client.py b/servicex/servicex_client.py index 34c2d161..60e7c721 100644 --- a/servicex/servicex_client.py +++ b/servicex/servicex_client.py @@ -34,7 +34,7 @@ from servicex.models import ResultFormat, TransformStatus, TransformedResults from servicex.query_cache import QueryCache from servicex.servicex_adapter import ServiceXAdapter -from servicex.query import ( +from servicex.query_core import ( GenericQuery, QueryStringGenerator, GenericQueryStringGenerator, @@ -76,7 +76,7 @@ def _load_ServiceXSpec( else: from importlib.metadata import entry_points - plugins = entry_points(group="servicex.queries") + plugins = entry_points(group="servicex.query") for _ in plugins: yaml.register_class(_.load()) diff --git a/servicex/uproot_raw/uproot_raw.py b/servicex/uproot_raw/uproot_raw.py index 4aaa9e80..bf4e2c0f 100644 --- a/servicex/uproot_raw/uproot_raw.py +++ b/servicex/uproot_raw/uproot_raw.py @@ -30,7 +30,7 @@ import pydantic from typing import List, Union, Mapping, Optional, get_args -from ..query import QueryStringGenerator +from ..query_core import QueryStringGenerator class TreeSubQuery(pydantic.BaseModel): diff --git a/tests/test_databinder.py b/tests/test_databinder.py index 57af4aed..e78a4672 100644 --- a/tests/test_databinder.py +++ b/tests/test_databinder.py @@ -412,3 +412,8 @@ def test_generic_query(codegen_list): # no codegen specified by generic class query = sx.generic_query(dataset_identifier=spec.Sample[0].RucioDID, query=spec.Sample[0].Query) + + +def test_entrypoint_import(): + """ This will check that we have at least the Python transformer defined in servicex.query """ + from servicex.query import PythonFunction # noqa \ No newline at end of file diff --git a/tests/test_servicex_dataset.py b/tests/test_servicex_dataset.py index 07ca40ef..6c4bcbc4 100644 --- a/tests/test_servicex_dataset.py +++ b/tests/test_servicex_dataset.py @@ -39,7 +39,7 @@ from servicex.models import (TransformStatus, Status, ResultFile, ResultFormat, TransformRequest, TransformedResults) from servicex.query_cache import QueryCache -from servicex.query import ServiceXException +from servicex.query_core import ServiceXException from servicex.servicex_client import ServiceXClient from servicex.uproot_raw.uproot_raw import UprootRawQuery