Skip to content

Commit ac8b427

Browse files
committed
Update examples doc
1 parent 217869e commit ac8b427

File tree

4 files changed

+69
-47
lines changed

4 files changed

+69
-47
lines changed

docs/examples.rst

Lines changed: 63 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,68 @@ Here are some examples of how to use the ServiceX client to extract data from a
44
examples shows the three ways to specify a request: as a YAML file, as a Python dictionary, and
55
as a typed Python object.
66

7-
The ServiceX Deliver Function
8-
-----------------------------
9-
The `deliver` function is used to submit a request to ServiceX. It takes a request in one of the
10-
three formats and returns a list `TransformedResult` objects. Each `TransformedResult` object
11-
is represents the result of a single sample in the request. The `TransformedResult` object
12-
contains the name of the sample, the output format, and a list of URLs or local file paths
13-
where the results can be found.
147

15-
How to Use YAML Specification
16-
-----------------------------
17-
In order to consume the YAML specification and pass it to the ServiceX `deliver` function
18-
you can use the following code:
8+
Examples For Each Query Type
9+
------------------
10+
Examples for each query type (Uproot-Raw, Func_ADL Uproot, Python Function)
11+
and three different representations (Python Dictionary, Python Typed Object, and YAML).
12+
Note that all examples extract the same branch of the same tree (`ROOT TTree`) from
13+
the same :ref:`dataset <label_dataset>`.
1914

20-
.. code:: python
2115

22-
from servicex import deliver
16+
Uproot-Raw Query Example
17+
~~~~~~~~~~~~~~~~~~~~
18+
This example uses the raw uproot query type to extract the `AnalysisElectronsAuxDyn.pt` branch
19+
from the `CollectionTree` tree in ATLAS PHYSLITE OpenData Dataset.
2320

24-
print(
25-
deliver("config_Uproot_FuncADL.yaml")
26-
)
21+
.. tabs::
22+
23+
.. tab:: *Python Dict*
2724

28-
Raw Uproot Example
29-
------------------
30-
This example uses the raw uproot query type to extract the `AnalysisElectronsAuxDyn.pt` branch from the `CollectionTree` tree
31-
in ATLAS PHYSLITE OpenData Dataset.
25+
.. literalinclude:: ../examples/UprootRaw_Dict.py
26+
:language: python
27+
28+
.. tab:: *Python Typed Object*
3229

33-
.. tabs::
30+
.. literalinclude:: ../examples/UprootRaw_Typed.py
31+
:language: python
3432

3533
.. tab:: *YAML*
3634

3735
.. literalinclude:: ../examples/config_UprootRaw.yaml
3836
:language: yaml
3937

38+
39+
Func_ADL Uproot Query Example
40+
~~~~~~~~~~~~~~~~~~~~
41+
This example uses an Func_ADL to extract the `AnalysisElectronsAuxDyn.pt` branch
42+
from the `CollectionTree` tree in ATLAS PHYSLITE OpenData Dataset.
43+
44+
.. tabs::
45+
4046
.. tab:: *Python Dict*
4147

42-
.. literalinclude:: ../examples/UprootRaw_Dict.py
48+
.. literalinclude:: ../examples/FuncADL_Uproot_Dict.py
4349
:language: python
44-
50+
4551
.. tab:: *Python Typed Object*
4652

47-
.. literalinclude:: ../examples/UprootRaw_Typed.py
53+
.. literalinclude:: ../examples/FuncADL_Uproot_Typed.py
4854
:language: python
4955

56+
.. tab:: *YAML*
5057

51-
Python Function Example
52-
-----------------------
53-
This example uses an uproot python function to extract the `AnalysisElectronsAuxDyn.pt` branch from the `CollectionTree` tree
54-
in ATLAS PHYSLITE OpenData Dataset. Note that you can specify a python function
55-
even in a yaml file.
58+
.. literalinclude:: ../examples/config_FuncADL_Uproot.yaml
59+
:language: yaml
5660

57-
.. tabs::
5861

59-
.. tab:: *YAML*
62+
Python Function Query Example
63+
~~~~~~~~~~~~~~~~~~~~
64+
This example uses an uproot python function to extract the `AnalysisElectronsAuxDyn.pt` branch
65+
from the `CollectionTree` tree in ATLAS PHYSLITE OpenData Dataset.
66+
Note that you can specify a python function even in a yaml file.
6067

61-
.. literalinclude:: ../examples/config_PythonFunction.yaml
62-
:language: yaml
68+
.. tabs::
6369

6470
.. tab:: *Python Dict*
6571

@@ -71,25 +77,35 @@ even in a yaml file.
7177
.. literalinclude:: ../examples/PythonFunction_Typed.py
7278
:language: python
7379

80+
.. tab:: *YAML*
7481

75-
Func_ADL Uproot Example
76-
-----------------------
77-
This example uses an Func_ADL to extract the `AnalysisElectronsAuxDyn.pt` branch from the `CollectionTree` tree
78-
in ATLAS PHYSLITE OpenData Dataset.
82+
.. literalinclude:: ../examples/config_PythonFunction.yaml
83+
:language: yaml
7984

80-
.. tabs::
8185

82-
.. tab:: *YAML*
86+
The ServiceX Deliver Function
87+
-----------------------------
88+
The `deliver` function is used to submit a request to ServiceX. It takes a request in one of the
89+
three formats and returns a python dictionary with the name of the sample as a key
90+
and a list of URLs or local file paths as a value.
8391

84-
.. literalinclude:: ../examples/config_FuncADL_Uproot.yaml
85-
:language: yaml
8692

87-
.. tab:: *Python Dict*
93+
How to Use YAML Specification
94+
-----------------------------
95+
YAML specification can be consumed by passing it to the ServiceX `deliver` function.
96+
You can use the following code:
8897

89-
.. literalinclude:: ../examples/FuncADL_Uproot_Dict.py
90-
:language: python
98+
.. code:: python
9199
92-
.. tab:: *Python Typed Object*
100+
from servicex import deliver
93101
94-
.. literalinclude:: ../examples/FuncADL_Uproot_Typed.py
95-
:language: python
102+
print(
103+
deliver("config_Uproot_FuncADL.yaml")
104+
)
105+
106+
.. _label_dataset:
107+
The Dataset in Examples
108+
-----------------------
109+
The dataset in the examples is publically accessible ATLAS Open Data
110+
(`ATLAS DAOD PHYSLITE format Run 2 2016 proton-proton collision data
111+
<https://opendata.cern.ch/record/80001>`_).

examples/config_FuncADL_Uproot.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# File: config_FuncADL_Uproot.yaml
2+
13
Sample:
24
- Name: Uproot_FuncADL_YAML
35
Dataset: !FileList

examples/config_PythonFunction.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# File: config_PythonFunction.yaml
2+
13
Sample:
24
- Name: Uproot_PythonFunction_YAML
35
Dataset: !FileList

examples/config_UprootRaw.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# File: config_UprootRaw.yaml
2+
13
Sample:
24
- Name: UprootRaw_YAML
35
Dataset: !FileList

0 commit comments

Comments
 (0)