diff --git a/docs/transform_request.rst b/docs/transform_request.rst index 56fdcad0..00b0ac9f 100644 --- a/docs/transform_request.rst +++ b/docs/transform_request.rst @@ -32,7 +32,7 @@ The General Section ^^^^^^^^^^^^^^^^^^^ The General section of the request includes the following fields: -* (Optional) ``OutputFormat``: Can be ``root-ttree`` (default) or ``parquet`` +* (Optional) ``OutputFormat``: Can be ``root-ttree`` (default) or ``parquet`` (you can also use the enums ``servicex.OutputFormat.root_ttree`` and ``servicex.OutputFormat.parquet``) * (Optional) ``Delivery``: Can be ``URLs`` or ``LocalCache`` (default) In general, if you are running on your laptop away from the ServiceX site and are working with a small amount of diff --git a/servicex/__init__.py b/servicex/__init__.py index e31f6df5..dc2bd9e6 100644 --- a/servicex/__init__.py +++ b/servicex/__init__.py @@ -27,12 +27,14 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from servicex.databinder_models import Sample, General, ServiceXSpec from servicex.servicex_client import deliver -from .models import ResultFormat, ResultDestination +from .models import ResultDestination import servicex.dataset as dataset import servicex.query as query +OutputFormat = General.OutputFormatEnum + __all__ = [ - "ResultFormat", + "OutputFormat", "ResultDestination", "Sample", "General", diff --git a/tests/test_databinder.py b/tests/test_databinder.py index 40cd9695..eae36fb3 100644 --- a/tests/test_databinder.py +++ b/tests/test_databinder.py @@ -2,7 +2,7 @@ from unittest.mock import patch from pydantic import ValidationError -from servicex import ServiceXSpec, dataset +from servicex import ServiceXSpec, dataset, OutputFormat from servicex.query_core import ServiceXException from servicex.servicex_client import ReturnValueException from servicex.dataset import FileList, Rucio @@ -93,6 +93,21 @@ def test_list_of_root_files(): ] +def test_output_format(): + spec = basic_spec() + spec['General'] = {'OutputFormat': 'root-ttree'} + ServiceXSpec.model_validate(spec) + spec['General'] = {'OutputFormat': 'parquet'} + ServiceXSpec.model_validate(spec) + spec['General'] = {'OutputFormat': OutputFormat.root_ttree} + ServiceXSpec.model_validate(spec) + spec['General'] = {'OutputFormat': OutputFormat.parquet} + ServiceXSpec.model_validate(spec) + with pytest.raises(ValidationError): + spec['General'] = {'OutputFormat': 'root-tree'} + ServiceXSpec.model_validate(spec) + + def test_rucio_did(): spec = ServiceXSpec.model_validate( basic_spec( diff --git a/tests/test_dataset_group.py b/tests/test_dataset_group.py index f603decf..9fa2ad6a 100644 --- a/tests/test_dataset_group.py +++ b/tests/test_dataset_group.py @@ -29,7 +29,7 @@ import pytest -from servicex import ResultFormat +from servicex.models import ResultFormat from servicex.dataset_group import DatasetGroup from servicex.query_core import ServiceXException