Skip to content

Commit cb96b26

Browse files
committed
fixes
1 parent f98f9c4 commit cb96b26

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/executorlib/standalone/interactive/arguments.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ def find_future_in_list(lst):
2727

2828
find_future_in_list(lst=args)
2929
find_future_in_list(lst=kwargs.values())
30-
boolean_flag = len([future for future in future_lst if future.done()]) == len(
30+
31+
return future_lst
32+
33+
34+
def check_list_of_futures_is_done(future_lst: list[Future]) -> bool:
35+
return len([future for future in future_lst if future.done()]) == len(
3136
future_lst
3237
)
33-
return future_lst, boolean_flag
3438

3539

3640
def get_exception_lst(future_lst: list[Future]) -> list:

src/executorlib/task_scheduler/interactive/dependency.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from executorlib.standalone.batched import batched_futures
88
from executorlib.standalone.interactive.arguments import (
99
check_exception_was_raised,
10+
check_list_of_futures_is_done,
1011
get_exception_lst,
1112
get_future_objects_from_input,
1213
update_futures_in_input,
@@ -185,6 +186,7 @@ def batched(
185186
"args": (),
186187
"kwargs": {"lst": iterable, "n": n, "skip_lst": skip_lst},
187188
"future": f,
189+
"future_lst": iterable,
188190
"future_skip": f_skip,
189191
"resource_dict": {},
190192
}
@@ -297,9 +299,10 @@ def _execute_tasks_with_dependencies(
297299
and task_dict["fn"] != "batched"
298300
and "future" in task_dict
299301
):
300-
future_lst, ready_flag = get_future_objects_from_input(
302+
future_lst = get_future_objects_from_input(
301303
args=task_dict["args"], kwargs=task_dict["kwargs"]
302304
)
305+
ready_flag = check_list_of_futures_is_done(future_lst=future_lst)
303306
exception_lst = get_exception_lst(future_lst=future_lst)
304307
if not check_exception_was_raised(future_obj=task_dict["future"]):
305308
if len(exception_lst) > 0:

tests/unit/standalone/interactive/test_arguments.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from executorlib.standalone.interactive.arguments import (
55
check_exception_was_raised,
6+
check_list_of_futures_is_done,
67
get_exception_lst,
78
get_future_objects_from_input,
89
update_futures_in_input,
@@ -13,14 +14,16 @@ class TestSerial(unittest.TestCase):
1314
def test_get_future_objects_from_input_with_future(self):
1415
input_args = (1, 2, Future(), [Future()], {3: Future()})
1516
input_kwargs = {"a": 1, "b": [Future()], "c": {"d": Future()}, "e": Future()}
16-
future_lst, boolean_flag = get_future_objects_from_input(args=input_args, kwargs=input_kwargs)
17+
future_lst = get_future_objects_from_input(args=input_args, kwargs=input_kwargs)
18+
boolean_flag = check_list_of_futures_is_done(future_lst=future_lst)
1719
self.assertEqual(len(future_lst), 6)
1820
self.assertFalse(boolean_flag)
1921

2022
def test_get_future_objects_from_input_without_future(self):
2123
input_args = (1, 2)
2224
input_kwargs = {"a": 1}
23-
future_lst, boolean_flag = get_future_objects_from_input(args=input_args, kwargs=input_kwargs)
25+
future_lst = get_future_objects_from_input(args=input_args, kwargs=input_kwargs)
26+
boolean_flag = check_list_of_futures_is_done(future_lst=future_lst)
2427
self.assertEqual(len(future_lst), 0)
2528
self.assertTrue(boolean_flag)
2629

0 commit comments

Comments
 (0)