Skip to content

Commit

Permalink
Merge pull request #617 from jrueb/fix_workitem_hash
Browse files Browse the repository at this point in the history
Fix WorkItem.__hash__
  • Loading branch information
lgray authored Nov 22, 2021
2 parents 183cbe4 + 5af34fc commit dde73df
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion coffea/processor/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class WorkItem:
entrystart: int
entrystop: int
fileuuid: str
usermeta: Optional[Dict] = None
usermeta: Optional[Dict] = field(default=None, compare=False)

def __len__(self) -> int:
return self.entrystop - self.entrystart
Expand Down
29 changes: 29 additions & 0 deletions tests/test_workitem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python3

from coffea.processor.executor import WorkItem


def test_work_item():
item1 = WorkItem("TestDataSet", "/a/b/c.root", "Events", 500, 670, "abc", {})
item2 = WorkItem(
"TestDataSet", "/a/b/c.root", "Events", 500, 670, "abc", {"meta": "data"}
)
item3 = WorkItem("TestDataSet", "/a/b/c.root", "Events", 500, 760, "abc", {})

assert item1 == item1
assert item1 == item2
assert item1 != item3
assert item1.dataset == "TestDataSet"
assert item1.filename == "/a/b/c.root"
assert item1.treename == "Events"
assert item1.entrystart == 500
assert item1.entrystop == 670
assert item1.fileuuid == "abc"
assert len(item1) == 670 - 500
assert len(item3) == 760 - 500

# Test if hashable
hash(item2)

# Test if usermeta is mutable
item1.usermeta["user"] = "meta"

0 comments on commit dde73df

Please sign in to comment.