f9columnar 0.2.2__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {f9columnar-0.2.2 → f9columnar-0.2.3}/PKG-INFO +69 -59
  2. {f9columnar-0.2.2 → f9columnar-0.2.3}/README.md +67 -56
  3. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/hdf5_dataloader.py +5 -4
  4. {f9columnar-0.2.2 → f9columnar-0.2.3}/pyproject.toml +1 -1
  5. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/__init__.py +0 -0
  6. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/analysis/__init__.py +0 -0
  7. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/analysis/triggers.py +0 -0
  8. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/arrays.py +0 -0
  9. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/data/PMGxsecDB_mc16.txt +0 -0
  10. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/data/PMGxsecDB_mc21.txt +0 -0
  11. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/data/campaigns.json +0 -0
  12. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/data/luminosity.json +0 -0
  13. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/data/periods.json +0 -0
  14. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/data/truth_classification.json +0 -0
  15. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/dataset_builder.py +0 -0
  16. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/hdf5_writer.py +0 -0
  17. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/histograms.py +0 -0
  18. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/processors.py +0 -0
  19. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/processors_collection.py +0 -0
  20. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/root_dataloader.py +0 -0
  21. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/run.py +0 -0
  22. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/submit/__init__.py +0 -0
  23. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/submit/act_driver.py +0 -0
  24. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/submit/act_handler.py +0 -0
  25. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/submit/act_merger.py +0 -0
  26. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/submit/act_run.py +0 -0
  27. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/submit/act_run.sh +0 -0
  28. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/utils/__init__.py +0 -0
  29. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/utils/ak_helpers.py +0 -0
  30. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/utils/config_utils.py +0 -0
  31. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/utils/helpers.py +0 -0
  32. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/utils/loggers.py +0 -0
  33. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/utils/regex_helpers.py +0 -0
  34. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/utils/rucio_db.py +0 -0
  35. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/utils/rucio_utils.py +0 -0
  36. {f9columnar-0.2.2 → f9columnar-0.2.3}/f9columnar/utils/xsec_db.py +0 -0
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: f9columnar
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Columnar analysis utils.
5
- Home-page: https://gitlab.cern.ch/ijs-f9-ljubljana/f9columnar
6
5
  License: MIT
7
6
  Author: Jan Gavranovic
8
7
  Author-email: jan.gavranovic@cern.ch
@@ -43,82 +42,38 @@ Description-Content-Type: text/markdown
43
42
 
44
43
  # F9 Columnar
45
44
 
46
- ### 🚧 **Work in Progress** ⚠️
45
+ ### What is this?
47
46
 
48
- ## Setup
47
+ This is a lightweight Python package for processing event data stored in ROOT or HDF5 files in a batch-oriented manner. It is designed for datasets that are too large to fit into memory or too slow to process in a single thread. Built on top of PyTorch and Awkward Arrays, the package leverages PyTorch's DataLoader with an IterableDataset for efficient parallel processing. It implements a columnar event loop that returns batches of events, following the same structure as a standard PyTorch training loop over epochs.
48
+
49
+ ### Why?
50
+
51
+ The primary goal of this package is to provide a simple and efficient solution for loading and processing large datasets, particularly for machine learning applications. It includes [`RootDataLoader`](f9columnar/root_dataloader.py) and [`Hdf5DataLoader`](f9columnar/hdf5_dataloader.py) classes for reading data from ROOT and HDF5 files. Additionally, it supports parallel data processing through processor classes, which can be chained together to perform complex calculations and histogramming.
49
52
 
50
- ### User install
53
+ ## Setup
51
54
 
52
- #### With PyTorch GPU
55
+ ### Install with PyTorch GPU
53
56
 
54
57
  ```shell
55
58
  pip install f9columnar[torch]
56
59
  ```
57
60
 
58
- #### With PyTorch CPU (recommended)
61
+ ### Install with PyTorch CPU (recommended)
59
62
 
60
63
  ```shell
61
64
  pip install f9columnar
62
65
  pip install torch --index-url https://download.pytorch.org/whl/cpu
63
66
  ```
64
67
 
65
- #### Without PyTorch
68
+ ### Install without PyTorch
66
69
 
67
70
  ```shell
68
71
  pip install f9columnar
69
72
  ```
70
73
 
71
- ### Development install
72
-
73
- Use [poetry](https://python-poetry.org/) to install the required packages:
74
-
75
- ```shell
76
- poetry config cache-dir $PWD
77
- poetry config virtualenvs.in-project true
78
- poetry install -E torch
79
- ```
80
-
81
- This environment is duplicated for batch processing on dCache.
82
-
83
- ## aCT
84
-
85
- [ARC](https://doc.vega.izum.si/arc) Control Tower (aCT) is a system for submitting and managing payloads on ARC (and other) Computing Elements. It is used to submit jobs on sites in Slovenia.
86
-
87
- ### Installation
88
-
89
- Install aCT client from the repository with the following command to the virtual environment (or with poetry):
90
-
91
- ```shell
92
- pip install "git+https://github.com/ARCControlTower/aCT.git@test#subdirectory=src/act/client/aCT-client"
93
- ```
94
-
95
- The command `act` is available in `PATH` as the virtual environment is activated. See the scripts in the [`submit`](f9columnar/submit/) directory for further details.
96
-
97
- ### Voms proxy setup
98
-
99
- Note that it is recommended to be in `/atlas/si` group and make the proxy with it. Active it using (in a separate terminal):
100
-
101
- ```shell
102
- setupATLAS
103
- lsetup emi
104
- voms-proxy-init --valid 96:0 --voms atlas:/atlas/si
105
- ```
106
-
107
- To propagate the proxy to the system use
108
-
109
- ```shell
110
- act proxy
111
- ```
112
-
113
- At this point you are ready to use aCT.
114
-
115
74
  ## Getting started example
116
75
 
117
- The code is written in a way that it can be used standalone or as a part of an analysis containing data and MC samples. The following example shows the standalone usage.
118
-
119
- ### Basic example
120
-
121
- The main idea is to have a columnar event loop that returns arrays of events. The code and usage is the same as in a standard torch training loop over epochs, but instead of having epochs we iterate over batches of events.
76
+ The following example demonstrates how to load data from multiple ROOT files, apply a simple filter to select two branches, define variables, apply a cut, and create a histogram.
122
77
 
123
78
  ```python
124
79
  from f9columnar.root_dataloader import get_root_dataloader
@@ -144,7 +99,9 @@ for events in root_dataloader:
144
99
  # ... do something with the arrays
145
100
  ```
146
101
 
147
- Doing calculations on arrays inside of workers can be done using a `Processor`. Many processors can be chained together into a `ProcessorsGraph` (DAG) to perform more complex calculations. Processors are applied to the arrays in the order given by the topological sort of the DAG. Note that each worker runs the same processor graph on batches of array events and returns the result to the event loop when done. So in the above example there would be 12 (`num_workers`) processor graphs running in parallel on small batches of events. An example of calculating tau visible mass and then applying a cut on this variable is shown below.
102
+ Calculations on arrays within worker processes can be performed using a `Processor`. Multiple processors can be linked together in a `ProcessorsGraph`, forming a directed acyclic graph (DAG). These processors are applied to arrays in the sequence determined by the DAG’s topological order.
103
+
104
+ Each worker executes the same processor graph on batches of event data and returns the results to the event loop once processing is complete. In the example above, 12 (`num_workers`) processor graphs would be running in parallel, each handling small batches of events. Below is an example demonstrating how to calculate the tau visible mass and apply a cut to this variable.
148
105
 
149
106
  ```python
150
107
  from f9columnar.processors import ProcessorsGraph, CheckpointProcessor
@@ -228,8 +185,61 @@ for processed_graph in dataloader:
228
185
  # ... do something with the histograms and arrays
229
186
  ```
230
187
 
188
+ A higher level of abstraction is also possible using the [`ColumnarEventLoop`](f9columnar/run.py) class. See benchmark [examples](benchmark/f9columnar_benchmark.py) for some more details.
189
+
190
+ ## aCT
191
+
192
+ Basic job submitting to Slovenian grid is also possible using aCT. Currently it only supports Ntuple analysis data format from rucio (for [R21](https://gitlab.cern.ch/atlas-dch-seesaw-analyses/MultiLeptonAnalysis) and [R25](https://gitlab.cern.ch/atlas-dch-seesaw-analyses/EnhancedCPToolkit)).
193
+
194
+ ### Installation
195
+
196
+ [ARC](https://doc.vega.izum.si/arc) Control Tower (aCT) is a system for submitting and managing payloads on ARC (and other) Computing Elements. It is used to submit jobs on sites in Slovenia. Install aCT client from the repository with the following command to the virtual environment (or with poetry):
197
+
198
+ ```shell
199
+ pip install "git+https://github.com/ARCControlTower/aCT.git@test#subdirectory=src/act/client/aCT-client"
200
+ ```
201
+
202
+ The command `act` is available in `PATH` as the virtual environment is activated. See the scripts in the [`submit`](f9columnar/submit/) directory for further details.
203
+
204
+ ### Voms proxy setup
205
+
206
+ Note that it is recommended to be in `/atlas/si` group and make the proxy with it. Active it using (in a separate terminal):
207
+
208
+ ```shell
209
+ setupATLAS
210
+ lsetup emi
211
+ voms-proxy-init --valid 96:0 --voms atlas:/atlas/si
212
+ ```
213
+
214
+ To propagate the proxy to the system use
215
+
216
+ ```shell
217
+ act proxy
218
+ ```
219
+
220
+ At this point you are ready to use aCT.
221
+
222
+ ## Examples
223
+
224
+ - [Mini-analysis](https://gitlab.cern.ch/jgavrano/columnar-seesaw)
225
+ - [Converting ROOT to HDF5](https://gitlab.cern.ch/atlas-dch-seesaw-analyses/SeeSawML/-/blob/main/seesaw/fakes/hdf5_converter.py?ref_type=heads)
226
+ - [HDF5 Dataloader for ML](https://gitlab.cern.ch/atlas-dch-seesaw-analyses/SeeSawML/-/blob/main/seesaw/fakes/hdf5_dataloader.py?ref_type=heads)
227
+ - [Histogramming](https://gitlab.cern.ch/atlas-dch-seesaw-analyses/SeeSawML/-/blob/main/seesaw/fakes/el_fake_hists.py?ref_type=heads)
228
+
231
229
  ## Development
232
230
 
231
+ ### Development install
232
+
233
+ Use [poetry](https://python-poetry.org/) to install the required packages:
234
+
235
+ ```shell
236
+ poetry config cache-dir $PWD
237
+ poetry config virtualenvs.in-project true
238
+ poetry install -E torch
239
+ ```
240
+
241
+ Note: this environment should be duplicated for batch processing on dCache.
242
+
233
243
  ### Making a portable venv with conda
234
244
 
235
245
  Make sure you have [Miniconda](https://docs.anaconda.com/miniconda/) installed:
@@ -1,81 +1,37 @@
1
1
  # F9 Columnar
2
2
 
3
- ### 🚧 **Work in Progress** ⚠️
3
+ ### What is this?
4
4
 
5
- ## Setup
5
+ This is a lightweight Python package for processing event data stored in ROOT or HDF5 files in a batch-oriented manner. It is designed for datasets that are too large to fit into memory or too slow to process in a single thread. Built on top of PyTorch and Awkward Arrays, the package leverages PyTorch's DataLoader with an IterableDataset for efficient parallel processing. It implements a columnar event loop that returns batches of events, following the same structure as a standard PyTorch training loop over epochs.
6
+
7
+ ### Why?
8
+
9
+ The primary goal of this package is to provide a simple and efficient solution for loading and processing large datasets, particularly for machine learning applications. It includes [`RootDataLoader`](f9columnar/root_dataloader.py) and [`Hdf5DataLoader`](f9columnar/hdf5_dataloader.py) classes for reading data from ROOT and HDF5 files. Additionally, it supports parallel data processing through processor classes, which can be chained together to perform complex calculations and histogramming.
6
10
 
7
- ### User install
11
+ ## Setup
8
12
 
9
- #### With PyTorch GPU
13
+ ### Install with PyTorch GPU
10
14
 
11
15
  ```shell
12
16
  pip install f9columnar[torch]
13
17
  ```
14
18
 
15
- #### With PyTorch CPU (recommended)
19
+ ### Install with PyTorch CPU (recommended)
16
20
 
17
21
  ```shell
18
22
  pip install f9columnar
19
23
  pip install torch --index-url https://download.pytorch.org/whl/cpu
20
24
  ```
21
25
 
22
- #### Without PyTorch
26
+ ### Install without PyTorch
23
27
 
24
28
  ```shell
25
29
  pip install f9columnar
26
30
  ```
27
31
 
28
- ### Development install
29
-
30
- Use [poetry](https://python-poetry.org/) to install the required packages:
31
-
32
- ```shell
33
- poetry config cache-dir $PWD
34
- poetry config virtualenvs.in-project true
35
- poetry install -E torch
36
- ```
37
-
38
- This environment is duplicated for batch processing on dCache.
39
-
40
- ## aCT
41
-
42
- [ARC](https://doc.vega.izum.si/arc) Control Tower (aCT) is a system for submitting and managing payloads on ARC (and other) Computing Elements. It is used to submit jobs on sites in Slovenia.
43
-
44
- ### Installation
45
-
46
- Install aCT client from the repository with the following command to the virtual environment (or with poetry):
47
-
48
- ```shell
49
- pip install "git+https://github.com/ARCControlTower/aCT.git@test#subdirectory=src/act/client/aCT-client"
50
- ```
51
-
52
- The command `act` is available in `PATH` as the virtual environment is activated. See the scripts in the [`submit`](f9columnar/submit/) directory for further details.
53
-
54
- ### Voms proxy setup
55
-
56
- Note that it is recommended to be in `/atlas/si` group and make the proxy with it. Active it using (in a separate terminal):
57
-
58
- ```shell
59
- setupATLAS
60
- lsetup emi
61
- voms-proxy-init --valid 96:0 --voms atlas:/atlas/si
62
- ```
63
-
64
- To propagate the proxy to the system use
65
-
66
- ```shell
67
- act proxy
68
- ```
69
-
70
- At this point you are ready to use aCT.
71
-
72
32
  ## Getting started example
73
33
 
74
- The code is written in a way that it can be used standalone or as a part of an analysis containing data and MC samples. The following example shows the standalone usage.
75
-
76
- ### Basic example
77
-
78
- The main idea is to have a columnar event loop that returns arrays of events. The code and usage is the same as in a standard torch training loop over epochs, but instead of having epochs we iterate over batches of events.
34
+ The following example demonstrates how to load data from multiple ROOT files, apply a simple filter to select two branches, define variables, apply a cut, and create a histogram.
79
35
 
80
36
  ```python
81
37
  from f9columnar.root_dataloader import get_root_dataloader
@@ -101,7 +57,9 @@ for events in root_dataloader:
101
57
  # ... do something with the arrays
102
58
  ```
103
59
 
104
- Doing calculations on arrays inside of workers can be done using a `Processor`. Many processors can be chained together into a `ProcessorsGraph` (DAG) to perform more complex calculations. Processors are applied to the arrays in the order given by the topological sort of the DAG. Note that each worker runs the same processor graph on batches of array events and returns the result to the event loop when done. So in the above example there would be 12 (`num_workers`) processor graphs running in parallel on small batches of events. An example of calculating tau visible mass and then applying a cut on this variable is shown below.
60
+ Calculations on arrays within worker processes can be performed using a `Processor`. Multiple processors can be linked together in a `ProcessorsGraph`, forming a directed acyclic graph (DAG). These processors are applied to arrays in the sequence determined by the DAG’s topological order.
61
+
62
+ Each worker executes the same processor graph on batches of event data and returns the results to the event loop once processing is complete. In the example above, 12 (`num_workers`) processor graphs would be running in parallel, each handling small batches of events. Below is an example demonstrating how to calculate the tau visible mass and apply a cut to this variable.
105
63
 
106
64
  ```python
107
65
  from f9columnar.processors import ProcessorsGraph, CheckpointProcessor
@@ -185,8 +143,61 @@ for processed_graph in dataloader:
185
143
  # ... do something with the histograms and arrays
186
144
  ```
187
145
 
146
+ A higher level of abstraction is also possible using the [`ColumnarEventLoop`](f9columnar/run.py) class. See benchmark [examples](benchmark/f9columnar_benchmark.py) for some more details.
147
+
148
+ ## aCT
149
+
150
+ Basic job submitting to Slovenian grid is also possible using aCT. Currently it only supports Ntuple analysis data format from rucio (for [R21](https://gitlab.cern.ch/atlas-dch-seesaw-analyses/MultiLeptonAnalysis) and [R25](https://gitlab.cern.ch/atlas-dch-seesaw-analyses/EnhancedCPToolkit)).
151
+
152
+ ### Installation
153
+
154
+ [ARC](https://doc.vega.izum.si/arc) Control Tower (aCT) is a system for submitting and managing payloads on ARC (and other) Computing Elements. It is used to submit jobs on sites in Slovenia. Install aCT client from the repository with the following command to the virtual environment (or with poetry):
155
+
156
+ ```shell
157
+ pip install "git+https://github.com/ARCControlTower/aCT.git@test#subdirectory=src/act/client/aCT-client"
158
+ ```
159
+
160
+ The command `act` is available in `PATH` as the virtual environment is activated. See the scripts in the [`submit`](f9columnar/submit/) directory for further details.
161
+
162
+ ### Voms proxy setup
163
+
164
+ Note that it is recommended to be in `/atlas/si` group and make the proxy with it. Active it using (in a separate terminal):
165
+
166
+ ```shell
167
+ setupATLAS
168
+ lsetup emi
169
+ voms-proxy-init --valid 96:0 --voms atlas:/atlas/si
170
+ ```
171
+
172
+ To propagate the proxy to the system use
173
+
174
+ ```shell
175
+ act proxy
176
+ ```
177
+
178
+ At this point you are ready to use aCT.
179
+
180
+ ## Examples
181
+
182
+ - [Mini-analysis](https://gitlab.cern.ch/jgavrano/columnar-seesaw)
183
+ - [Converting ROOT to HDF5](https://gitlab.cern.ch/atlas-dch-seesaw-analyses/SeeSawML/-/blob/main/seesaw/fakes/hdf5_converter.py?ref_type=heads)
184
+ - [HDF5 Dataloader for ML](https://gitlab.cern.ch/atlas-dch-seesaw-analyses/SeeSawML/-/blob/main/seesaw/fakes/hdf5_dataloader.py?ref_type=heads)
185
+ - [Histogramming](https://gitlab.cern.ch/atlas-dch-seesaw-analyses/SeeSawML/-/blob/main/seesaw/fakes/el_fake_hists.py?ref_type=heads)
186
+
188
187
  ## Development
189
188
 
189
+ ### Development install
190
+
191
+ Use [poetry](https://python-poetry.org/) to install the required packages:
192
+
193
+ ```shell
194
+ poetry config cache-dir $PWD
195
+ poetry config virtualenvs.in-project true
196
+ poetry install -E torch
197
+ ```
198
+
199
+ Note: this environment should be duplicated for batch processing on dCache.
200
+
190
201
  ### Making a portable venv with conda
191
202
 
192
203
  Make sure you have [Miniconda](https://docs.anaconda.com/miniconda/) installed:
@@ -229,7 +229,7 @@ class Hdf5LoaderIterator:
229
229
  name: str,
230
230
  iterators_df: pd.DataFrame,
231
231
  worker_id: int,
232
- processors: list[Callable[[ArrayLike, dict], tuple[ArrayLike, dict]]] | ProcessorsGraph | None,
232
+ processors: list[Callable[[ArrayLike, dict], tuple[ArrayLike, dict]]] | ProcessorsGraph | None = None,
233
233
  hdf5_files_desc_dct: dict[str, dict[str, Any]] | None = None,
234
234
  ) -> None:
235
235
  self.name = name
@@ -372,13 +372,14 @@ class Hdf5IterableDataset(IterableDataset):
372
372
  logging.warning(f"Dataset {dataset_name} not found in {file}. Skipping!")
373
373
  continue
374
374
 
375
- piles_metadata[file] = {"piles_lst": None, "piles_shapes": None}
375
+ if file not in piles_metadata:
376
+ piles_metadata[file] = {"piles_lst": [], "piles_shapes": []}
376
377
 
377
378
  piles_lst = self._get_piles_metadata(file)["piles"][dataset_name]
378
- piles_metadata[file]["piles_lst"] = piles_lst
379
+ piles_metadata[file]["piles_lst"] += piles_lst
379
380
 
380
381
  piles_shapes = self._get_piles_shape(file, piles_lst)
381
- piles_metadata[file]["piles_shapes"] = piles_shapes
382
+ piles_metadata[file]["piles_shapes"] += piles_shapes
382
383
 
383
384
  for file, metadata in piles_metadata.items():
384
385
  for pile, shape in zip(metadata["piles_lst"], metadata["piles_shapes"]):
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "f9columnar"
3
- version = "0.2.2"
3
+ version = "0.2.3"
4
4
  description = "Columnar analysis utils."
5
5
  authors = ["Jan Gavranovic <jan.gavranovic@cern.ch>"]
6
6
  readme = "README.md"
File without changes