-
Notifications
You must be signed in to change notification settings - Fork 76
Physical layer interface
In this wiki, I'll document the interface that Uproot expects from Source
classes, such as HTTPSource and XRootDSource. This document only describes reading because only reading has been implemented (Nov 2020).
When a user opens a file with uproot4.open, the URL scheme determines which Source to use:
- non-URL or
"file://"
defaults to MemmapSource, but MultithreadedFileSource is also a good option -
"http://"
and"https://"
default to HTTPSource -
"root://"
defaults to XRootDSource - a non-string, non-Path object with
read
andseek
methods is handled by ObjectSource.
The uproot4.open returns a ReadOnlyDirectory, which has a file property pointing to a ReadOnlyFile, which has a source property pointing to the actual Source. The Source may be stateful, with open file handles and associated threads. When any object derived from uproot4.open exits a with
statement (through its __exit__
) or is explicitly closed, __exit__
calls are propagated all the way down to the Source, so that it can close or shutdown whatever it needs to.