Query classes

All the query classes are also made available under the package servicex.query and can be imported from there:

So, for example,

from servicex.query import FuncADL_Uproot

is equivalent to

from servicex.func_adl.func_adl_dataset import FuncADLQuery_Uproot

Uproot-Raw queries

class servicex.uproot_raw.uproot_raw.UprootRawQuery(query: List[TreeSubQuery | CopyHistogramSubQuery] | TreeSubQuery | CopyHistogramSubQuery, default_codegen: str = 'uproot-raw')[source]
generate_selection_string()[source]

override with the selection string to send to ServiceX

pydantic model servicex.uproot_raw.uproot_raw.CopyHistogramSubQuery[source]

Request the copying of a ROOT object from the input file to the output.

Parameters:

copy_histograms – (typing.Union[typing.List[str], str]) Objects to copy

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

field copy_histograms: List[str] | str [Required]

Objects to copy

pydantic model servicex.uproot_raw.uproot_raw.TreeSubQuery[source]
Express an uproot-raw query on an ntuple. Arguments have the same meaning as the

ones of the same name for uproot.arrays(): https://uproot.readthedocs.io/en/stable/uproot.behaviors.TBranch.HasBranches.html#uproot-behaviors-tbranch-hasbranches-arrays

Parameters:
  • treename – (typing.Union[typing.Mapping[str, str], typing.List[str], str]) Name of input ntuple in file

  • expressions – (typing.Union[str, typing.List[str], NoneType]) Awkward Array expressions to evaluate for output

  • cut – (typing.Optional[str]) Awkward Array expressions to select passing rows

  • filter_name – (typing.Union[str, typing.List[str], NoneType]) Expression to filter the list of considered input variables by name

  • filter_typename – (typing.Union[str, typing.List[str], NoneType]) Expression to filter the list of considered input variables by type name

  • aliases – (typing.Optional[typing.Mapping[str, str]]) Define aliases to use in computation and expressions

  • fail_on_missing_trees – (typing.Optional[bool]) Make queries fail if input trees are missing (default False)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

field treename: Mapping[str, str] | List[str] | str [Required]

Name of input ntuple in file

field expressions: str | List[str] | None = None

Awkward Array expressions to evaluate for output

field cut: str | None = None

Awkward Array expressions to select passing rows

field filter_name: str | List[str] | None = None

Expression to filter the list of considered input variables by name

field filter_typename: str | List[str] | None = None

Expression to filter the list of considered input variables by type name

field aliases: Mapping[str, str] | None = None

Define aliases to use in computation and expressions

field fail_on_missing_trees: bool | None = None

Make queries fail if input trees are missing (default False)

Python queries

class servicex.python_dataset.PythonFunction(python_function: str | Callable | None = None)[source]
generate_selection_string() str[source]

override with the selection string to send to ServiceX

FuncADL queries

class servicex.func_adl.func_adl_dataset.FuncADLQuery(item_type: Type = typing.Any)[source]

ServiceX Dataset class that uses func_adl query syntax.

as_qastle()[source]

Generate Qastle from this AST

Returns:

Qastle representation of the target’s AST

check_data_format_request(f_name: str)[source]

Required override of EventDataset

async execute_result_async(a: AST, title: str | None = None) Any[source]

Required override of EventDataset

generate_qastle(a: AST) str[source]

Generate the qastle from the ast of the query.

1. The top level function is already marked as being “ok” 1. If the top level function is something we have to process locally,

then we strip it off.

Parameters:

a (ast.AST) – The complete AST of the request.

Returns:

Qastle that should be sent to servicex

Return type:

str

generate_selection_string() str[source]

override with the selection string to send to ServiceX

set_tree(tree_name: str) FuncADLQuery[T][source]

Set the tree name for the query. :param tree_name: Name of the tree to use for the query :type tree_name: str

Returns:

The Dataset with the tree appended to the first call object

class servicex.func_adl.func_adl_dataset.FuncADLQuery_ATLASr21(item_type: Type = typing.Any)[source]
class servicex.func_adl.func_adl_dataset.FuncADLQuery_ATLASr22(item_type: Type = typing.Any)[source]
class servicex.func_adl.func_adl_dataset.FuncADLQuery_ATLASxAOD(item_type: Type = typing.Any)[source]
class servicex.func_adl.func_adl_dataset.FuncADLQuery_CMS(item_type: Type = typing.Any)[source]
class servicex.func_adl.func_adl_dataset.FuncADLQuery_Uproot(item_type: Type = typing.Any)[source]
generate_selection_string()[source]

override with the selection string to send to ServiceX