vine-reduce 2026.8.1__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.
- vine_reduce-2026.8.1/LICENSE +201 -0
- vine_reduce-2026.8.1/PKG-INFO +226 -0
- vine_reduce-2026.8.1/README.md +188 -0
- vine_reduce-2026.8.1/pyproject.toml +114 -0
- vine_reduce-2026.8.1/setup.cfg +4 -0
- vine_reduce-2026.8.1/src/vine_reduce/__init__.py +49 -0
- vine_reduce-2026.8.1/src/vine_reduce/checkpoint_db.py +188 -0
- vine_reduce-2026.8.1/src/vine_reduce/coffea.py +188 -0
- vine_reduce-2026.8.1/src/vine_reduce/defaults.py +165 -0
- vine_reduce-2026.8.1/src/vine_reduce/distributor.py +116 -0
- vine_reduce-2026.8.1/src/vine_reduce/engine.py +290 -0
- vine_reduce-2026.8.1/src/vine_reduce/executor.py +108 -0
- vine_reduce-2026.8.1/src/vine_reduce/local_distributor.py +194 -0
- vine_reduce-2026.8.1/src/vine_reduce/pipeline.py +558 -0
- vine_reduce-2026.8.1/src/vine_reduce/remote_environment.py +315 -0
- vine_reduce-2026.8.1/src/vine_reduce/serialization.py +29 -0
- vine_reduce-2026.8.1/src/vine_reduce/taskvine_distributor.py +392 -0
- vine_reduce-2026.8.1/src/vine_reduce/types.py +92 -0
- vine_reduce-2026.8.1/src/vine_reduce.egg-info/PKG-INFO +226 -0
- vine_reduce-2026.8.1/src/vine_reduce.egg-info/SOURCES.txt +31 -0
- vine_reduce-2026.8.1/src/vine_reduce.egg-info/dependency_links.txt +1 -0
- vine_reduce-2026.8.1/src/vine_reduce.egg-info/requires.txt +18 -0
- vine_reduce-2026.8.1/src/vine_reduce.egg-info/top_level.txt +1 -0
- vine_reduce-2026.8.1/tests/test_checkpoint_db.py +62 -0
- vine_reduce-2026.8.1/tests/test_coffea.py +85 -0
- vine_reduce-2026.8.1/tests/test_defaults.py +144 -0
- vine_reduce-2026.8.1/tests/test_engine_end_to_end.py +257 -0
- vine_reduce-2026.8.1/tests/test_examples.py +53 -0
- vine_reduce-2026.8.1/tests/test_executor.py +46 -0
- vine_reduce-2026.8.1/tests/test_local_distributor.py +176 -0
- vine_reduce-2026.8.1/tests/test_pipeline.py +407 -0
- vine_reduce-2026.8.1/tests/test_remote_environment.py +204 -0
- vine_reduce-2026.8.1/tests/test_taskvine_distributor.py +377 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the
|
|
44
|
+
purposes of this License, Derivative Works shall not include works
|
|
45
|
+
that remain separable from, or merely link (or bind by name) to the
|
|
46
|
+
interfaces of, the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Ben Tovar
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vine-reduce
|
|
3
|
+
Version: 2026.8.1
|
|
4
|
+
Summary: Dynamic MapReduce framework for data processing
|
|
5
|
+
Author-email: Ben Tovar <btovar@nd.edu>
|
|
6
|
+
Maintainer-email: Ben Tovar <btovar@nd.edu>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
Project-URL: Homepage, https://github.com/cooperative-computing-lab/vine-reduce
|
|
9
|
+
Project-URL: Repository, https://github.com/cooperative-computing-lab/vine-reduce.git
|
|
10
|
+
Project-URL: Documentation, https://github.com/cooperative-computing-lab/vine-reduce#readme
|
|
11
|
+
Project-URL: Bug Tracker, https://github.com/cooperative-computing-lab/vine-reduce/issues
|
|
12
|
+
Keywords: dynamic-data-reduction,mapreduce,data-processing,distributed-computing
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Requires-Python: >=3.13
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: awkward>=2.8.7
|
|
22
|
+
Requires-Dist: coffea>=2025.7.3
|
|
23
|
+
Requires-Dist: fsspec>=2026.7.0
|
|
24
|
+
Requires-Dist: fsspec-xrootd>=0.5.1
|
|
25
|
+
Requires-Dist: numpy>=2.4.6
|
|
26
|
+
Requires-Dist: rich>=14.2.0
|
|
27
|
+
Requires-Dist: uproot>=5.6.6
|
|
28
|
+
Requires-Dist: xrootd>=5.8.4
|
|
29
|
+
Requires-Dist: zstandard>=0.25.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov>=2.0; extra == "dev"
|
|
33
|
+
Requires-Dist: black>=21.0; extra == "dev"
|
|
34
|
+
Requires-Dist: flake8>=3.8; extra == "dev"
|
|
35
|
+
Provides-Extra: conda
|
|
36
|
+
Requires-Dist: ndcctools>=7.17.1; extra == "conda"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# VineReduce
|
|
40
|
+
|
|
41
|
+
A dynamic MapReduce framework for data processing, built on top of
|
|
42
|
+
[TaskVine](https://cctools.readthedocs.io/en/latest/taskvine/).
|
|
43
|
+
|
|
44
|
+
For each `(processor, dataset)` pair, `VineReduce` splits every file in the
|
|
45
|
+
dataset into chunks, runs your processor over each chunk remotely (the "map"
|
|
46
|
+
step), then repeatedly folds pooled processor outputs together with a
|
|
47
|
+
reducer (the "reduce" step) until one final result covers the whole
|
|
48
|
+
dataset. Progress is checkpointed along the way, so an interrupted run can
|
|
49
|
+
resume without redoing finished work. See [PLAN.md](PLAN.md) for the full
|
|
50
|
+
design.
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
This project requires Python 3.13+ and is managed with
|
|
55
|
+
[pixi](https://pixi.sh/).
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Clone the repository
|
|
59
|
+
git clone https://github.com/cooperative-computing-lab/vine-reduce.git
|
|
60
|
+
cd vine-reduce
|
|
61
|
+
|
|
62
|
+
# Install the default environment (runtime dependencies only)
|
|
63
|
+
pixi install
|
|
64
|
+
|
|
65
|
+
# Or install the dev environment (adds pytest, black, flake8, pyright)
|
|
66
|
+
pixi install -e dev
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
All commands should be run through pixi so they pick up the managed
|
|
70
|
+
environment, e.g. `pixi run python your_script.py`.
|
|
71
|
+
|
|
72
|
+
## Quick Start
|
|
73
|
+
|
|
74
|
+
`examples/quick_start/quick_start.py` is a self-contained, runnable example:
|
|
75
|
+
it generates some toy binary data, starts a `TaskVineDistributor` with a
|
|
76
|
+
single local worker (no cluster or separate `vine_worker` process needed),
|
|
77
|
+
runs three processors over two datasets, and checks the results for
|
|
78
|
+
consistency.
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
cd examples/quick_start
|
|
82
|
+
pixi run python quick_start.py
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Reading through that file top-to-bottom (it's heavily commented) is the
|
|
86
|
+
fastest way to see how the pieces fit together: `build_datasets` describes
|
|
87
|
+
the input shape `VineReduce` expects, `numbers_chunk_to_args` turns a
|
|
88
|
+
`Chunk` into processor arguments, and `main()` wires a `TaskVineDistributor`
|
|
89
|
+
and `VineReduce` together and calls `compute()`.
|
|
90
|
+
|
|
91
|
+
The shape of a minimal call looks like this:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from vine_reduce import VineReduce
|
|
95
|
+
|
|
96
|
+
vr = VineReduce(
|
|
97
|
+
processors={"my_processor": my_processor_fn},
|
|
98
|
+
input=datasets, # {name: {"metadata": {...}, "files": {path: num_entries}}}
|
|
99
|
+
chunk_to_args=my_chunk_to_args,
|
|
100
|
+
chunksize=10_000,
|
|
101
|
+
results_dir="results",
|
|
102
|
+
# distributor defaults to a local ProcessPoolExecutor-backed
|
|
103
|
+
# LocalDistributor if omitted; pass a TaskVineDistributor to run on a
|
|
104
|
+
# real TaskVine cluster instead. Non-final checkpoints are the
|
|
105
|
+
# distributor's own concern (e.g. TaskVineDistributor(checkpoint_dir=...)),
|
|
106
|
+
# not VineReduce's.
|
|
107
|
+
)
|
|
108
|
+
vr.compute()
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Executors
|
|
112
|
+
|
|
113
|
+
`chunk_to_args`'s output for a chunk becomes the argument each processor
|
|
114
|
+
call runs remotely on. The `executor` argument to `VineReduce` controls how
|
|
115
|
+
that call actually runs, at the execution site:
|
|
116
|
+
|
|
117
|
+
- `simple_executor` (default) — calls `processor(args)` directly.
|
|
118
|
+
- `cloudpickle_executor` — runs `processor(args)` in its own subprocess, so a
|
|
119
|
+
crash or memory leak in `processor` doesn't take down the worker task
|
|
120
|
+
itself. Supports closures and lambdas as `processor`, unlike the stdlib
|
|
121
|
+
`pickle` a plain `ProcessPoolExecutor` would require.
|
|
122
|
+
- `dask_executor` — for a `processor` that returns a dask-delayed object (or
|
|
123
|
+
dask array/dataframe) rather than a plain value; computes it at the
|
|
124
|
+
execution site using one subprocess per core allocated to the task. `dask`
|
|
125
|
+
is not a `vine_reduce` dependency and must already be installed wherever
|
|
126
|
+
this executor runs.
|
|
127
|
+
|
|
128
|
+
All three live in `src/vine_reduce/executor.py`.
|
|
129
|
+
|
|
130
|
+
## Packaging an environment for remote workers
|
|
131
|
+
|
|
132
|
+
`TaskVineDistributor` accepts an `environment=` argument — a path to a
|
|
133
|
+
packed, relocatable [poncho package](https://cctools.readthedocs.io/en/stable/poncho)
|
|
134
|
+
tarball — which it ships to every worker alongside each task, so worker
|
|
135
|
+
nodes need nothing beyond TaskVine itself pre-installed.
|
|
136
|
+
|
|
137
|
+
`vine_reduce.get_environment()` (`src/vine_reduce/remote_environment.py`)
|
|
138
|
+
builds that tarball for you, via `poncho_package_create`:
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from vine_reduce import TaskVineDistributor, get_environment
|
|
142
|
+
|
|
143
|
+
environment = get_environment()
|
|
144
|
+
distributor = TaskVineDistributor(
|
|
145
|
+
port=0,
|
|
146
|
+
resources_processor={"cores": 1},
|
|
147
|
+
environment=environment,
|
|
148
|
+
)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`get_environment()` packs whatever is currently installed in the calling
|
|
152
|
+
conda environment (`$CONDA_PREFIX` by default, or pass `conda_env_path=`) -
|
|
153
|
+
nothing more. Install whatever your workers need (conda install, pip
|
|
154
|
+
install, a pixi dependency, ...) into that environment before calling it.
|
|
155
|
+
Builds are cached on disk (keyed by a hash of the environment's installed
|
|
156
|
+
packages) and reused across runs. Editable pip installs can't be packed
|
|
157
|
+
as-is, so any package currently installed editable (`vine_reduce` itself,
|
|
158
|
+
typically) is temporarily reinstalled non-editable for the pack step and
|
|
159
|
+
reinstalled editable again immediately afterwards. If `vine_reduce` - or
|
|
160
|
+
another package named via `pip_editable` - has uncommitted changes in its
|
|
161
|
+
checkout, the next call rebuilds automatically rather than risk shipping
|
|
162
|
+
stale code (pass `unstaged="fail"` to raise `UnstagedChanges` instead):
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
environment = get_environment(
|
|
166
|
+
pip_editable={"my-analysis-repo": ["src", "pyproject.toml"]},
|
|
167
|
+
)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
`get_environment` is not TaskVine-specific: it just resolves a tarball
|
|
171
|
+
path, so it works the same way regardless of which `Distributor`
|
|
172
|
+
ultimately uses that path. Building requires `poncho_package_create` and
|
|
173
|
+
`conda` on `PATH` - see the `conda` extra in `pyproject.toml`.
|
|
174
|
+
|
|
175
|
+
## HEP / coffea workflows
|
|
176
|
+
|
|
177
|
+
`vine_reduce.VineReduceCoffea` is a specialization for
|
|
178
|
+
[coffea](https://coffeateam.github.io/coffea/)-based analyses: it supplies
|
|
179
|
+
NanoEvents-reading, awkward-array materialization, and coffea-style
|
|
180
|
+
accumulator merging, while chunking, checkpointing, and restart are
|
|
181
|
+
inherited unchanged from `VineReduce`. See `src/vine_reduce/coffea.py`.
|
|
182
|
+
|
|
183
|
+
`examples/cortado/vr_cortado.py` is a runnable example built on it,
|
|
184
|
+
adapted from the ["cortado"
|
|
185
|
+
example](https://github.com/cooperative-computing-lab/dynamic_data_reduction/tree/main/examples/cortado)
|
|
186
|
+
in `dynamic_data_reduction`, the project this one's dynamic map-reduce loop
|
|
187
|
+
descends from: it generates synthetic NanoAOD-like ROOT files for two
|
|
188
|
+
datasets, skims each down to events with at least four leptons, and merges
|
|
189
|
+
the surviving events per dataset with a custom awkward-array-concatenating
|
|
190
|
+
reducer.
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
cd examples/cortado
|
|
194
|
+
pixi run python vr_cortado.py
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Production use: ttbarEFT
|
|
198
|
+
|
|
199
|
+
[`TopEFT/ttbarEFT`](https://github.com/TopEFT/ttbarEFT) is a CMS
|
|
200
|
+
top-quark EFT search that runs its analysis stage through `vine_reduce`
|
|
201
|
+
on top of TaskVine, distributing histogram-filling processors over an
|
|
202
|
+
HTCondor pool.
|
|
203
|
+
[`examples/ttBar/run_processor_with_vr.py`](examples/ttBar/run_processor_with_vr.py)
|
|
204
|
+
shows how that integration looked in practice: driving a `ttbarEFT`
|
|
205
|
+
`AnalysisProcessor` per lepton channel through `vine_reduce`. It predates
|
|
206
|
+
the current `VineReduceCoffea`/`TaskVineDistributor` API described above
|
|
207
|
+
(it was written against an earlier `vine_reduce` release), so treat it as
|
|
208
|
+
a reference for how a full physics analysis wires up channels,
|
|
209
|
+
Wilson-coefficient/histogram selection, and X509 proxy handling around
|
|
210
|
+
`vine_reduce`, not as a runnable script against the current API.
|
|
211
|
+
|
|
212
|
+
## Development
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
pixi run -e dev pytest tests/ -v # run tests
|
|
216
|
+
pixi run -e dev black . # format
|
|
217
|
+
pixi run -e dev flake8 # lint
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
CI (GitHub Actions and a mirrored GitLab CI pipeline) runs all three on
|
|
221
|
+
every push and pull request.
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
This project is licensed under the Apache License 2.0 - see the
|
|
226
|
+
[LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# VineReduce
|
|
2
|
+
|
|
3
|
+
A dynamic MapReduce framework for data processing, built on top of
|
|
4
|
+
[TaskVine](https://cctools.readthedocs.io/en/latest/taskvine/).
|
|
5
|
+
|
|
6
|
+
For each `(processor, dataset)` pair, `VineReduce` splits every file in the
|
|
7
|
+
dataset into chunks, runs your processor over each chunk remotely (the "map"
|
|
8
|
+
step), then repeatedly folds pooled processor outputs together with a
|
|
9
|
+
reducer (the "reduce" step) until one final result covers the whole
|
|
10
|
+
dataset. Progress is checkpointed along the way, so an interrupted run can
|
|
11
|
+
resume without redoing finished work. See [PLAN.md](PLAN.md) for the full
|
|
12
|
+
design.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
This project requires Python 3.13+ and is managed with
|
|
17
|
+
[pixi](https://pixi.sh/).
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Clone the repository
|
|
21
|
+
git clone https://github.com/cooperative-computing-lab/vine-reduce.git
|
|
22
|
+
cd vine-reduce
|
|
23
|
+
|
|
24
|
+
# Install the default environment (runtime dependencies only)
|
|
25
|
+
pixi install
|
|
26
|
+
|
|
27
|
+
# Or install the dev environment (adds pytest, black, flake8, pyright)
|
|
28
|
+
pixi install -e dev
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
All commands should be run through pixi so they pick up the managed
|
|
32
|
+
environment, e.g. `pixi run python your_script.py`.
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
`examples/quick_start/quick_start.py` is a self-contained, runnable example:
|
|
37
|
+
it generates some toy binary data, starts a `TaskVineDistributor` with a
|
|
38
|
+
single local worker (no cluster or separate `vine_worker` process needed),
|
|
39
|
+
runs three processors over two datasets, and checks the results for
|
|
40
|
+
consistency.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
cd examples/quick_start
|
|
44
|
+
pixi run python quick_start.py
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Reading through that file top-to-bottom (it's heavily commented) is the
|
|
48
|
+
fastest way to see how the pieces fit together: `build_datasets` describes
|
|
49
|
+
the input shape `VineReduce` expects, `numbers_chunk_to_args` turns a
|
|
50
|
+
`Chunk` into processor arguments, and `main()` wires a `TaskVineDistributor`
|
|
51
|
+
and `VineReduce` together and calls `compute()`.
|
|
52
|
+
|
|
53
|
+
The shape of a minimal call looks like this:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from vine_reduce import VineReduce
|
|
57
|
+
|
|
58
|
+
vr = VineReduce(
|
|
59
|
+
processors={"my_processor": my_processor_fn},
|
|
60
|
+
input=datasets, # {name: {"metadata": {...}, "files": {path: num_entries}}}
|
|
61
|
+
chunk_to_args=my_chunk_to_args,
|
|
62
|
+
chunksize=10_000,
|
|
63
|
+
results_dir="results",
|
|
64
|
+
# distributor defaults to a local ProcessPoolExecutor-backed
|
|
65
|
+
# LocalDistributor if omitted; pass a TaskVineDistributor to run on a
|
|
66
|
+
# real TaskVine cluster instead. Non-final checkpoints are the
|
|
67
|
+
# distributor's own concern (e.g. TaskVineDistributor(checkpoint_dir=...)),
|
|
68
|
+
# not VineReduce's.
|
|
69
|
+
)
|
|
70
|
+
vr.compute()
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Executors
|
|
74
|
+
|
|
75
|
+
`chunk_to_args`'s output for a chunk becomes the argument each processor
|
|
76
|
+
call runs remotely on. The `executor` argument to `VineReduce` controls how
|
|
77
|
+
that call actually runs, at the execution site:
|
|
78
|
+
|
|
79
|
+
- `simple_executor` (default) — calls `processor(args)` directly.
|
|
80
|
+
- `cloudpickle_executor` — runs `processor(args)` in its own subprocess, so a
|
|
81
|
+
crash or memory leak in `processor` doesn't take down the worker task
|
|
82
|
+
itself. Supports closures and lambdas as `processor`, unlike the stdlib
|
|
83
|
+
`pickle` a plain `ProcessPoolExecutor` would require.
|
|
84
|
+
- `dask_executor` — for a `processor` that returns a dask-delayed object (or
|
|
85
|
+
dask array/dataframe) rather than a plain value; computes it at the
|
|
86
|
+
execution site using one subprocess per core allocated to the task. `dask`
|
|
87
|
+
is not a `vine_reduce` dependency and must already be installed wherever
|
|
88
|
+
this executor runs.
|
|
89
|
+
|
|
90
|
+
All three live in `src/vine_reduce/executor.py`.
|
|
91
|
+
|
|
92
|
+
## Packaging an environment for remote workers
|
|
93
|
+
|
|
94
|
+
`TaskVineDistributor` accepts an `environment=` argument — a path to a
|
|
95
|
+
packed, relocatable [poncho package](https://cctools.readthedocs.io/en/stable/poncho)
|
|
96
|
+
tarball — which it ships to every worker alongside each task, so worker
|
|
97
|
+
nodes need nothing beyond TaskVine itself pre-installed.
|
|
98
|
+
|
|
99
|
+
`vine_reduce.get_environment()` (`src/vine_reduce/remote_environment.py`)
|
|
100
|
+
builds that tarball for you, via `poncho_package_create`:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from vine_reduce import TaskVineDistributor, get_environment
|
|
104
|
+
|
|
105
|
+
environment = get_environment()
|
|
106
|
+
distributor = TaskVineDistributor(
|
|
107
|
+
port=0,
|
|
108
|
+
resources_processor={"cores": 1},
|
|
109
|
+
environment=environment,
|
|
110
|
+
)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`get_environment()` packs whatever is currently installed in the calling
|
|
114
|
+
conda environment (`$CONDA_PREFIX` by default, or pass `conda_env_path=`) -
|
|
115
|
+
nothing more. Install whatever your workers need (conda install, pip
|
|
116
|
+
install, a pixi dependency, ...) into that environment before calling it.
|
|
117
|
+
Builds are cached on disk (keyed by a hash of the environment's installed
|
|
118
|
+
packages) and reused across runs. Editable pip installs can't be packed
|
|
119
|
+
as-is, so any package currently installed editable (`vine_reduce` itself,
|
|
120
|
+
typically) is temporarily reinstalled non-editable for the pack step and
|
|
121
|
+
reinstalled editable again immediately afterwards. If `vine_reduce` - or
|
|
122
|
+
another package named via `pip_editable` - has uncommitted changes in its
|
|
123
|
+
checkout, the next call rebuilds automatically rather than risk shipping
|
|
124
|
+
stale code (pass `unstaged="fail"` to raise `UnstagedChanges` instead):
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
environment = get_environment(
|
|
128
|
+
pip_editable={"my-analysis-repo": ["src", "pyproject.toml"]},
|
|
129
|
+
)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`get_environment` is not TaskVine-specific: it just resolves a tarball
|
|
133
|
+
path, so it works the same way regardless of which `Distributor`
|
|
134
|
+
ultimately uses that path. Building requires `poncho_package_create` and
|
|
135
|
+
`conda` on `PATH` - see the `conda` extra in `pyproject.toml`.
|
|
136
|
+
|
|
137
|
+
## HEP / coffea workflows
|
|
138
|
+
|
|
139
|
+
`vine_reduce.VineReduceCoffea` is a specialization for
|
|
140
|
+
[coffea](https://coffeateam.github.io/coffea/)-based analyses: it supplies
|
|
141
|
+
NanoEvents-reading, awkward-array materialization, and coffea-style
|
|
142
|
+
accumulator merging, while chunking, checkpointing, and restart are
|
|
143
|
+
inherited unchanged from `VineReduce`. See `src/vine_reduce/coffea.py`.
|
|
144
|
+
|
|
145
|
+
`examples/cortado/vr_cortado.py` is a runnable example built on it,
|
|
146
|
+
adapted from the ["cortado"
|
|
147
|
+
example](https://github.com/cooperative-computing-lab/dynamic_data_reduction/tree/main/examples/cortado)
|
|
148
|
+
in `dynamic_data_reduction`, the project this one's dynamic map-reduce loop
|
|
149
|
+
descends from: it generates synthetic NanoAOD-like ROOT files for two
|
|
150
|
+
datasets, skims each down to events with at least four leptons, and merges
|
|
151
|
+
the surviving events per dataset with a custom awkward-array-concatenating
|
|
152
|
+
reducer.
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
cd examples/cortado
|
|
156
|
+
pixi run python vr_cortado.py
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Production use: ttbarEFT
|
|
160
|
+
|
|
161
|
+
[`TopEFT/ttbarEFT`](https://github.com/TopEFT/ttbarEFT) is a CMS
|
|
162
|
+
top-quark EFT search that runs its analysis stage through `vine_reduce`
|
|
163
|
+
on top of TaskVine, distributing histogram-filling processors over an
|
|
164
|
+
HTCondor pool.
|
|
165
|
+
[`examples/ttBar/run_processor_with_vr.py`](examples/ttBar/run_processor_with_vr.py)
|
|
166
|
+
shows how that integration looked in practice: driving a `ttbarEFT`
|
|
167
|
+
`AnalysisProcessor` per lepton channel through `vine_reduce`. It predates
|
|
168
|
+
the current `VineReduceCoffea`/`TaskVineDistributor` API described above
|
|
169
|
+
(it was written against an earlier `vine_reduce` release), so treat it as
|
|
170
|
+
a reference for how a full physics analysis wires up channels,
|
|
171
|
+
Wilson-coefficient/histogram selection, and X509 proxy handling around
|
|
172
|
+
`vine_reduce`, not as a runnable script against the current API.
|
|
173
|
+
|
|
174
|
+
## Development
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
pixi run -e dev pytest tests/ -v # run tests
|
|
178
|
+
pixi run -e dev black . # format
|
|
179
|
+
pixi run -e dev flake8 # lint
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
CI (GitHub Actions and a mirrored GitLab CI pipeline) runs all three on
|
|
183
|
+
every push and pull request.
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
This project is licensed under the Apache License 2.0 - see the
|
|
188
|
+
[LICENSE](LICENSE) file for details.
|