Skip to content

Correct way to specify lazy_cache in JEC factory? #467

Answered by nsmith-
kondratyevd asked this question in Q&A
Discussion options

You must be logged in to vote

The cachetools package (which is a chained dependency of coffea) provides several options. Here is one example, using the awkward nbytes feature:

from cachetools import LRUCache
cache = LRUCache(1_000_000, lambda a: a.nbytes)
jets = jec_factory.build(jets, lazy_cache=cache)

Similarly, such caches can also be used when instantiating NanoEvents:

cache = LRUCache(int(1e8), lambda a: a.nbytes)
factory = NanoEventsFactory.from_root(
    filename,
    runtime_cache=cache,
    entry_stop=10000,
    metadata={"dataset": "SomeDataset"},
)
events = factory.events()

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by nsmith-
Comment options

You must be logged in to vote
3 replies
@nsmith-
Comment options

@kondratyevd
Comment options

@kondratyevd
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants