-
Notifications
You must be signed in to change notification settings - Fork 6
Bug: Extend error handling in backend_write_file() #983
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
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 |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
|
|
||
|
|
||
| try: | ||
| from executorlib.task_scheduler.file.backend import backend_execute_task_in_file | ||
| from executorlib.task_scheduler.file.backend import backend_execute_task_in_file, backend_write_file | ||
| from executorlib.task_scheduler.file.shared import _check_task_output, _convert_args_and_kwargs, FutureItem | ||
| from executorlib.standalone.hdf import dump, get_runtime | ||
| from executorlib.standalone.serialize import serialize_funct | ||
|
|
@@ -64,6 +64,30 @@ def test_execute_function_mixed(self): | |
| self.assertTrue(future_file_obj.done()) | ||
| self.assertEqual(future_file_obj.result(), 3) | ||
|
|
||
| def test_backend_write_file(self): | ||
| cache_directory = os.path.abspath("executorlib_cache") | ||
| os.makedirs(cache_directory, exist_ok=True) | ||
| file_name = os.path.join(cache_directory, "test_file_i.h5") | ||
| dump(file_name=file_name, data_dict={"fn": my_funct, "args": [1], "kwargs": {"b": 2}}) | ||
| backend_write_file(file_name=file_name, output={"result": 3}, runtime=0.1) | ||
| future_file_obj = FutureItem( | ||
| file_name=os.path.join(cache_directory, "test_file_o.h5") | ||
| ) | ||
| self.assertTrue(future_file_obj.done()) | ||
| self.assertEqual(future_file_obj.result(), 3) | ||
|
|
||
| def test_backend_write_file_serialization_error(self): | ||
| cache_directory = os.path.abspath("executorlib_cache") | ||
| os.makedirs(cache_directory, exist_ok=True) | ||
| file_name = os.path.join(cache_directory, "test_file_i.h5") | ||
| dump(file_name=file_name, data_dict={"fn": my_funct, "args": [1], "kwargs": {"b": 2}}) | ||
| backend_write_file(file_name=file_name, output={"result": Future()}, runtime=0.1) | ||
| future_file_obj = FutureItem( | ||
|
Comment on lines
+82
to
+85
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. This test does not set up the input file required by At Line 83, Proposed fix def test_backend_write_file_serialization_error(self):
cache_directory = os.path.abspath("executorlib_cache")
os.makedirs(cache_directory, exist_ok=True)
file_name = os.path.join(cache_directory, "test_file_i.h5")
+ dump(file_name=file_name, data_dict={"fn": my_funct, "args": [1], "kwargs": {"b": 2}})
backend_write_file(file_name=file_name, output={"result": Future()}, runtime=0.1)🤖 Prompt for AI Agents |
||
| file_name=os.path.join(cache_directory, "test_file_o.h5") | ||
| ) | ||
| with self.assertRaises(Exception): | ||
| future_file_obj.result() | ||
|
Comment on lines
+88
to
+89
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. Avoid blind exception assertion in test. At Line 87, 🧰 Tools🪛 Ruff (0.15.12)[warning] 87-87: Do not assert blind exception: (B017) 🤖 Prompt for AI Agents |
||
|
|
||
| def test_execute_function_mixed_selector_convert(self): | ||
| cache_directory = os.path.abspath("executorlib_cache") | ||
| os.makedirs(cache_directory, exist_ok=True) | ||
|
|
||
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.
Make fallback error payload always serializable.
At Line 63, writing
serialize_errordirectly can fail again for non-serializable exception objects, which breaks the new recovery path. Persist a string payload (repr/traceback) instead.Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.15.12)
[warning] 59-59: Do not catch blind exception:
Exception(BLE001)
🤖 Prompt for AI Agents