-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add another example (event count per dataset)
- Loading branch information
1 parent
5e222b1
commit 0e5977b
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import undr | ||
|
||
|
||
def handle_dvs(file: undr.DvsFile, send_message: undr.SendMessage): | ||
file_total = 0 | ||
for packet in file.packets(): | ||
file_total += len(packet) | ||
send_message( | ||
{ | ||
"dataset_name": file.path_id.parts[0], | ||
"file_total": file_total, | ||
} | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
configuration = undr.configuration_from_path("undr.toml") | ||
dataset_name_to_total = { | ||
dataset_name: 0 | ||
for dataset_name in configuration.name_to_dataset_settings.keys() | ||
} | ||
for message in configuration.map(switch=undr.Switch(handle_dvs=handle_dvs)): | ||
dataset_name_to_total[message["dataset_name"]] += message["file_total"] | ||
for dataset_name, total in dataset_name_to_total: | ||
print(f"{dataset_name}: {total}") |