Repository navigation
[Bug] Resubmit tasks whose previous run with the same key already finished #1117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,6 +72,22 @@ def test_submit_dependency_on_failed_task(self): | |
| ) | ||
| ) | ||
|
|
||
| def test_resubmit_finished_task_with_same_cache_key(self): | ||
| with FileTaskScheduler(execute_function=subprocess_execute) as exe: | ||
| for i in range(3): | ||
| resource_dict = {"cache_key": "error_" + str(i)} | ||
| fs1 = exe.submit(get_error, a=1, resource_dict=resource_dict) | ||
| with self.assertRaises(ValueError): | ||
| fs1.result(timeout=15) | ||
| fs2 = exe.submit(get_error, a=1, resource_dict=resource_dict) | ||
| with self.assertRaises(ValueError): | ||
| fs2.result(timeout=15) | ||
| resource_dict = {"cache_key": "result_" + str(i)} | ||
| fs3 = exe.submit(my_funct, 1, b=2, resource_dict=resource_dict) | ||
| self.assertEqual(fs3.result(timeout=15), 3) | ||
| fs4 = exe.submit(my_funct, 1, b=2, resource_dict=resource_dict) | ||
| self.assertEqual(fs4.result(timeout=15), 3) | ||
|
|
||
| def test_submit_dependency_on_duplicate_task(self): | ||
| with FileTaskScheduler(execute_function=subprocess_execute) as exe: | ||
| fs1 = exe.submit(my_funct, 1, b=2) | ||
|
|
@@ -383,6 +399,49 @@ def test_executor_function_unpicklable_argument_with_cache_key(self): | |
| q.put({"shutdown": True, "wait": True}) | ||
| process.join() | ||
|
|
||
| def test_executor_function_resubmit_after_failed_submission(self): | ||
| fs_bad_1 = Future() | ||
| fs_bad_2 = Future() | ||
| fs_good = Future() | ||
| q = Queue() | ||
| for fs in [fs_bad_1, fs_bad_2]: | ||
| q.put( | ||
| { | ||
| "fn": len, | ||
| "args": ([Unpicklable()],), | ||
| "kwargs": {}, | ||
| "future": fs, | ||
| "resource_dict": {"cache_key": "bad/key"}, | ||
| } | ||
| ) | ||
| q.put( | ||
| { | ||
| "fn": my_funct, | ||
| "args": (), | ||
| "kwargs": {"a": 1, "b": 2}, | ||
| "future": fs_good, | ||
| "resource_dict": {}, | ||
| } | ||
| ) | ||
| cache_dir = os.path.abspath("executorlib_cache") | ||
| os.makedirs(cache_dir, exist_ok=True) | ||
| process = Thread( | ||
| target=execute_tasks_h5, | ||
| kwargs={ | ||
| "future_queue": q, | ||
| "execute_function": subprocess_execute, | ||
| "executor_kwargs": {"cores": 1, "cwd": None, "cache_directory": cache_dir}, | ||
| "terminate_function": subprocess_terminate, | ||
| }, | ||
| ) | ||
| process.start() | ||
| for fs in [fs_bad_1, fs_bad_2]: | ||
| with self.assertRaises(TypeError): | ||
| fs.result(timeout=15) | ||
| self.assertEqual(fs_good.result(timeout=15), 3) | ||
| q.put({"shutdown": True, "wait": True}) | ||
| process.join() | ||
|
Comment on lines
+442
to
+443
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shut down the scheduler thread when an assertion fails. If the second future remains pending, Line 440 raises Put shutdown and thread joining in
|
||
|
|
||
| def test_convert_args_and_kwargs(self): | ||
| f1 = Future() | ||
| f1.set_result(1) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terminate cancelled tasks before removing their process handles.
A cancelled
Futurealso satisfiesdone(). (docs.python.org) If a caller cancels a launched task and queues the same key before the next refresh, this branch deletes its process handle before_refresh_memory_dictcan pass it to_cancel_processes.The retry can then launch while the original process remains active. Both attempts use the same cache paths. When termination is configured, run the cancellation cleanup before removing the old bookkeeping. Preserve the current path for normally completed tasks.