Skip to main content

Submit Functional Queries to a ServiceX endpoint.

Project description

func_adl_servicex

Send func_adl expressions to a ServiceX endpoint

GitHub Actions Status Code Coverage

PyPI version Supported Python versions

Introduction

This package contains the single object ServiceXSourceXAOD and ``ServiceXSourceUpROOTwhich can be used as a root of afunc_adl` expression to query large LHC datasets from an active `ServiceX` instance located on the net.

See below for simple examples.

Further Information

  • servicex documentation
  • func_adl documentation

Usage

To use func_adl on servicex, the only func_adl package you only need to install this package. All others required will be pulled in as dependencies of this package.

Using the xAOD backend

See the further information for documentation above to understand how this works. Here is a quick sample that will run against an ATLAS xAOD backend in servicex to get out jet pt's for those jets with pt > 30 GeV.

from func_adl_servicex import ServiceXSourceXAOD

dataset_xaod = "mc15_13TeV:mc15_13TeV.361106.PowhegPythia8EvtGen_AZNLOCTEQ6L1_Zee.merge.DAOD_STDM3.e3601_s2576_s2132_r6630_r6264_p2363_tid05630052_00"
ds = ServiceXSourceXAOD(dataset_xaod)
data = (
    ds
    .SelectMany('lambda e: (e.Jets("AntiKt4EMTopoJets"))')
    .Where('lambda j: (j.pt()/1000)>30')
    .Select('lambda j: j.pt()')
    .AsAwkwardArray(["JetPt"])
    .value()
)

print(data['JetPt'])

Using the CMS Run 1 AOD backend

See the further information for documentation above to understand how this works. Here is a quick sample that will run against an CMS Run 1 AOD backend in servicex. It turns against a 6 TB CMS Open Data dataset, selecting global muons with a pT greater than 30 GeV.

from func_adl_servicex import ServiceXSourceCMSRun1AOD

dataset_xaod = "cernopendata://16"
ds = ServiceXSourceCMSRun1AOD(dataset_xaod)
data = (
    ds
    .SelectMany(lambda e: e.TrackMuons("globalMuons"))
    .Where(lambda m: m.pt() > 30)
    .Select(lambda m: m.pt())
    .AsAwkwardArray(['mu_pt'])
    .value()
)

print(data['mu_pt'])

Using the uproot backend

See the further information for documentation above to understand how this works. Here is a quick sample that will run against a ROOT file (TTree) in the uproot backend in servicex to get out jet pt's. Note that the image name tag is likely wrong here. See XXX to get the current one.

from servicex import ServiceXDataset
from func_adl_servicex import ServiceXSourceUpROOT


dataset_uproot = "user.kchoi:user.kchoi.ttHML_80fb_ttbar"
uproot_transformer_image = "sslhep/servicex_func_adl_uproot_transformer:issue6"

sx_dataset = ServiceXDataset(dataset_uproot, image=uproot_transformer_image)
ds = ServiceXSourceUpROOT(sx_dataset, "nominal")
data = (
    ds.Select("lambda e: {
        'lep_pt_1': e.lep_Pt_1,
        'lep_pt_2': e.lep_Pt_2
        }")
    .value()

print(data)

Running on Local Datasets

It is possible to run on local files. This works well when testing or building out your code, but is horrible if you need to run on a large number of files. It is recommended to use this only with a single file. It is, for the most part, a drop-in replacement for the ServiceX backend version.

First, you must install the local variant of func_adl_servicex. If you are using pip, you can do the following:

pip install func_adl_servicex[local]

With that installed, the following will work:

from func_adl_servicex import SXLocalxAOD

dataset_xaod = "my_local_xaod.root"
ds = SXLocalxAOD(dataset_xaod)
data = (ds
    .SelectMany('lambda e: (e.Jets("AntiKt4EMTopoJets"))')
    .Where('lambda j: (j.pt()/1000)>30')
    .Select('lambda j: j.pt()')
    .AsAwkwardArray(["JetPt"])
    .value()
)

print(data['JetPt'])

And replace SXLocalxAOD with SXLocalCMSRun1AOD for using CMS backend (and, of course, update the query).

Development

PR's are welcome! Feel free to add an issue for new features or questions.

The master branch is the most recent commits that both pass all tests and are slated for the next release. Releases are tagged. Modifications to any released versions are made off those tags.

Qastle

This is for people working with the back-ends that run in servicex.

This is the qastle produced for an xAOD dataset:

(call EventDataset 'ServiceXDatasetSource')

(the actual dataset name is passed in the servicex web API call.)

This is the qastle produced for a ROOT flat file:

(call EventDataset 'ServiceXDatasetSource' 'tree_name')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

func_adl_servicex-2.0b2.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

func_adl_servicex-2.0b2-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file func_adl_servicex-2.0b2.tar.gz.

File metadata

  • Download URL: func_adl_servicex-2.0b2.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.13

File hashes

Hashes for func_adl_servicex-2.0b2.tar.gz
Algorithm Hash digest
SHA256 09ddfd40a037a76d0e443865db3fd5a9556da033ad64c731d47bdbb64f150547
MD5 def18770f1f6762923a2d4edd73abc71
BLAKE2b-256 e6bcb4781ad68c26cd1bb810b88d45f04c667fb47f23520322b1264725f99cb3

See more details on using hashes here.

Provenance

File details

Details for the file func_adl_servicex-2.0b2-py3-none-any.whl.

File metadata

  • Download URL: func_adl_servicex-2.0b2-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.13

File hashes

Hashes for func_adl_servicex-2.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 4f8b4b044cf73ef1bcb0b1d578bf24979f5e9ed98bf9b32b39e13d7499b383fe
MD5 23e2c186788d2f482604973d94163001
BLAKE2b-256 cb57129481e9b3deec887865dddb6e9013c3009ba8afec5810211d119da5a3f7

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page