-
-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
487 additions
and
34 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
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
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,44 @@ | ||
from typing import Iterable | ||
|
||
|
||
def scheduler_story(keys: set, transition_log: Iterable) -> list: | ||
"""Creates a story from the scheduler transition log given a set of keys | ||
describing tasks or stimuli. | ||
Parameters | ||
---------- | ||
keys : set | ||
A set of task `keys` or `stimulus_id`'s | ||
log : iterable | ||
The scheduler transition log | ||
Returns | ||
------- | ||
story : list | ||
""" | ||
return [t for t in transition_log if t[0] in keys or keys.intersection(t[3])] | ||
|
||
|
||
def worker_story(keys: set, log: Iterable) -> list: | ||
"""Creates a story from the worker log given a set of keys | ||
describing tasks or stimuli. | ||
Parameters | ||
---------- | ||
keys : set | ||
A set of task `keys` or `stimulus_id`'s | ||
log : iterable | ||
The worker log | ||
Returns | ||
------- | ||
story : list | ||
""" | ||
return [ | ||
msg | ||
for msg in log | ||
if any(key in msg for key in keys) | ||
or any( | ||
key in c for key in keys for c in msg if isinstance(c, (tuple, list, set)) | ||
) | ||
] |
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
Oops, something went wrong.