-
Notifications
You must be signed in to change notification settings - Fork 2
fix: access built-in system Python instead of using venv for runtime #30
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
Merged
Merged
Changes from 64 commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
09ab3e1
feat: add download acceleration infrastructure
deanq 795c9e5
feat: integrate download acceleration with dependency installer
deanq 046eb58
feat: add workspace acceleration support
deanq 45a65fe
test: add download acceleration test coverage
deanq ce51390
chore: moved test-handler files to src/
deanq 6c04de1
feat: runtime uses aria2 for accelerated parallel downloads
deanq 66eb286
chore: update project structure and dependencies
deanq 1930b4b
chore: updated tetra-rp
deanq 731fd56
build: local-execution-test use make test-handler
deanq e829140
chore: update CLAUDE.md
deanq 104b2da
chore: move these values to constants.py for maintainability
deanq f8aa89a
feat: add system package acceleration with nala
deanq cd56185
refactor: disable Python package download acceleration
deanq d7c996d
test: uv is no longer part of download accelerator
deanq 2ab93e3
feat: implement accelerate_downloads parameter logic in RemoteExecutor
deanq b50a7bf
feat: add pip fallback for Python dependencies when acceleration disa…
deanq 440d00d
feat: enhance HF model caching with hf_transfer/hf_xet strategy
deanq 0320e4d
test: add comprehensive coverage for accelerate_downloads parameter
deanq 034f770
test: update integration tests for new acceleration parameter
deanq 9531079
chore: update dependencies and constants for download acceleration
deanq d75d320
refactor: remove pip installation method from dependency installer
deanq 227b33e
test: update unit tests to expect UV instead of pip
deanq 338a165
test: rename test file from pip to UV naming convention
deanq f88745d
feat: implement parallel execution for accelerated downloads
deanq f22e74d
feat: add async wrapper for HuggingFace model download acceleration
deanq 816fc75
test: update tests for parallel execution and async dependencies
deanq c9ad0d3
test: comprehensive test coverage expansion and cleanup
deanq e31137a
refactor: optimize HF acceleration to use native Hub features
deanq e1db417
chore: memory correction
deanq 76ab9c0
feat: implement HuggingFace download acceleration strategies
deanq c269bcd
feat: implement centralized log streaming system
deanq 04e5b54
chore: these logs are for debug level
deanq f232a9c
Merge branch 'main' into deanq/ae-962-log-streaming
deanq 83b3293
fix: merge conflicts
deanq f9a068c
chore: make update
deanq 692d8fc
chore: these are debug lines
deanq ce2deae
chore: nala logs were too noisy
deanq 90e3b9a
chore: updated tetra-rp
deanq e578007
fix: duplicated lines due to bad merge conflict resolution
deanq 7e7201e
Merge branch 'main' into deanq/ae-962-log-streaming
deanq 8091476
chore: update uv.lock
deanq 8c8f902
fix: test-handler was not exactly testing properly
deanq 47699d2
Merge branch 'deanq/ae-962-log-streaming' into deanq/ae-1165-bug-pyto…
deanq c6ac06d
chore: use GPU build for smoke tests
deanq cc92323
fix: multi-stage build loses crucial built-in system Python
deanq 83787e7
chore: updated to latest submodule state
deanq b99af9d
fix: local/macos testing fails due to lack of apt-get or nala
deanq 736c2eb
test: tests to confirm system Python access
deanq 0785310
refactor: install_dependencies relies on uv and pip provisions
deanq 16f7a1b
chore: better debug logs for dependency_installer
deanq ee6595e
feat: implement universal subprocess utility with automatic logging
deanq 8c259c2
fix: use Docker detection for dependency installation method
deanq fcd51bd
docs: update CLAUDE.md with universal subprocess utility documentation
deanq b980e51
chore: vscode config to point to src
deanq 0bda8a1
chore: no need for a NALA_CHECK_CMD constant
deanq 177c3d2
build: update submodule
deanq d365f2a
chore: logs namespace is now just `tetra`
deanq 8b2cf5f
Merge branch 'deanq/ae-962-log-streaming' into deanq/ae-1165-bug-pyto…
deanq b95451d
docs: System Python Runtime Architecture
deanq 011890a
docs: Centralized Log Streaming System
deanq f11b4dc
chore: update and cleanup
deanq e2fe764
fix: docker uses system's conda python; local uses uv
deanq 39a32de
fix: docker uses uv --system or conda python; local uses uv
deanq 0447519
Merge branch 'deanq/ae-962-log-streaming' into deanq/ae-1165-bug-pyto…
deanq 43888d5
Merge branch 'main' into deanq/ae-1165-bug-pytorchs-not-found
deanq 564192a
build: fix CI to activate venv before `make test-handler`
deanq d26ef79
build: use Docker-based tests for CI
deanq 3f1b07f
fix: conda path wasn't found on CPU image (applies only to Pytorch im…
deanq f4cbf30
Merge branch 'main' into deanq/ae-1165-bug-pytorchs-not-found
deanq f3d4a03
fix: completely remove local-execution-test-gpu
deanq 3902147
build: use --rebase and not --merge
deanq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| dotenv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,19 @@ | ||
| FROM pytorch/pytorch:2.8.0-cuda12.8-cudnn9-runtime AS builder | ||
| FROM pytorch/pytorch:2.8.0-cuda12.8-cudnn9-runtime | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Install build tools and uv (only in builder stage) | ||
| # Install system dependencies and uv | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| git curl build-essential ca-certificates \ | ||
| curl ca-certificates nala \ | ||
| && curl -LsSf https://astral.sh/uv/install.sh | sh \ | ||
| && cp ~/.local/bin/uv /usr/local/bin/uv \ | ||
| && chmod +x /usr/local/bin/uv | ||
| && chmod +x /usr/local/bin/uv \ | ||
| && apt-get clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Copy app code and install dependencies | ||
| COPY README.md src/* pyproject.toml uv.lock ./ | ||
| RUN uv sync | ||
|
|
||
|
|
||
| # --- Final stage: strip build tools, retain only runtime essentials --- | ||
| FROM pytorch/pytorch:2.8.0-cuda12.8-cudnn9-runtime | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Install nala for system package acceleration in runtime stage | ||
| RUN apt-get update && apt-get install -y --no-install-recommends nala \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Copy app and uv binary from builder | ||
| COPY --from=builder /app /app | ||
| COPY --from=builder /usr/local/bin/uv /usr/local/bin/uv | ||
| RUN uv export --format requirements-txt --no-dev --no-hashes > requirements.txt \ | ||
| && uv pip install --system -r requirements.txt | ||
|
|
||
| CMD ["uv", "run", "handler.py"] | ||
| CMD ["python", "handler.py"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,19 @@ | ||
| # Stage 1: Build stage | ||
| FROM python:3.12-slim AS builder | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Install minimal OS deps and uv | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| curl ca-certificates git build-essential \ | ||
| && curl -LsSf https://astral.sh/uv/install.sh | sh \ | ||
| && cp ~/.local/bin/uv /usr/local/bin/uv \ | ||
| && chmod +x /usr/local/bin/uv | ||
|
|
||
| # Copy app files and install deps | ||
| COPY README.md src/* pyproject.toml uv.lock ./ | ||
| RUN uv sync | ||
|
|
||
| # Stage 2: Runtime stage | ||
| FROM python:3.12-slim | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Install runtime dependencies | ||
| # Install system dependencies and uv | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| curl ca-certificates nala \ | ||
| && curl -LsSf https://astral.sh/uv/install.sh | sh \ | ||
| && cp ~/.local/bin/uv /usr/local/bin/uv \ | ||
| && chmod +x /usr/local/bin/uv \ | ||
| && apt-get clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Copy only necessary files from the builder stage | ||
| COPY --from=builder /app /app | ||
| COPY --from=builder /usr/local/bin/uv /usr/local/bin/uv | ||
| # Copy app code and install dependencies | ||
| COPY README.md src/* pyproject.toml uv.lock ./ | ||
| RUN uv export --format requirements-txt --no-dev --no-hashes > requirements.txt \ | ||
| && uv pip install --system -r requirements.txt | ||
|
|
||
| CMD ["uv", "run", "handler.py"] | ||
| CMD ["python", "handler.py"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # Centralized Log Streaming System | ||
|
|
||
| ## Overview | ||
|
|
||
| This design implements a comprehensive log streaming architecture that captures all system logs during remote execution and includes them in the `FunctionResponse.stdout` for complete visibility into dependency installation, workspace setup, and function execution. | ||
|
|
||
| ## Key Components | ||
|
|
||
| ### 1. LogStreamer (`src/log_streamer.py`) | ||
| Thread-safe log capture system that buffers logs and streams them to the response output. | ||
|
|
||
| ```mermaid | ||
| graph TB | ||
| A[Remote Function Execution] --> B[LogStreamer] | ||
| B --> C[Thread-Safe Buffer] | ||
| C --> D[Log Formatting] | ||
| D --> E[FunctionResponse.stdout] | ||
|
|
||
| F[Dependency Installation] --> B | ||
| G[Workspace Setup] --> B | ||
| H[System Operations] --> B | ||
| ``` | ||
|
|
||
| ### 2. Centralized Logging (`src/logger.py`) | ||
| Unified logging configuration with: | ||
| - **Debug Format**: `timestamp | level | name | file:line | message` | ||
| - **Production Format**: `timestamp | level | message` | ||
| - **Namespace**: All logs use `tetra.*` hierarchy | ||
|
|
||
| ### 3. Integration Points | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| participant C as Client | ||
| participant RE as RemoteExecutor | ||
| participant LS as LogStreamer | ||
| participant DI as DependencyInstaller | ||
| participant WM as WorkspaceManager | ||
|
|
||
| C->>RE: Execute Function | ||
| RE->>LS: Start Log Streaming | ||
| RE->>DI: Install Dependencies | ||
| DI-->>LS: Log installation progress | ||
| RE->>WM: Setup Workspace | ||
| WM-->>LS: Log workspace operations | ||
| RE->>RE: Execute Function | ||
| RE-->>LS: Capture execution logs | ||
| LS->>RE: Streamed logs | ||
| RE->>C: FunctionResponse with logs in stdout | ||
| ``` | ||
|
|
||
| ## Technical Changes | ||
|
|
||
| ### Log Namespace Consolidation | ||
| - Changed from `worker_tetra` to `tetra` namespace | ||
| - Consistent logging hierarchy across all components | ||
| - Better alignment with tetra-rp logging standards | ||
|
|
||
| ### Memory Management | ||
| - Configurable buffer size (default: 1000 entries) | ||
| - Automatic buffer rotation prevents memory issues | ||
| - Thread-safe operations with proper locking | ||
|
|
||
| ### Error Resilience | ||
| - Log streaming failures don't break execution | ||
| - Graceful fallback when streaming unavailable | ||
| - Robust error handling in all log operations | ||
|
|
||
| ## Files Modified | ||
|
|
||
| | Component | Purpose | | ||
| |-----------|---------| | ||
| | `src/log_streamer.py` | New centralized log streaming system | | ||
| | `src/logger.py` | New unified logging configuration | | ||
| | `src/remote_executor.py` | Integration with log streaming | | ||
| | `src/dependency_installer.py` | Log capture during installation | | ||
| | `src/test_log_streaming.json` | Test case for log visibility | | ||
|
|
||
| ## Benefits | ||
|
|
||
| 1. **Complete Observability**: All system operations visible in function response | ||
| 2. **Debugging Efficiency**: Detailed logs help diagnose issues quickly | ||
| 3. **Production Ready**: Clean, structured logs with appropriate formatting | ||
| 4. **Thread Safety**: Concurrent operations don't interfere with log capture | ||
| 5. **Memory Efficient**: Bounded buffer prevents memory exhaustion | ||
|
|
||
| ## Testing | ||
|
|
||
| - New test case validates log capture and streaming | ||
| - Integration tests verify logs from dependency installation | ||
| - All existing tests pass with new logging system | ||
| - CI/CD maintains clean output with appropriate log levels |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # System Python Runtime Architecture | ||
|
|
||
| ## Overview | ||
|
|
||
| This design addresses full use of PyTorch installation built into the base Docker image that we use for the runtime. | ||
|
|
||
| ## Architecture Design | ||
|
|
||
| ### System Python Runtime | ||
|
|
||
| ```mermaid | ||
| graph TD | ||
| A[RunPod Request] --> B[src/handler.py] | ||
| B --> C[RemoteExecutor] | ||
| C --> D[Environment Detection] | ||
| D --> E{Docker?} | ||
| E -->|Yes| F[System UV Install] | ||
| E -->|No| G[Local UV Install] | ||
| F --> H[Function Execution] | ||
| G --> H | ||
|
|
||
| I[WorkspaceManager] --> C | ||
| J[DependencyInstaller] --> C | ||
| K[FunctionExecutor] --> C | ||
| ``` | ||
|
|
||
| ## Key Points | ||
|
|
||
|
|
||
| ### Dependency Installation Strategy | ||
|
|
||
| ```mermaid | ||
| flowchart LR | ||
| A[Dependencies Required] --> B{Environment Check} | ||
| B -->|Docker| C[uv pip install --system] | ||
| B -->|Local| D[uv pip install] | ||
| C --> E[Direct System Installation] | ||
| D --> F[Managed Environment Installation] | ||
| ``` | ||
|
|
||
| ### Component Architecture | ||
|
|
||
| ```mermaid | ||
| graph TB | ||
| A[handler.py] --> B[RemoteExecutor] | ||
| B --> C[WorkspaceManager] | ||
| B --> D[DependencyInstaller] | ||
| B --> E[FunctionExecutor] | ||
| B --> F[ClassExecutor] | ||
|
|
||
| G[subprocess_utils] --> D | ||
| G --> E | ||
| G --> F | ||
|
|
||
| H[download_accelerator] --> D | ||
| I[serialization_utils] --> E | ||
| I --> F | ||
| ``` | ||
|
|
||
| ## Benefits | ||
|
|
||
| ### Improved Reliability | ||
| - **Environment detection** handles Docker vs local contexts | ||
| - **Centralized subprocess handling** through `run_logged_subprocess` | ||
| - **Consistent error handling** via `FunctionResponse` pattern | ||
|
|
||
| ### Performance Optimizations | ||
| - **Faster cold starts** without venv initialization | ||
| - **Reduced container size** from simplified builds | ||
| - **Direct package access** eliminates the re-downloading torch and other built-in libraries | ||
|
|
||
| ## Implementation Details | ||
|
|
||
| ### System Installation Strategy | ||
| ```python | ||
| # Docker environment | ||
| command = ["uv", "pip", "install", "--system", "--no-cache"] + packages | ||
|
|
||
| # Local environment | ||
| command = ["uv", "pip", "install", "--python-preference=managed"] + packages | ||
| ``` | ||
|
|
||
| This architecture refactor addresses the core PyTorch installation issues while maintaining API compatibility and improving operational simplicity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.