Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
09ab3e1
feat: add download acceleration infrastructure
deanq Aug 16, 2025
795c9e5
feat: integrate download acceleration with dependency installer
deanq Aug 16, 2025
046eb58
feat: add workspace acceleration support
deanq Aug 16, 2025
45a65fe
test: add download acceleration test coverage
deanq Aug 16, 2025
ce51390
chore: moved test-handler files to src/
deanq Aug 16, 2025
6c04de1
feat: runtime uses aria2 for accelerated parallel downloads
deanq Aug 16, 2025
66eb286
chore: update project structure and dependencies
deanq Aug 16, 2025
1930b4b
chore: updated tetra-rp
deanq Aug 19, 2025
731fd56
build: local-execution-test use make test-handler
deanq Aug 19, 2025
e829140
chore: update CLAUDE.md
deanq Aug 19, 2025
104b2da
chore: move these values to constants.py for maintainability
deanq Aug 19, 2025
f8aa89a
feat: add system package acceleration with nala
deanq Aug 19, 2025
cd56185
refactor: disable Python package download acceleration
deanq Aug 20, 2025
d7c996d
test: uv is no longer part of download accelerator
deanq Aug 20, 2025
2ab93e3
feat: implement accelerate_downloads parameter logic in RemoteExecutor
deanq Aug 21, 2025
b50a7bf
feat: add pip fallback for Python dependencies when acceleration disa…
deanq Aug 21, 2025
440d00d
feat: enhance HF model caching with hf_transfer/hf_xet strategy
deanq Aug 21, 2025
0320e4d
test: add comprehensive coverage for accelerate_downloads parameter
deanq Aug 21, 2025
034f770
test: update integration tests for new acceleration parameter
deanq Aug 21, 2025
9531079
chore: update dependencies and constants for download acceleration
deanq Aug 21, 2025
d75d320
refactor: remove pip installation method from dependency installer
deanq Aug 21, 2025
227b33e
test: update unit tests to expect UV instead of pip
deanq Aug 21, 2025
338a165
test: rename test file from pip to UV naming convention
deanq Aug 21, 2025
f88745d
feat: implement parallel execution for accelerated downloads
deanq Aug 21, 2025
f22e74d
feat: add async wrapper for HuggingFace model download acceleration
deanq Aug 21, 2025
816fc75
test: update tests for parallel execution and async dependencies
deanq Aug 21, 2025
c9ad0d3
test: comprehensive test coverage expansion and cleanup
deanq Aug 21, 2025
e31137a
refactor: optimize HF acceleration to use native Hub features
deanq Aug 21, 2025
e1db417
chore: memory correction
deanq Aug 21, 2025
76ab9c0
feat: implement HuggingFace download acceleration strategies
deanq Aug 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: update project structure and dependencies
- Update test files moved to src/ directory
- Enhanced test coverage for acceleration features
- Updated dependencies and documentation
- Submodule updates for tetra-rp
  • Loading branch information
deanq committed Aug 16, 2025
commit 66eb286f168b8c1a85c111e42af430df59176521
41 changes: 19 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ requires-python = ">=3.9,<3.13"
dependencies = [
"cloudpickle>=3.1.1",
"pydantic>=2.11.4",
"requests>=2.25.0",
"runpod",
]

Expand All @@ -18,6 +19,7 @@ dev = [
"pytest-asyncio>=0.24.0",
"ruff>=0.8.0",
"mypy>=1.11.0",
"types-requests>=2.25.0",
]

[tool.pytest.ini_options]
Expand Down Expand Up @@ -48,40 +50,35 @@ filterwarnings = [
"ignore::pytest.PytestUnknownMarkWarning"
]

[tool.ruff]
# Exclude tetra-rp directory since it's a separate repository
exclude = [
"tetra-rp/",
]

[tool.mypy]
# Basic configuration
python_version = "3.9"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = false # Start lenient, can be stricter later
disallow_incomplete_defs = false
check_untyped_defs = true

# Import discovery
mypy_path = ["src"]
explicit_package_bases = true
namespace_packages = true

# Error output
check_untyped_defs = true
disallow_any_generics = true
disallow_untyped_defs = false
warn_redundant_casts = true
warn_unused_ignores = true
warn_return_any = true
strict_optional = true
show_error_codes = true
show_column_numbers = true
pretty = true

# Exclude directories
exclude = [
"tetra-rp/",
"tests/", # Start by excluding tests, can add later
]

# Per-module options
[[tool.mypy.overrides]]
module = [
"runpod.*",
"cloudpickle.*",
"cloudpickle",
"runpod",
"transformers",
]
ignore_missing_imports = true

[tool.ruff]
# Exclude tetra-rp directory since it's a separate repository
exclude = [
"tetra-rp/",
]
2 changes: 1 addition & 1 deletion src/class_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, workspace_manager):
super().__init__(workspace_manager)
# Instance registry for persistent class instances
self.class_instances: Dict[str, Any] = {}
self.instance_metadata: Dict[str, Dict] = {}
self.instance_metadata: Dict[str, Dict[str, Any]] = {}

def execute(self, request: FunctionRequest) -> FunctionResponse:
"""Execute class method - required by BaseExecutor interface."""
Expand Down
3 changes: 2 additions & 1 deletion src/handler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import runpod
import logging
import sys
from typing import Dict, Any

from remote_execution import FunctionRequest, FunctionResponse
from remote_executor import RemoteExecutor
Expand All @@ -13,7 +14,7 @@
)


async def handler(event: dict) -> dict:
async def handler(event: Dict[str, Any]) -> Dict[str, Any]:
"""
RunPod serverless function handler with dependency installation.
"""
Expand Down
10 changes: 8 additions & 2 deletions tests/integration/test_dependency_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,20 @@ def test_with_deps():
"obj", (object,), {"success": True, "stdout": "python deps installed"}
)()
mock_execute.return_value = type(
"obj", (object,), {"success": True, "result": "encoded_result"}
"obj",
(object,),
{
"success": True,
"result": "encoded_result",
"stdout": "function executed",
},
)()

result = await executor.ExecuteFunction(request)

# Verify all steps were called
mock_sys_deps.assert_called_once_with(["curl"])
mock_py_deps.assert_called_once_with(["requests"])
mock_py_deps.assert_called_once_with(["requests"], True)
mock_execute.assert_called_once_with(request)

assert result.success is True
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_handler_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TestHandlerIntegration:

def setup_method(self):
"""Setup for each test method."""
self.test_data_dir = Path(__file__).parent.parent.parent
self.test_data_dir = Path(__file__).parent.parent.parent / "src"
self.test_input_file = self.test_data_dir / "test_input.json"
self.test_class_input_file = self.test_data_dir / "test_class_input.json"

Expand Down
86 changes: 74 additions & 12 deletions tests/integration/test_runpod_volume_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,31 @@
import base64
import cloudpickle
import threading
from unittest.mock import Mock, patch
from unittest.mock import Mock, patch, MagicMock

from handler import RemoteExecutor, handler
from remote_execution import FunctionResponse
from constants import RUNPOD_VOLUME_PATH, VENV_DIR_NAME, RUNTIMES_DIR_NAME
from src.handler import RemoteExecutor, handler
from src.remote_execution import FunctionResponse
from src.constants import RUNPOD_VOLUME_PATH, VENV_DIR_NAME, RUNTIMES_DIR_NAME


class TestFullWorkflowWithVolume:
"""Test complete request workflows with volume integration."""

def setup_method(self):
# Patch subprocess.run globally for all tests in this class
class ContextManagerMock(MagicMock):
def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
pass

self.subprocess_run_patcher = patch("subprocess.run", new=ContextManagerMock())
self.subprocess_run_patcher.start()

def teardown_method(self):
self.subprocess_run_patcher.stop()

@patch("os.makedirs")
@patch("workspace_manager.WorkspaceManager._validate_virtual_environment")
@patch("os.path.exists")
Expand Down Expand Up @@ -177,17 +192,35 @@ def system_test():
assert result["success"] is True

# Should have called apt-get update and install
calls = [call[0][0] for call in mock_popen.call_args_list]
assert any("apt-get" in " ".join(call) and "update" in call for call in calls)
assert any("apt-get" in " ".join(call) and "curl" in call for call in calls)
assert any(
"uv" in call and "requests==2.25.1" in " ".join(call) for call in calls
)
popen_calls = [call[0][0] for call in mock_popen.call_args_list]
assert any(
"apt-get" in " ".join(call) and "curl" in " ".join(call)
for call in popen_calls
)
assert any(
"uv" in " ".join(call) and "requests==2.25.1" in " ".join(call)
for call in popen_calls
)


class TestConcurrentRequests:
"""Test realistic concurrent access scenarios."""

def setup_method(self):
# Patch subprocess.run globally for all tests in this class
class ContextManagerMock(MagicMock):
def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
pass

self.subprocess_run_patcher = patch("subprocess.run", new=ContextManagerMock())
self.subprocess_run_patcher.start()

def teardown_method(self):
self.subprocess_run_patcher.stop()

@patch("os.makedirs")
@patch("workspace_manager.WorkspaceManager._validate_virtual_environment")
@patch("os.path.exists")
Expand Down Expand Up @@ -331,6 +364,21 @@ def install_deps(executor, packages):
class TestMixedExecution:
"""Test mixed volume and non-volume execution scenarios."""

def setup_method(self):
# Patch subprocess.run globally for all tests in this class
class ContextManagerMock(MagicMock):
def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
pass

self.subprocess_run_patcher = patch("subprocess.run", new=ContextManagerMock())
self.subprocess_run_patcher.start()

def teardown_method(self):
self.subprocess_run_patcher.stop()

@patch("os.makedirs")
@patch("workspace_manager.WorkspaceManager._validate_virtual_environment")
@patch("os.path.exists")
Expand Down Expand Up @@ -395,11 +443,10 @@ async def test_fallback_on_volume_initialization_failure(
) # Volume exists but venv doesn't exist

# Mock file operations
mock_file = Mock()
mock_file = MagicMock()
mock_file.fileno.return_value = 3
mock_open.return_value.__enter__.return_value = mock_file

# Mock failed virtual environment creation
mock_process = Mock()
mock_process.returncode = 1
mock_process.communicate.return_value = (b"", b"Failed to create venv")
Expand All @@ -426,6 +473,21 @@ async def test_fallback_on_volume_initialization_failure(
class TestErrorHandlingIntegration:
"""Test error handling in integrated volume scenarios."""

def setup_method(self):
# Patch subprocess.run globally for all tests in this class
class ContextManagerMock(MagicMock):
def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
pass

self.subprocess_run_patcher = patch("subprocess.run", new=ContextManagerMock())
self.subprocess_run_patcher.start()

def teardown_method(self):
self.subprocess_run_patcher.stop()

@patch("os.makedirs")
@patch("workspace_manager.WorkspaceManager._validate_virtual_environment")
@patch("os.path.exists")
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_remote_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ async def test_execute_function_with_dependencies_orchestration(self):

# Verify all components were called in correct order
mock_sys_deps.assert_called_once_with(["curl"])
mock_py_deps.assert_called_once_with(["requests"])
mock_py_deps.assert_called_once_with(["requests"], True)
mock_execute.assert_called_once_with(request)

@pytest.mark.asyncio
Expand Down Expand Up @@ -211,8 +211,8 @@ def test_component_access_methods(self):
self.executor.dependency_installer, "install_dependencies"
) as mock_install:
mock_install.return_value = Mock(success=True)
self.executor.dependency_installer.install_dependencies(["test"])
mock_install.assert_called_once_with(["test"])
self.executor.dependency_installer.install_dependencies(["test"], True)
mock_install.assert_called_once_with(["test"], True)

# Test workspace manager methods
with patch.object(
Expand Down
44 changes: 44 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading