speedy-utils 1.1.43__tar.gz → 1.1.44__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/PKG-INFO +156 -8
  2. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/README.md +155 -7
  3. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/pyproject.toml +1 -1
  4. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/scripts/test_locals.py +1 -2
  5. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/scripts/test_ray_locals.py +1 -2
  6. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/multi_worker/process.py +25 -18
  7. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.githooks/pre-push +0 -0
  8. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/copilot-instructions.md +0 -0
  9. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/prompts/improveParallelErrorHandling.prompt.md +0 -0
  10. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/skills/caching-utilities/SKILL.md +0 -0
  11. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/skills/caching-utilities/examples/caching_example.py +0 -0
  12. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/skills/io-utilities/SKILL.md +0 -0
  13. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/skills/io-utilities/examples/io_example.py +0 -0
  14. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/skills/llm-integration/SKILL.md +0 -0
  15. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/skills/llm-integration/examples/llm_example.py +0 -0
  16. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/skills/multi-threading-processing/SKILL.md +0 -0
  17. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/skills/ray-distributed-computing/SKILL.md +0 -0
  18. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/skills/skill-creation/SKILL.md +0 -0
  19. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/skills/vision-utilities/SKILL.md +0 -0
  20. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/skills/vision-utilities/examples/vision_example.py +0 -0
  21. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.github/workflows/publish.yml +0 -0
  22. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.gitignore +0 -0
  23. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/.pre-commit-config.yaml +0 -0
  24. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/AGENTS.md +0 -0
  25. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/bumpversion.sh +0 -0
  26. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/debug/debug_generate_response.py +0 -0
  27. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/debug/debug_n_param.py +0 -0
  28. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/debug/debug_n_structure.py +0 -0
  29. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/debug/integration_test.py +0 -0
  30. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/debug/test_decode_api.py +0 -0
  31. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/debug/test_endpoints.py +0 -0
  32. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/debug/test_generate.py +0 -0
  33. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/debug/test_generate_endpoint.py +0 -0
  34. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/docs/GENERATE_QUICKREF.md +0 -0
  35. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/docs/IMPLEMENTATION.md +0 -0
  36. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/docs/QUICKSTART.md +0 -0
  37. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/docs/TOKENIZATION.md +0 -0
  38. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/docs/TOKENIZATION_IMPLEMENTATION.md +0 -0
  39. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/docs/zero_copy_sharing.md +0 -0
  40. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/examples/generate_example.py +0 -0
  41. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/examples/llm_ray_example.py +0 -0
  42. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/examples/pytorch_large_model.py +0 -0
  43. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/examples/shared_kwargs_example.py +0 -0
  44. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/examples/temperature_range_example.py +0 -0
  45. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/examples/test_parallel_gpu.py +0 -0
  46. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/examples/test_share_ray.py +0 -0
  47. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/examples/tokenization_example.py +0 -0
  48. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/examples/vision_utils_example.py +0 -0
  49. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/experiments/exp1/dockerfile +0 -0
  50. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/experiments/exp1/run_in_docker.sh +0 -0
  51. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/experiments/exp1/test.png +0 -0
  52. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/experiments/test_read_image.py +0 -0
  53. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/notebooks/README.ipynb +0 -0
  54. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/notebooks/llm_utils/llm_as_a_judge.ipynb +0 -0
  55. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/notebooks/parallel_gpu_pool.ipynb +0 -0
  56. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/notebooks/ray_tutorial.ipynb +0 -0
  57. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/notebooks/test_multi_thread.ipynb +0 -0
  58. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/ruff.toml +0 -0
  59. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/scripts/bug.py +0 -0
  60. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/scripts/bug_simple.py +0 -0
  61. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/scripts/debug_import_time.py +0 -0
  62. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/scripts/deploy.sh +0 -0
  63. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/scripts/imports.sh +0 -0
  64. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/scripts/test.py +0 -0
  65. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/scripts/test_both_backends.py +0 -0
  66. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/scripts/test_error_handling.py +0 -0
  67. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/scripts/test_import_time_vision.py +0 -0
  68. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/scripts/test_ray_mp.py +0 -0
  69. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/setup.cfg +0 -0
  70. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/datasets_utils/convert_to_arrow.py +0 -0
  71. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/__init__.py +0 -0
  72. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/chat_format/__init__.py +0 -0
  73. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/chat_format/display.py +0 -0
  74. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/chat_format/transform.py +0 -0
  75. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/chat_format/utils.py +0 -0
  76. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/group_messages.py +0 -0
  77. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/llm_ray.py +0 -0
  78. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/__init__.py +0 -0
  79. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/async_lm/__init__.py +0 -0
  80. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/async_lm/_utils.py +0 -0
  81. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/async_lm/async_llm_task.py +0 -0
  82. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/async_lm/async_lm.py +0 -0
  83. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/async_lm/async_lm_base.py +0 -0
  84. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/async_lm/lm_specific.py +0 -0
  85. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/base_prompt_builder.py +0 -0
  86. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/llm.py +0 -0
  87. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/llm_signature.py +0 -0
  88. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/lm_base.py +0 -0
  89. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/mixins.py +0 -0
  90. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/openai_memoize.py +0 -0
  91. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/signature.py +0 -0
  92. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/lm/utils.py +0 -0
  93. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/scripts/README.md +0 -0
  94. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/scripts/fast_vllm.py +0 -0
  95. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/scripts/vllm_load_balancer.py +0 -0
  96. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/scripts/vllm_serve.py +0 -0
  97. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/vector_cache/__init__.py +0 -0
  98. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/vector_cache/cli.py +0 -0
  99. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/vector_cache/core.py +0 -0
  100. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/vector_cache/types.py +0 -0
  101. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/llm_utils/vector_cache/utils.py +0 -0
  102. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/__imports.py +0 -0
  103. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/__init__.py +0 -0
  104. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/common/__init__.py +0 -0
  105. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/common/clock.py +0 -0
  106. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/common/function_decorator.py +0 -0
  107. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/common/logger.py +0 -0
  108. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/common/notebook_utils.py +0 -0
  109. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/common/patcher.py +0 -0
  110. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/common/report_manager.py +0 -0
  111. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/common/utils_cache.py +0 -0
  112. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/common/utils_io.py +0 -0
  113. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/common/utils_misc.py +0 -0
  114. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/common/utils_print.py +0 -0
  115. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/multi_worker/__init__.py +0 -0
  116. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/multi_worker/dataset_ray.py +0 -0
  117. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/multi_worker/parallel_gpu_pool.py +0 -0
  118. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/multi_worker/progress.py +0 -0
  119. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/multi_worker/thread.py +0 -0
  120. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/scripts/__init__.py +0 -0
  121. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/scripts/mpython.py +0 -0
  122. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/speedy_utils/scripts/openapi_client_codegen.py +0 -0
  123. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/vision_utils/README.md +0 -0
  124. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/vision_utils/__init__.py +0 -0
  125. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/vision_utils/io_utils.py +0 -0
  126. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/src/vision_utils/plot.py +0 -0
  127. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/test_s3.py +0 -0
  128. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/import_all.py +0 -0
  129. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/import_time_report.py +0 -0
  130. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/integration_test.py +0 -0
  131. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/llm_utils/test_llm_mixins.py +0 -0
  132. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/sample_objects.py +0 -0
  133. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/test.py +0 -0
  134. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/test_logger.py +0 -0
  135. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/test_logger_format.py +0 -0
  136. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/test_memoize_typing.py +0 -0
  137. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/test_mpython.py +0 -0
  138. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/test_multithread_error_trace.py +0 -0
  139. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/test_process.py +0 -0
  140. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/test_process_update.py +0 -0
  141. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/test_pytorch_sharing.py +0 -0
  142. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/test_shared_kwargs.py +0 -0
  143. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/test_thread.py +0 -0
  144. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/tests/test_tokenization.py +0 -0
  145. {speedy_utils-1.1.43 → speedy_utils-1.1.44}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: speedy-utils
3
- Version: 1.1.43
3
+ Version: 1.1.44
4
4
  Summary: Fast and easy-to-use package for data science
5
5
  Project-URL: Homepage, https://github.com/anhvth/speedy
6
6
  Project-URL: Repository, https://github.com/anhvth/speedy
@@ -58,13 +58,48 @@ Description-Content-Type: text/markdown
58
58
 
59
59
  **Speedy Utils** is a Python utility library designed to streamline common programming tasks such as caching, parallel processing, file I/O, and data manipulation. It provides a collection of decorators, functions, and classes to enhance productivity and performance in your Python projects.
60
60
 
61
+ ## 🚀 Recent Updates (January 27, 2026)
62
+
63
+ **Enhanced Error Handling in Parallel Processing:**
64
+ - Rich-formatted error tracebacks with code context and syntax highlighting
65
+ - Three error handling modes: 'raise', 'ignore', and 'log'
66
+ - Filtered tracebacks focusing on user code (hiding infrastructure)
67
+ - Real-time progress reporting with error/success statistics
68
+ - Automatic error logging to timestamped files
69
+ - Caller frame information showing where parallel functions were invoked
70
+
71
+ ## Quick Start
72
+
73
+ ### Parallel Processing with Error Handling
74
+
75
+ ```python
76
+ from speedy_utils import multi_thread, multi_process
77
+
78
+ # Simple parallel processing
79
+ results = multi_thread(lambda x: x * 2, [1, 2, 3, 4, 5])
80
+ # Results: [2, 4, 6, 8, 10]
81
+
82
+ # Robust processing with error handling
83
+ def process_item(item):
84
+ if item == 3:
85
+ raise ValueError(f"Cannot process item {item}")
86
+ return item * 2
87
+
88
+ # Continue processing despite errors
89
+ results = multi_thread(process_item, [1, 2, 3, 4, 5], error_handler='log')
90
+ # Results: [2, 4, None, 8, 10] - errors logged automatically
91
+ ```
92
+
61
93
  ## Table of Contents
62
94
 
95
+ - [🚀 Recent Updates](#-recent-updates-january-27-2026)
96
+ - [Quick Start](#quick-start)
63
97
  - [Features](#features)
64
98
  - [Installation](#installation)
65
99
  - [Usage](#usage)
66
- - [Caching](#caching)
67
100
  - [Parallel Processing](#parallel-processing)
101
+ - [Enhanced Error Handling](#enhanced-error-handling)
102
+ - [Caching](#caching)
68
103
  - [File I/O](#file-io)
69
104
  - [Data Manipulation](#data-manipulation)
70
105
  - [Utility Functions](#utility-functions)
@@ -73,11 +108,12 @@ Description-Content-Type: text/markdown
73
108
  ## Features
74
109
 
75
110
  - **Caching Mechanisms**: Disk-based and in-memory caching to optimize function calls.
76
- - **Parallel Processing**: Multi-threading, multi-processing, and asynchronous multi-threading utilities.
111
+ - **Parallel Processing**: Multi-threading, multi-processing, and asynchronous multi-threading utilities with enhanced error handling.
77
112
  - **File I/O**: Simplified JSON, JSONL, and pickle file handling with support for various file extensions.
78
113
  - **Data Manipulation**: Utilities for flattening lists and dictionaries, converting data types, and more.
79
114
  - **Timing Utilities**: Tools to measure and log execution time of functions and processes.
80
115
  - **Pretty Printing**: Enhanced printing functions for structured data, including HTML tables for Jupyter notebooks.
116
+ - **Enhanced Error Handling**: Rich error tracebacks with code context, configurable error handling modes ('raise', 'ignore', 'log'), and detailed progress reporting.
81
117
 
82
118
  ## Installation
83
119
 
@@ -162,20 +198,132 @@ result = compute_sum(5, 7) # Retrieved from in-memory cache
162
198
 
163
199
  ### Parallel Processing
164
200
 
165
- #### Multi-threading
201
+ #### Multi-threading with Enhanced Error Handling
166
202
 
167
- Execute functions concurrently using multiple threads. This approach is straightforward and automatically handles both notebook and Python script executions. In a notebook environment, it delegates the running thread to a separate process. If interrupted, it immediately stops this process, avoiding thread dependency issues where threads continue running until all tasks are completed.
203
+ Execute functions concurrently using multiple threads with comprehensive error handling. The enhanced error handling provides three modes: 'raise' (default), 'ignore', and 'log'. When errors occur, you'll see rich-formatted tracebacks with code context and caller information.
168
204
 
169
205
  ```python
170
206
  from speedy_utils import multi_thread
171
207
 
172
208
  def process_item(item):
173
- # Your processing logic
209
+ # Simulate processing that might fail
210
+ if item == 3:
211
+ raise ValueError(f"Invalid item: {item}")
174
212
  return item * 2
175
213
 
176
214
  items = [1, 2, 3, 4, 5]
177
- results = multi_thread(process_item, items, workers=3)
178
- print(results) # [2, 4, 6, 8, 10]
215
+
216
+ # Default behavior: raise on first error with rich traceback
217
+ try:
218
+ results = multi_thread(process_item, items, workers=3)
219
+ except SystemExit:
220
+ print("Error occurred and was displayed with rich formatting")
221
+
222
+ # Continue processing on errors, return None for failed items
223
+ results = multi_thread(process_item, items, workers=3, error_handler='ignore')
224
+ print(results) # [2, 4, None, 8, 10]
225
+
226
+ # Log errors to files and continue processing
227
+ results = multi_thread(process_item, items, workers=3, error_handler='log', max_error_files=10)
228
+ print(results) # [2, 4, None, 8, 10] - errors logged to .cache/speedy_utils/error_logs/
229
+ ```
230
+
231
+ #### Multi-processing with Error Handling
232
+
233
+ Process items across multiple processes with the same enhanced error handling capabilities.
234
+
235
+ ```python
236
+ from speedy_utils import multi_process
237
+
238
+ def risky_computation(x):
239
+ """Computation that might fail for certain inputs."""
240
+ if x % 5 == 0:
241
+ raise RuntimeError(f"Cannot process multiples of 5: {x}")
242
+ return x ** 2
243
+
244
+ data = list(range(12))
245
+
246
+ # Process with error logging (continues on errors)
247
+ results = multi_process(
248
+ risky_computation,
249
+ data,
250
+ backend='mp',
251
+ error_handler='log',
252
+ max_error_files=5
253
+ )
254
+ print(results) # [0, 1, 4, 9, 16, None, 36, 49, 64, 81, None, 121]
255
+ ```
256
+
257
+ ### Enhanced Error Handling
258
+
259
+ **Speedy Utils** now provides comprehensive error handling for parallel processing with rich formatting and detailed diagnostics.
260
+
261
+ #### Rich Error Tracebacks
262
+
263
+ When errors occur, you'll see beautifully formatted tracebacks with:
264
+ - **Code context**: Lines of code around the error location
265
+ - **Caller information**: Shows where the parallel function was invoked
266
+ - **Filtered frames**: Focuses on user code, hiding infrastructure details
267
+ - **Color coding**: Easy-to-read formatting with syntax highlighting
268
+
269
+ #### Error Handling Modes
270
+
271
+ Choose how to handle errors in parallel processing:
272
+
273
+ - **`'raise'` (default)**: Stop on first error with detailed traceback
274
+ - **`'ignore'`**: Continue processing, return `None` for failed items
275
+ - **`'log'`**: Log errors to files and continue processing
276
+
277
+ #### Error Logging
278
+
279
+ When using `error_handler='log'`, errors are automatically saved to timestamped files in `.cache/speedy_utils/error_logs/` with full context and stack traces.
280
+
281
+ #### Progress Reporting with Error Statistics
282
+
283
+ Progress bars now show real-time error and success counts:
284
+
285
+ ```
286
+ Multi-thread [8/10] [00:02<00:00, 3.45it/s, success=8, errors=2, pending=0]
287
+ ```
288
+
289
+ This makes it easy to monitor processing health at a glance.
290
+
291
+ #### Example: Robust Data Processing
292
+
293
+ ```python
294
+ from speedy_utils import multi_thread
295
+
296
+ def process_data_record(record):
297
+ """Process a data record that might have issues."""
298
+ try:
299
+ # Your processing logic here
300
+ value = record['value'] / record['divisor']
301
+ return {'result': value, 'status': 'success'}
302
+ except KeyError as e:
303
+ raise ValueError(f"Missing required field in record: {e}")
304
+ except ZeroDivisionError:
305
+ raise ValueError("Division by zero in record")
306
+
307
+ # Sample data with some problematic records
308
+ data = [
309
+ {'value': 10, 'divisor': 2}, # OK
310
+ {'value': 15, 'divisor': 0}, # Will error
311
+ {'value': 20, 'divisor': 4}, # OK
312
+ {'value': 25}, # Missing divisor - will error
313
+ ]
314
+
315
+ # Process with error logging - continues despite errors
316
+ results = multi_thread(
317
+ process_data_record,
318
+ data,
319
+ workers=4,
320
+ error_handler='log',
321
+ max_error_files=10
322
+ )
323
+
324
+ print("Results:", results)
325
+ # Output: Results: [{'result': 5.0, 'status': 'success'}, None, {'result': 5.0, 'status': 'success'}, None]
326
+ # Errors are logged to files for later analysis
179
327
  ```
180
328
 
181
329
  ### File I/O
@@ -6,13 +6,48 @@
6
6
 
7
7
  **Speedy Utils** is a Python utility library designed to streamline common programming tasks such as caching, parallel processing, file I/O, and data manipulation. It provides a collection of decorators, functions, and classes to enhance productivity and performance in your Python projects.
8
8
 
9
+ ## 🚀 Recent Updates (January 27, 2026)
10
+
11
+ **Enhanced Error Handling in Parallel Processing:**
12
+ - Rich-formatted error tracebacks with code context and syntax highlighting
13
+ - Three error handling modes: 'raise', 'ignore', and 'log'
14
+ - Filtered tracebacks focusing on user code (hiding infrastructure)
15
+ - Real-time progress reporting with error/success statistics
16
+ - Automatic error logging to timestamped files
17
+ - Caller frame information showing where parallel functions were invoked
18
+
19
+ ## Quick Start
20
+
21
+ ### Parallel Processing with Error Handling
22
+
23
+ ```python
24
+ from speedy_utils import multi_thread, multi_process
25
+
26
+ # Simple parallel processing
27
+ results = multi_thread(lambda x: x * 2, [1, 2, 3, 4, 5])
28
+ # Results: [2, 4, 6, 8, 10]
29
+
30
+ # Robust processing with error handling
31
+ def process_item(item):
32
+ if item == 3:
33
+ raise ValueError(f"Cannot process item {item}")
34
+ return item * 2
35
+
36
+ # Continue processing despite errors
37
+ results = multi_thread(process_item, [1, 2, 3, 4, 5], error_handler='log')
38
+ # Results: [2, 4, None, 8, 10] - errors logged automatically
39
+ ```
40
+
9
41
  ## Table of Contents
10
42
 
43
+ - [🚀 Recent Updates](#-recent-updates-january-27-2026)
44
+ - [Quick Start](#quick-start)
11
45
  - [Features](#features)
12
46
  - [Installation](#installation)
13
47
  - [Usage](#usage)
14
- - [Caching](#caching)
15
48
  - [Parallel Processing](#parallel-processing)
49
+ - [Enhanced Error Handling](#enhanced-error-handling)
50
+ - [Caching](#caching)
16
51
  - [File I/O](#file-io)
17
52
  - [Data Manipulation](#data-manipulation)
18
53
  - [Utility Functions](#utility-functions)
@@ -21,11 +56,12 @@
21
56
  ## Features
22
57
 
23
58
  - **Caching Mechanisms**: Disk-based and in-memory caching to optimize function calls.
24
- - **Parallel Processing**: Multi-threading, multi-processing, and asynchronous multi-threading utilities.
59
+ - **Parallel Processing**: Multi-threading, multi-processing, and asynchronous multi-threading utilities with enhanced error handling.
25
60
  - **File I/O**: Simplified JSON, JSONL, and pickle file handling with support for various file extensions.
26
61
  - **Data Manipulation**: Utilities for flattening lists and dictionaries, converting data types, and more.
27
62
  - **Timing Utilities**: Tools to measure and log execution time of functions and processes.
28
63
  - **Pretty Printing**: Enhanced printing functions for structured data, including HTML tables for Jupyter notebooks.
64
+ - **Enhanced Error Handling**: Rich error tracebacks with code context, configurable error handling modes ('raise', 'ignore', 'log'), and detailed progress reporting.
29
65
 
30
66
  ## Installation
31
67
 
@@ -110,20 +146,132 @@ result = compute_sum(5, 7) # Retrieved from in-memory cache
110
146
 
111
147
  ### Parallel Processing
112
148
 
113
- #### Multi-threading
149
+ #### Multi-threading with Enhanced Error Handling
114
150
 
115
- Execute functions concurrently using multiple threads. This approach is straightforward and automatically handles both notebook and Python script executions. In a notebook environment, it delegates the running thread to a separate process. If interrupted, it immediately stops this process, avoiding thread dependency issues where threads continue running until all tasks are completed.
151
+ Execute functions concurrently using multiple threads with comprehensive error handling. The enhanced error handling provides three modes: 'raise' (default), 'ignore', and 'log'. When errors occur, you'll see rich-formatted tracebacks with code context and caller information.
116
152
 
117
153
  ```python
118
154
  from speedy_utils import multi_thread
119
155
 
120
156
  def process_item(item):
121
- # Your processing logic
157
+ # Simulate processing that might fail
158
+ if item == 3:
159
+ raise ValueError(f"Invalid item: {item}")
122
160
  return item * 2
123
161
 
124
162
  items = [1, 2, 3, 4, 5]
125
- results = multi_thread(process_item, items, workers=3)
126
- print(results) # [2, 4, 6, 8, 10]
163
+
164
+ # Default behavior: raise on first error with rich traceback
165
+ try:
166
+ results = multi_thread(process_item, items, workers=3)
167
+ except SystemExit:
168
+ print("Error occurred and was displayed with rich formatting")
169
+
170
+ # Continue processing on errors, return None for failed items
171
+ results = multi_thread(process_item, items, workers=3, error_handler='ignore')
172
+ print(results) # [2, 4, None, 8, 10]
173
+
174
+ # Log errors to files and continue processing
175
+ results = multi_thread(process_item, items, workers=3, error_handler='log', max_error_files=10)
176
+ print(results) # [2, 4, None, 8, 10] - errors logged to .cache/speedy_utils/error_logs/
177
+ ```
178
+
179
+ #### Multi-processing with Error Handling
180
+
181
+ Process items across multiple processes with the same enhanced error handling capabilities.
182
+
183
+ ```python
184
+ from speedy_utils import multi_process
185
+
186
+ def risky_computation(x):
187
+ """Computation that might fail for certain inputs."""
188
+ if x % 5 == 0:
189
+ raise RuntimeError(f"Cannot process multiples of 5: {x}")
190
+ return x ** 2
191
+
192
+ data = list(range(12))
193
+
194
+ # Process with error logging (continues on errors)
195
+ results = multi_process(
196
+ risky_computation,
197
+ data,
198
+ backend='mp',
199
+ error_handler='log',
200
+ max_error_files=5
201
+ )
202
+ print(results) # [0, 1, 4, 9, 16, None, 36, 49, 64, 81, None, 121]
203
+ ```
204
+
205
+ ### Enhanced Error Handling
206
+
207
+ **Speedy Utils** now provides comprehensive error handling for parallel processing with rich formatting and detailed diagnostics.
208
+
209
+ #### Rich Error Tracebacks
210
+
211
+ When errors occur, you'll see beautifully formatted tracebacks with:
212
+ - **Code context**: Lines of code around the error location
213
+ - **Caller information**: Shows where the parallel function was invoked
214
+ - **Filtered frames**: Focuses on user code, hiding infrastructure details
215
+ - **Color coding**: Easy-to-read formatting with syntax highlighting
216
+
217
+ #### Error Handling Modes
218
+
219
+ Choose how to handle errors in parallel processing:
220
+
221
+ - **`'raise'` (default)**: Stop on first error with detailed traceback
222
+ - **`'ignore'`**: Continue processing, return `None` for failed items
223
+ - **`'log'`**: Log errors to files and continue processing
224
+
225
+ #### Error Logging
226
+
227
+ When using `error_handler='log'`, errors are automatically saved to timestamped files in `.cache/speedy_utils/error_logs/` with full context and stack traces.
228
+
229
+ #### Progress Reporting with Error Statistics
230
+
231
+ Progress bars now show real-time error and success counts:
232
+
233
+ ```
234
+ Multi-thread [8/10] [00:02<00:00, 3.45it/s, success=8, errors=2, pending=0]
235
+ ```
236
+
237
+ This makes it easy to monitor processing health at a glance.
238
+
239
+ #### Example: Robust Data Processing
240
+
241
+ ```python
242
+ from speedy_utils import multi_thread
243
+
244
+ def process_data_record(record):
245
+ """Process a data record that might have issues."""
246
+ try:
247
+ # Your processing logic here
248
+ value = record['value'] / record['divisor']
249
+ return {'result': value, 'status': 'success'}
250
+ except KeyError as e:
251
+ raise ValueError(f"Missing required field in record: {e}")
252
+ except ZeroDivisionError:
253
+ raise ValueError("Division by zero in record")
254
+
255
+ # Sample data with some problematic records
256
+ data = [
257
+ {'value': 10, 'divisor': 2}, # OK
258
+ {'value': 15, 'divisor': 0}, # Will error
259
+ {'value': 20, 'divisor': 4}, # OK
260
+ {'value': 25}, # Missing divisor - will error
261
+ ]
262
+
263
+ # Process with error logging - continues despite errors
264
+ results = multi_thread(
265
+ process_data_record,
266
+ data,
267
+ workers=4,
268
+ error_handler='log',
269
+ max_error_files=10
270
+ )
271
+
272
+ print("Results:", results)
273
+ # Output: Results: [{'result': 5.0, 'status': 'success'}, None, {'result': 5.0, 'status': 'success'}, None]
274
+ # Errors are logged to files for later analysis
127
275
  ```
128
276
 
129
277
  ### File I/O
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "speedy-utils"
3
- version = "1.1.43"
3
+ version = "1.1.44"
4
4
  description = "Fast and easy-to-use package for data science"
5
5
  authors = [{ name = "AnhVTH", email = "anhvth.226@gmail.com" }]
6
6
  readme = "README.md"
@@ -15,5 +15,4 @@ def process_data(item):
15
15
 
16
16
  if __name__ == '__main__':
17
17
  inputs = range(5)
18
- ret = multi_process(process_data, inputs, backend='mp', error_handler='log')
19
- print(ret)
18
+ multi_process(process_data, inputs, backend='mp')
@@ -3,8 +3,7 @@ from speedy_utils import *
3
3
  def do_something(x):
4
4
  x = 10
5
5
  y = 0
6
- # Intentionally cause division by zero error for testing
7
- _ = x/y
6
+ x/y
8
7
 
9
8
  if __name__ == '__main__':
10
9
  inputs = range(10)
@@ -115,32 +115,39 @@ class ErrorStats:
115
115
  func_name: str,
116
116
  ) -> str:
117
117
  """Write error details to a log file."""
118
+ from io import StringIO
119
+ from rich.console import Console
120
+
118
121
  log_path = self._error_log_dir / f'{idx}.log'
119
122
 
123
+ output = StringIO()
124
+ console = Console(file=output, width=120, no_color=False)
125
+
120
126
  # Format traceback
121
127
  tb_lines = self._format_traceback(error)
122
128
 
123
- content = []
124
- content.append(f'{"=" * 60}')
125
- content.append(f'Error at index: {idx}')
126
- content.append(f'Function: {func_name}')
127
- content.append(f'Error Type: {type(error).__name__}')
128
- content.append(f'Error Message: {error}')
129
- content.append(f'{"=" * 60}')
130
- content.append('')
131
- content.append('Input:')
132
- content.append('-' * 40)
129
+ console.print(f'{"=" * 60}')
130
+ console.print(f'Error at index: {idx}')
131
+ console.print(f'Function: {func_name}')
132
+ console.print(f'Error Type: {type(error).__name__}')
133
+ console.print(f'Error Message: {error}')
134
+ console.print(f'{"=" * 60}')
135
+ console.print('')
136
+ console.print('Input:')
137
+ console.print('-' * 40)
133
138
  try:
134
- content.append(repr(input_value))
139
+ import json
140
+ console.print(json.dumps(input_value, indent=2))
135
141
  except Exception:
136
- content.append('<unable to repr input>')
137
- content.append('')
138
- content.append('Traceback:')
139
- content.append('-' * 40)
140
- content.extend(tb_lines)
142
+ console.print(repr(input_value))
143
+ console.print('')
144
+ console.print('Traceback:')
145
+ console.print('-' * 40)
146
+ for line in tb_lines:
147
+ console.print(line)
141
148
 
142
149
  with open(log_path, 'w') as f:
143
- f.write('\n'.join(content))
150
+ f.write(output.getvalue())
144
151
 
145
152
  return str(log_path)
146
153
 
@@ -824,7 +831,7 @@ def multi_process(
824
831
  log_worker: Literal['zero', 'first', 'all'] = 'first',
825
832
  total_items: int | None = None,
826
833
  poll_interval: float = 0.3,
827
- error_handler: ErrorHandlerType = 'raise',
834
+ error_handler: ErrorHandlerType = 'log',
828
835
  max_error_files: int = 100,
829
836
  **func_kwargs: Any,
830
837
  ) -> list[Any]:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes