Skip to content

Commit 3ac6871

Browse files
authored
expose OutputFormatEnum instead of ResultFormat to user (#484)
expose OutputFormatEnum instead of ResultFormat to user; mention in the documentation
1 parent 730e61f commit 3ac6871

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

docs/transform_request.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The General Section
3232
^^^^^^^^^^^^^^^^^^^
3333
The General section of the request includes the following fields:
3434

35-
* (Optional) ``OutputFormat``: Can be ``root-ttree`` (default) or ``parquet``
35+
* (Optional) ``OutputFormat``: Can be ``root-ttree`` (default) or ``parquet`` (you can also use the enums ``servicex.OutputFormat.root_ttree`` and ``servicex.OutputFormat.parquet``)
3636
* (Optional) ``Delivery``: Can be ``URLs`` or ``LocalCache`` (default)
3737

3838
In general, if you are running on your laptop away from the ServiceX site and are working with a small amount of

servicex/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@
2727
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
from servicex.databinder_models import Sample, General, ServiceXSpec
2929
from servicex.servicex_client import deliver
30-
from .models import ResultFormat, ResultDestination
30+
from .models import ResultDestination
3131
import servicex.dataset as dataset
3232
import servicex.query as query
3333

34+
OutputFormat = General.OutputFormatEnum
35+
3436
__all__ = [
35-
"ResultFormat",
37+
"OutputFormat",
3638
"ResultDestination",
3739
"Sample",
3840
"General",

tests/test_databinder.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from unittest.mock import patch
33
from pydantic import ValidationError
44

5-
from servicex import ServiceXSpec, dataset
5+
from servicex import ServiceXSpec, dataset, OutputFormat
66
from servicex.query_core import ServiceXException
77
from servicex.servicex_client import ReturnValueException
88
from servicex.dataset import FileList, Rucio
@@ -93,6 +93,21 @@ def test_list_of_root_files():
9393
]
9494

9595

96+
def test_output_format():
97+
spec = basic_spec()
98+
spec['General'] = {'OutputFormat': 'root-ttree'}
99+
ServiceXSpec.model_validate(spec)
100+
spec['General'] = {'OutputFormat': 'parquet'}
101+
ServiceXSpec.model_validate(spec)
102+
spec['General'] = {'OutputFormat': OutputFormat.root_ttree}
103+
ServiceXSpec.model_validate(spec)
104+
spec['General'] = {'OutputFormat': OutputFormat.parquet}
105+
ServiceXSpec.model_validate(spec)
106+
with pytest.raises(ValidationError):
107+
spec['General'] = {'OutputFormat': 'root-tree'}
108+
ServiceXSpec.model_validate(spec)
109+
110+
96111
def test_rucio_did():
97112
spec = ServiceXSpec.model_validate(
98113
basic_spec(

tests/test_dataset_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
import pytest
3131

32-
from servicex import ResultFormat
32+
from servicex.models import ResultFormat
3333
from servicex.dataset_group import DatasetGroup
3434
from servicex.query_core import ServiceXException
3535

0 commit comments

Comments
 (0)