Reduce and tighten code comments and docstrings repo-wide (#6095)
Trim and tighten code comments and docstrings across the repository. Comment-only: every changed file verified code-identical to main via AST/token comparison.
This commit is contained in:
parent
8292e699e4
commit
187144d4e7
311 changed files with 4121 additions and 8731 deletions
|
|
@ -21,8 +21,7 @@ class TestNoTorchBackendAutoInInstallSh:
|
|||
|
||||
def test_no_torch_backend_auto_outside_fallback(self):
|
||||
lines = INSTALL_SH.read_text().splitlines()
|
||||
# Find the fallback block: starts with the "else" after the
|
||||
# TORCH_INDEX_URL check and ends at the next "fi".
|
||||
# Fallback block: from "GPU detection failed" to the next "fi".
|
||||
fallback_start = None
|
||||
fallback_end = None
|
||||
for i, line in enumerate(lines):
|
||||
|
|
|
|||
|
|
@ -1,19 +1,11 @@
|
|||
"""Comprehensive E2E sandbox tests for PR #4624 (fix/install-mac-intel-no-torch).
|
||||
|
||||
Proves that:
|
||||
- The BEFORE state (top-level torch imports) crashes without torch
|
||||
- The AFTER state (lazy/removed imports) works without torch
|
||||
- Edge cases (broken torch, partial torch) are handled gracefully
|
||||
- Hardware detection falls back to CPU without torch
|
||||
- install.sh flag parsing and platform detection work correctly
|
||||
- install_python_stack.py NO_TORCH filtering is correct
|
||||
- Live server starts and responds without torch (optional, requires studio venv)
|
||||
"""E2E sandbox tests for PR #4624 (fix/install-mac-intel-no-torch): BEFORE
|
||||
(top-level torch) crashes, AFTER (lazy imports) works, broken/partial torch,
|
||||
CPU hardware fallback, install.sh parsing, NO_TORCH filtering, and live server.
|
||||
|
||||
Run:
|
||||
# Lightweight tests (Groups 1-6, ~26 tests):
|
||||
# Lightweight (Groups 1-6):
|
||||
python -m pytest tests/python/test_e2e_no_torch_sandbox.py -v -k "not server"
|
||||
|
||||
# Server tests (Group 7, 4 tests, requires studio venv):
|
||||
# Server (Group 7, requires studio venv):
|
||||
python -m pytest tests/python/test_e2e_no_torch_sandbox.py -v -m server
|
||||
"""
|
||||
|
||||
|
|
@ -212,12 +204,8 @@ def no_torch_venv(request, tmp_path_factory):
|
|||
|
||||
|
||||
class TestBeforeAfterImportChain:
|
||||
"""Prove the bug exists in BEFORE state and is fixed in AFTER state.
|
||||
|
||||
BEFORE = PR branch files with top-level torch import synthetically prepended
|
||||
(simulates the main branch).
|
||||
AFTER = PR branch files as-is (lazy imports / torch import removed).
|
||||
"""
|
||||
"""BEFORE (PR files with a synthetic top-level torch import, simulating
|
||||
main) crashes; AFTER (PR files as-is, lazy imports) works."""
|
||||
|
||||
# -- BEFORE: crashes --
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ import pytest
|
|||
|
||||
|
||||
def _stub_module(name: str) -> types.ModuleType:
|
||||
# __spec__ must be set so importlib.util.find_spec(name) does not raise
|
||||
# ValueError if a downstream test imports the real package.
|
||||
# __spec__ set so find_spec(name) doesn't raise if a later test imports
|
||||
# the real package.
|
||||
mod = types.ModuleType(name)
|
||||
mod.__spec__ = importlib.util.spec_from_loader(name, loader = None)
|
||||
return mod
|
||||
|
|
|
|||
|
|
@ -10,12 +10,11 @@ from unittest import mock
|
|||
|
||||
import pytest
|
||||
|
||||
# Add the studio directory so we can import install_python_stack
|
||||
# Add the studio directory so we can import install_python_stack.
|
||||
STUDIO_DIR = Path(__file__).resolve().parents[2] / "studio"
|
||||
sys.path.insert(0, str(STUDIO_DIR))
|
||||
|
||||
# _build_uv_cmd lives at module level; import after path setup.
|
||||
# We need to mock parts of the module that do work at import time.
|
||||
# Import after path setup.
|
||||
import install_python_stack as ips
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ def no_torch_venv(request, tmp_path_factory):
|
|||
if venv_python is None:
|
||||
pytest.skip(f"Could not create Python {py_version} venv")
|
||||
|
||||
# Verify torch is NOT importable
|
||||
check = subprocess.run(
|
||||
[str(venv_python), "-c", "import torch"],
|
||||
capture_output = True,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
"""
|
||||
Tests for two install fixes:
|
||||
1. tokenizers added to no-torch-runtime.txt (prevents AutoConfig crash)
|
||||
2. TORCH_CONSTRAINT variable in install.sh (arm64 macOS + py313+ -> torch>=2.6)
|
||||
"""Tests for two install fixes:
|
||||
1. tokenizers in no-torch-runtime.txt (prevents AutoConfig crash)
|
||||
2. TORCH_CONSTRAINT in install.sh (arm64 macOS + py313+ -> torch>=2.6)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue