-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework current pods query to filter finished ones
- Loading branch information
1 parent
42f6e61
commit 58c0d0d
Showing
2 changed files
with
35 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import itertools | ||
from typing import Iterable, TypeVar | ||
|
||
|
||
_T = TypeVar("_T") | ||
|
||
|
||
def batched(iterable: Iterable[_T], n: int) -> Iterable[list[_T]]: | ||
"Batch data into tuples of length n. The last batch may be shorter." | ||
# batched('ABCDEFG', 3) --> ABC DEF G | ||
if n < 1: | ||
raise ValueError("n must be at least one") | ||
it = iter(iterable) | ||
while batch := list(itertools.islice(it, n)): | ||
yield batch |