-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preprocessing files with zero events #1140
Labels
bug
Something isn't working
Comments
I'm happy to PR if the solution makes sense to you. |
Hi @alexander-held, thanks a lot! This makes sense to me. |
I had a brief look and believe the solution could be this diff --git a/src/coffea/dataset_tools/preprocess.py b/src/coffea/dataset_tools/preprocess.py
index cef72ad5..69ffe3fa 100644
--- a/src/coffea/dataset_tools/preprocess.py
+++ b/src/coffea/dataset_tools/preprocess.py
@@ -76,6 +76,9 @@ def get_steps(
num_entries = tree.num_entries
+ if num_entries == 0:
+ continue
+
form_json = None
form_hash = None
if save_form: |
Please make a PR with this change. We should make this configurable by the user (the continue behavior should be on by default). |
No one ever made a PR for this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When running preprocessing over files containing zero events,
num_entries
will be0
and a division in the step size determination will fail withZeroDivisionError
here: https://github.com/CoffeaTeam/coffea/blob/e06c4b84d0a641ab569ae7c16fecc39fe74c9743/src/coffea/dataset_tools/preprocess.py#L127I assume the solution would be to bypass all of https://github.com/CoffeaTeam/coffea/blob/e06c4b84d0a641ab569ae7c16fecc39fe74c9743/src/coffea/dataset_tools/preprocess.py#L79-L156 in this case to instead run https://github.com/CoffeaTeam/coffea/blob/e06c4b84d0a641ab569ae7c16fecc39fe74c9743/src/coffea/dataset_tools/preprocess.py#L158-L173
and return.
To Reproduce
The actual case where I saw this happen contained a tree without any arrays inside. I'm not sure if
uproot
supports writing that for a reproducer (I don't think so?) but in either case I think only the.num_entries
property matters so the tree content should be irrelevant here.Expected behavior
handle empty files without crash
Output
Desktop (please complete the following information):
n/a
Additional context
cc @sebastien-rettie
The text was updated successfully, but these errors were encountered: