Skip to content

Commit d5b0642

Browse files
committed
fix: resolve translation shadowing, standardize safe_print, and refactor tests
- Replaced tuple unpacking dummy variables (`_`) with `unused` globally to prevent shadowing the `_` gettext translation function. - Swapped standard `print()` calls for `safe_print()` in the core, dispatcher, and tests to prevent UnicodeEncodeErrors on strict terminals and Windows. - Refactored `test_verify_bubble_deps.py` into an OOP `KBSyncVerifier` class with bi-directional (DB ↔ Disk) symmetry checks. - Relocated FFI and diagnostic tests (`diag_uv_ffi.py`, `test_uv_ffi_contracts.py`) to the root `tests/` directory and fixed linter-induced AttributeErrors. - Added the "Daemon IPC Showcase" (Option 11) to the interactive `8pkg demo` CLI menu. - Enhanced the daemon worker pre-warm logic to accurately detect and strip framework (torch/tensorflow) site-packages from the bubble path. - Registered the `integration` pytest marker in `pytest.ini`. New files: • tests/diag_uv_ffi.py (425 lines) • tests/test_uv_ffi_contracts.py (793 lines) Modified: • build_hooks.py (+1/-1 lines) • src/omnipkg/cli.py (+4/-2 lines) • src/omnipkg/core.py (+2/-2 lines) • src/omnipkg/dispatcher.py (+34/-34 lines) • src/omnipkg/installation/installers.py (+4/-4 lines) • src/omnipkg/installation/smart_install.py (+3/-3 lines) • src/omnipkg/integration/reproducible.py (+44/-40 lines) • src/omnipkg/isolation/fs_lock_queue.py (+1/-1 lines) • src/omnipkg/isolation/fs_watcher.py (+7/-7 lines) • src/omnipkg/isolation/resource_monitor.py (+7/-7 lines) • src/omnipkg/isolation/worker_daemon.py (+17/-4 lines) • src/omnipkg/package_meta_builder.py (+10/-10 lines) • src/omnipkg/windows_bootstrap/launcher.py (+1/-1 lines) • setup.py (+4/-4 lines) • pytest.ini (+1/-0 lines) • src/omnipkg/tests/omnipkg_ipc_showcase.py (+22/-17 lines) • src/omnipkg/tests/test_concurrent_install.py (+2/-2 lines) • src/omnipkg/tests/test_daemon_tags.py (+22/-18 lines) • src/omnipkg/tests/test_loader_stress_test.py (+1/-1 lines) • src/omnipkg/tests/test_old_rich.py (+1/-1 lines) • src/omnipkg/tests/test_rich_switching.py (+3/-3 lines) • src/omnipkg/tests/test_tensorflow_switching.py (+1/-1 lines) • tests/test_dispatcher_contracts.py (+1/-1 lines) • tests/test_ffi_verify.py (+13/-9 lines) • tests/test_flask_port_finder.py (+9/-9 lines) • tests/test_omnipkg_contracts.py (+11/-11 lines) • tests/test_verify_bubble_deps.py (+117/-179 lines) [gitship-generated]
1 parent 8ef5cf2 commit d5b0642

30 files changed

Lines changed: 357 additions & 519 deletions

build_hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _collect_host_info() -> dict:
101101
fields = {}
102102
for line in Path(osr).read_text().splitlines():
103103
if "=" in line and not line.startswith("#"):
104-
k, _, v = line.partition("=")
104+
k, unused, v = line.partition("=")
105105
fields[k.strip()] = v.strip().strip('"')
106106
info["linux_distro_id"] = fields.get("ID", "unknown").lower()
107107
info["linux_distro_version"] = fields.get("VERSION_ID", "unknown")

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
addopts = -ra --color=yes --continue-on-collection-errors
33
markers =
44
windows_compat: Tests that verify Windows-specific compatibility
5+
integration: marks tests as integration tests (deselect with '-m "not integration"')

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def _skip(reason, **kw): return {"status": "skipped", "reason": reason, **kw}
160160

161161
if replaced:
162162
binary_out.unlink(missing_ok=True)
163-
print(f" [dispatcher] ✅ Fast C dispatcher installed over: {replaced}")
163+
safe_print(f" [dispatcher] ✅ Fast C dispatcher installed over: {replaced}")
164164
installed_paths = []
165165
for name in replaced:
166166
target = Path(install_dir) / (name + _exe)
@@ -276,7 +276,7 @@ def _clean_env():
276276
import importlib.util, site
277277
sp = site.getsitepackages()
278278
sp0 = sp[0] if sp else "unknown"
279-
print(" [uv-ffi] ✅ PyO3 FFI extension built and installed")
279+
safe_print(" [uv-ffi] ✅ PyO3 FFI extension built and installed")
280280
print(f" [uv-ffi] site-packages : {sp0}")
281281
# Find the actual .so path for the manifest
282282
import glob as _uvg
@@ -375,7 +375,7 @@ def _collect_host_info() -> dict:
375375
fields = {}
376376
for line in Path(osr).read_text().splitlines():
377377
if "=" in line and not line.startswith("#"):
378-
k, _, v = line.partition("=")
378+
k, unused, v = line.partition("=")
379379
fields[k.strip()] = v.strip().strip('"')
380380
info["linux_distro_id"] = fields.get("ID", "unknown").lower()
381381
info["linux_distro_version"] = fields.get("VERSION_ID", "unknown")
@@ -672,7 +672,7 @@ def build_extension(self, ext):
672672
print(f" [atomic] output (.so) : {Path(so_path).resolve()}")
673673
try:
674674
super().build_extension(ext)
675-
print(f" [atomic] ✅ built to : {Path(so_path).resolve()}")
675+
safe_print(f" [atomic] ✅ built to : {Path(so_path).resolve()}")
676676
self._atomic_result = {"status": "ok", "so_path": str(Path(so_path).resolve())}
677677
except Exception as e:
678678
print(f"\n{'!'*60}")

src/omnipkg/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,6 +2470,7 @@ def main():
24702470
safe_print(_("8. 🌠 Quantum Multiverse Warp (concurrent installs) — needs 3.11"))
24712471
safe_print(_("9. Flask Port Finder (auto-healing with Flask)"))
24722472
safe_print(_("10. CLI Healing Test (omnipkg run shell commands)"))
2473+
safe_print(_("11. Daemon IPC Showcase"))
24732474
safe_print(_("\nFor chaos/stress tests: 8pkg stress-test"))
24742475

24752476
from omnipkg.common_utils import safe_input
@@ -2478,7 +2479,7 @@ def main():
24782479

24792480
if args.demo_id is not None:
24802481
if not (1 <= args.demo_id <= 10):
2481-
safe_print(_("❌ Invalid demo ID {}. Choose 1-10.").format(args.demo_id))
2482+
safe_print(_("❌ Invalid demo ID {}. Choose 1-11.").format(args.demo_id))
24822483
return 1
24832484
response = str(args.demo_id)
24842485
safe_print(_('🎯 Running demo {}...').format(response))
@@ -2487,7 +2488,7 @@ def main():
24872488
safe_print(_('🤖 Non-interactive: auto-selecting demo {}').format(response))
24882489
else:
24892490
response = safe_input(
2490-
_("Enter your choice (1-10): "),
2491+
_("Enter your choice (1-11): "),
24912492
default="1",
24922493
auto_value=os.environ.get("OMNIPKG_DEMO_ID", "1"),
24932494
)
@@ -2503,6 +2504,7 @@ def main():
25032504
"8": ("Quantum Multiverse Warp", TESTS_DIR / "test_concurrent_install.py", "3.11"),
25042505
"9": ("Flask Port Finder", TESTS_DIR / "test_flask_port_finder.py", None),
25052506
"10": ("CLI Healing Test", TESTS_DIR / "test_cli_healing.py", None),
2507+
"11": ("Daemon IPC Showcase", TESTS_DIR / "omnipkg_ipc_showcase.py", None),
25062508
}
25072509

25082510
if response not in demo_map:

src/omnipkg/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3295,7 +3295,7 @@ def _get_our_config_path(self) -> Path:
32953295
_gc_exe = Path(_gc.get("python_executable", "")).resolve()
32963296
if _gc_exe != exe_path:
32973297
if debug_mode:
3298-
print(f"[DEBUG-CONFIG] ⚠️ Global config points to {_gc_exe} but we are {exe_path} — ignoring stale global config", file=sys.stderr)
3298+
safe_print(f"[DEBUG-CONFIG] ⚠️ Global config points to {_gc_exe} but we are {exe_path} — ignoring stale global config", file=sys.stderr)
32993299
self._write_interpreter_config(exe_path, f"{sys.version_info.major}.{sys.version_info.minor}")
33003300
return per_python_config
33013301
except Exception:
@@ -6639,7 +6639,7 @@ def _self_heal_omnipkg_installation(self):
66396639
_stamped_ver = _stamp.get("version")
66406640
if _stamped_ver:
66416641
# Get running version fast (toml first, then metadata)
6642-
_running_ver, _ = self._get_master_version_ultra_fast()
6642+
_running_ver, unused = self._get_master_version_ultra_fast()
66436643
if _running_ver == _stamped_ver:
66446644
# Already stamped at this exact version — nothing to do.
66456645
return

0 commit comments

Comments
 (0)