speedy-utils 1.1.20__tar.gz → 1.1.22__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 (71) hide show
  1. speedy_utils-1.1.22/.github/copilot-instructions.md +67 -0
  2. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/PKG-INFO +1 -1
  3. speedy_utils-1.1.22/notebooks/test_multi_thread.ipynb +82 -0
  4. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/pyproject.toml +1 -1
  5. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/__init__.py +12 -1
  6. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/lm/llm_task.py +172 -251
  7. speedy_utils-1.1.22/src/llm_utils/lm/utils.py +345 -0
  8. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/multi_worker/process.py +128 -27
  9. speedy_utils-1.1.22/src/speedy_utils/multi_worker/thread.py +611 -0
  10. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/tests/test_thread.py +100 -2
  11. speedy_utils-1.1.20/.github/copilot-instructions.md +0 -39
  12. speedy_utils-1.1.20/src/llm_utils/lm/utils.py +0 -123
  13. speedy_utils-1.1.20/src/speedy_utils/multi_worker/thread.py +0 -496
  14. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/.github/workflows/publish.yml +0 -0
  15. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/.gitignore +0 -0
  16. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/.pre-commit-config.yaml +0 -0
  17. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/README.md +0 -0
  18. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/bumpversion.sh +0 -0
  19. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/ruff.toml +0 -0
  20. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/scripts/deploy.sh +0 -0
  21. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/setup.cfg +0 -0
  22. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/chat_format/__init__.py +0 -0
  23. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/chat_format/display.py +0 -0
  24. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/chat_format/transform.py +0 -0
  25. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/chat_format/utils.py +0 -0
  26. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/group_messages.py +0 -0
  27. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/lm/__init__.py +0 -0
  28. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/lm/async_lm/__init__.py +0 -0
  29. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/lm/async_lm/_utils.py +0 -0
  30. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/lm/async_lm/async_llm_task.py +0 -0
  31. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/lm/async_lm/async_lm.py +0 -0
  32. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/lm/async_lm/async_lm_base.py +0 -0
  33. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/lm/async_lm/lm_specific.py +0 -0
  34. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/lm/base_prompt_builder.py +0 -0
  35. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/lm/lm.py +0 -0
  36. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/lm/lm_base.py +0 -0
  37. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/lm/openai_memoize.py +0 -0
  38. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/scripts/README.md +0 -0
  39. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/scripts/vllm_load_balancer.py +0 -0
  40. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/scripts/vllm_serve.py +0 -0
  41. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/vector_cache/__init__.py +0 -0
  42. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/vector_cache/cli.py +0 -0
  43. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/vector_cache/core.py +0 -0
  44. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/vector_cache/types.py +0 -0
  45. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/llm_utils/vector_cache/utils.py +0 -0
  46. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/__init__.py +0 -0
  47. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/all.py +0 -0
  48. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/common/__init__.py +0 -0
  49. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/common/clock.py +0 -0
  50. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/common/function_decorator.py +0 -0
  51. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/common/logger.py +0 -0
  52. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/common/notebook_utils.py +0 -0
  53. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/common/patcher.py +0 -0
  54. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/common/report_manager.py +0 -0
  55. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/common/utils_cache.py +0 -0
  56. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/common/utils_io.py +0 -0
  57. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/common/utils_misc.py +0 -0
  58. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/common/utils_print.py +0 -0
  59. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/multi_worker/__init__.py +0 -0
  60. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/scripts/__init__.py +0 -0
  61. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/scripts/mpython.py +0 -0
  62. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/src/speedy_utils/scripts/openapi_client_codegen.py +0 -0
  63. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/tests/sample_objects.py +0 -0
  64. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/tests/test.py +0 -0
  65. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/tests/test_logger.py +0 -0
  66. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/tests/test_logger_format.py +0 -0
  67. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/tests/test_memoize_typing.py +0 -0
  68. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/tests/test_mpython.py +0 -0
  69. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/tests/test_process.py +0 -0
  70. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/tests/test_process_update.py +0 -0
  71. {speedy_utils-1.1.20 → speedy_utils-1.1.22}/uv.lock +0 -0
@@ -0,0 +1,67 @@
1
+ ## Coding Standards
2
+
3
+ - **Naming**
4
+ - snake_case for functions & variables
5
+ - PascalCase for classes
6
+ - **Formatting**
7
+ - 4-space indentation
8
+ - Single quotes for strings
9
+ - f-strings for interpolation
10
+ - **Typing & Docs**
11
+ - Add type hints to all public functions & methods
12
+ - Keep docstrings minimal; comment only non-obvious logic
13
+ - **Comparisons**
14
+ - Use `is` / `is not` when comparing with `None`
15
+
16
+ ## Tooling Assumptions
17
+
18
+ - Editor: **VS Code**
19
+ - Pylance setting: `"python.analysis.typeCheckingMode": "basic"`
20
+ - Code must satisfy **basic** type checking (no strict-mode warnings).
21
+ - Prefer clear, straightforward typing over complex generics.
22
+
23
+ ## Preferred Libraries
24
+
25
+ - Logging: `loguru`
26
+ - Database: `Peewee` + **PostgreSQL** (or **SQLite** locally)
27
+ - Web API: `FastAPI`
28
+ - Pydantic: `FastAPI`
29
+ - Testing: `pytest`
30
+ - Async: `asyncio` + `aiohttp`
31
+ - PydanticV2: `pydantic` (v2.x)
32
+
33
+ ## Project Architecture
34
+
35
+ - **speedy_utils**: General utility library for caching, parallel processing, file I/O, data manipulation. See `src/speedy_utils/__init__.py` for public API.
36
+ - **llm_utils**: LLM-specific utilities including chat formatting, language model tasks, vector caching, and VLLM server management. See `src/llm_utils/__init__.py`.
37
+ - Data flows: Function caching with disk/memory backends, parallel execution via threads/processes, auto-detect file serialization (JSON/JSONL/Pickle).
38
+
39
+ ## Developer Workflows
40
+
41
+ - **Build/Install**: `uv pip install .` or `pip install -e .` for development.
42
+ - **Test**: `python test.py` (runs unittest suite) or `pytest` for individual tests.
43
+ - **Lint/Format**: `ruff check .` and `ruff format .` (configured in `ruff.toml`).
44
+ - **Type Check**: `mypy` (strict settings in `pyproject.toml`).
45
+ - **Debug**: Use `ipdb` for interactive debugging, `debugpy` for VS Code.
46
+ - **Scripts**: `mpython` for multi-process Python execution, `svllm` for VLLM server, `svllm-lb` for load balancer.
47
+
48
+ ## Integration Points
49
+
50
+ - **External APIs**: OpenAI API via `llm_utils.lm.openai_memoize`, VLLM servers for local inference.
51
+ - **Distributed**: Ray backend for parallel processing (install with `[ray]` extra).
52
+ - **Async**: `aiohttp` for async HTTP, `asyncio` for concurrency.
53
+ - **Dependencies**: Managed via `pyproject.toml`, install with `uv` preferred.
54
+
55
+ ## When user provide a list of problems:
56
+
57
+ Directly go over the list and edit the code to fix the problems.
58
+
59
+ ## Common problems when generated code to avoid:
60
+
61
+ _Stick to these choices unless explicitly instructed otherwise._
62
+
63
+ ---
64
+
65
+ ## Rules for Code Generation
66
+
67
+ - Each line should less than 88 characters.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: speedy-utils
3
- Version: 1.1.20
3
+ Version: 1.1.22
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
@@ -0,0 +1,82 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "4c7c0614",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "from speedy_utils import *"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": null,
16
+ "id": "3725a7bb",
17
+ "metadata": {},
18
+ "outputs": [],
19
+ "source": [
20
+ "def sleep_and_count(n):\n",
21
+ " thread_id = n\n",
22
+ " n = 10\n",
23
+ " for i in range(n):\n",
24
+ " time.sleep(2)\n",
25
+ " print(f'[Thread {thread_id}] Count: {i+1}/{n}')\n",
26
+ " return True\n",
27
+ "\n",
28
+ "inputs = list(range(10))\n",
29
+ "results = multi_thread(sleep_and_count, inputs, workers=4)"
30
+ ]
31
+ },
32
+ {
33
+ "cell_type": "code",
34
+ "execution_count": null,
35
+ "id": "ace1dc5c",
36
+ "metadata": {},
37
+ "outputs": [
38
+ {
39
+ "ename": "NameError",
40
+ "evalue": "name 'results' is not defined",
41
+ "output_type": "error",
42
+ "traceback": [
43
+ "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
44
+ "\u001b[31mNameError\u001b[39m Traceback (most recent call last)",
45
+ "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[15]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mresults\u001b[49m\n",
46
+ "\u001b[31mNameError\u001b[39m: name 'results' is not defined"
47
+ ]
48
+ }
49
+ ],
50
+ "source": []
51
+ },
52
+ {
53
+ "cell_type": "code",
54
+ "execution_count": null,
55
+ "id": "b98f317b",
56
+ "metadata": {},
57
+ "outputs": [],
58
+ "source": []
59
+ }
60
+ ],
61
+ "metadata": {
62
+ "kernelspec": {
63
+ "display_name": ".venv",
64
+ "language": "python",
65
+ "name": "python3"
66
+ },
67
+ "language_info": {
68
+ "codemirror_mode": {
69
+ "name": "ipython",
70
+ "version": 3
71
+ },
72
+ "file_extension": ".py",
73
+ "mimetype": "text/x-python",
74
+ "name": "python",
75
+ "nbconvert_exporter": "python",
76
+ "pygments_lexer": "ipython3",
77
+ "version": "3.13.7"
78
+ }
79
+ },
80
+ "nbformat": 4,
81
+ "nbformat_minor": 5
82
+ }
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "speedy-utils"
3
- version = "1.1.20"
3
+ version = "1.1.22"
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"
@@ -6,6 +6,15 @@ from llm_utils.lm.base_prompt_builder import BasePromptBuilder
6
6
 
7
7
  LLM = LLMTask
8
8
 
9
+ # Convenience functions for killing VLLM servers
10
+ def kill_all_vllm() -> int:
11
+ """Kill all tracked VLLM server processes. Returns number of processes killed."""
12
+ return LLMTask.kill_all_vllm()
13
+
14
+ def kill_vllm_on_port(port: int) -> bool:
15
+ """Kill VLLM server on specific port. Returns True if server was killed."""
16
+ return LLMTask.kill_vllm_on_port(port)
17
+
9
18
  from .chat_format import (
10
19
  build_chatml_input,
11
20
  display_chat_messages_as_html,
@@ -35,5 +44,7 @@ __all__ = [
35
44
  "get_model_name",
36
45
  "VectorCache",
37
46
  "BasePromptBuilder",
38
- "LLM"
47
+ "LLM",
48
+ "kill_all_vllm",
49
+ "kill_vllm_on_port"
39
50
  ]