Skip to content

Commit

Permalink
feat: added better output when overlapping events found
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Aug 5, 2020
1 parent 5b9977f commit 52937c4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples/merge_buckets.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import timedelta

import aw_client
from aw_transform.filter_period_intersect import _intersecting_eventpairs

Expand All @@ -14,10 +16,14 @@ def main():
dest_events = aw.get_events(dest_id)
print(f"✓ dest events: {len(dest_events)}")

print("Checking overlap")
print("Checking overlap...")
overlaps = list(_intersecting_eventpairs(src_events, dest_events))
if overlaps:
print("Buckets had overlap, can't safely merge")
total_duration_src = sum((e.duration for e in src_events), timedelta())
total_overlap = sum((tp.duration for _, _, tp in overlaps), timedelta())
print(
f"Buckets had overlap ({total_overlap} out of {total_duration_src}), can't safely merge, exiting."
)
exit(1)
print("No overlap detected, continuing...")

Expand Down

0 comments on commit 52937c4

Please sign in to comment.