Rich Module Switching¶
Demo Status: Verified
This demo is fully functional and runs automatically via the CLI.
Try it now: Click the play button to run this demo instantly:
This demo showcases OmniPkg’s ability to manage multiple concurrent versions of a pure Python package (like rich) within a single environment, switching between them instantly using the Worker Daemon.
Usage¶
To run this demo directly on your machine (skipping the main interactive menu), use the following command:
What You’ll Learn¶
- Bubble Creation: How OmniPkg installs conflicting versions into isolated “Bubbles” without breaking the main environment.
- Daemon Proxying: How to execute code against a specific version using the
DaemonProxy. - Auto-Healing: How the system detects corruption or missing files and repairs them on the fly.
The Code¶
This script sets up a “Main” environment with rich==13.7.1, then creates isolated bubbles for older versions (13.5.3 and 13.4.2). It then verifies that each context loads the correct code.
from omnipkg.common_utils import safe_print
from omnipkg.isolation.worker_daemon import DaemonClient, DaemonProxy
# 1. Setup Main Environment
omnipkg_core.smart_install(["rich==13.7.1"])
# 2. Create Isolated Bubbles
# These do NOT overwrite 13.7.1; they live in hidden side-dirs
omnipkg_core.smart_install(["rich==13.5.3"])
omnipkg_core.smart_install(["rich==13.4.2"])
# 3. Verify Main Environment (Local Process)
import rich
print(f"Main Process Version: {rich.__version__}")
# Output: 13.7.1
# 4. Verify Bubbles (Daemon Process)
client = DaemonClient()
# Execute code inside the v13.5.3 bubble
proxy = DaemonProxy(client, "rich==13.5.3")
result = proxy.execute("""
import rich
from importlib.metadata import version
print(f"Daemon Version: {version('rich')}")
""")
# Output: 13.5.3
Live Execution Log¶
Below is the actual output from running this demo. Notice how OmniPkg handles the installation, verification, and cleanup automatically.
(evocoder_env) minds3t@aiminingrig:~/omnipkg$ omnipkg demo 1
================================================================================
๐ STEP 1: Environment Setup & Cleanup
================================================================================
๐งน Force removing any existing Rich installation...
โ
Rich uninstalled successfully.
โน๏ธ Rich not found. Installing baseline v13.7.1...
โ Pip validated 'rich==13.7.1' -> 'rich==13.7.1'
โ
Environment prepared
================================================================================
๐ STEP 2: Creating Test Bubbles
================================================================================
๐ซง Creating bubble for rich==13.5.3
โ ๏ธ Detected 1 dependency changes:
โฌ๏ธ rich: v13.7.1 โ v13.5.3 (downgrade)
๐ก๏ธ STABILITY PROTECTION: Processing 1 changed package(s)
๐ซง Creating isolated bubble for rich v13.5.3 (Python 3.11 context)
- ๐ Moving verified build to bubble: .../.omnipkg_versions/rich-13.5.3
โ
Bubble created successfully
๐ซง Creating bubble for rich==13.4.2
โ ๏ธ Detected 1 dependency changes:
โฌ๏ธ rich: v13.7.1 โ v13.4.2 (downgrade)
๐ก๏ธ STABILITY PROTECTION: Processing 1 changed package(s)
- ๐ Moving verified build to bubble: .../.omnipkg_versions/rich-13.4.2
โ
Bubble created successfully
================================================================================
๐ STEP 3: High-Speed Version Verification
================================================================================
--- Testing Main Environment (rich==13.7.1) ---
๐ Verifying v13.7.1 in Main Process...
โ
Verified version 13.7.1
--- Testing Bubble (rich==13.5.3) ---
โก Verifying v13.5.3 via Daemon Worker...
- Version: 13.5.3
- Path: .../site-packages/.omnipkg_versions/rich-13.5.3/rich/__init__.py
- Latency: 1752.59ms
โ
Verified version 13.5.3
--- Testing Bubble (rich==13.4.2) ---
โก Verifying v13.4.2 via Daemon Worker...
- Version: 13.4.2
- Path: .../site-packages/.omnipkg_versions/rich-13.4.2/rich/__init__.py
- Latency: 1723.25ms
โ
Verified version 13.4.2
================================================================================
๐ FINAL TEST RESULTS
================================================================================
main-13.7.1 : โ
PASSED
bubble-13.5.3 : โ
PASSED
bubble-13.4.2 : โ
PASSED
================================================================================
๐ STEP 4: Cleanup
================================================================================
๐งน Removing test bubbles...
๐๏ธ Deleting bubble directory: .../.omnipkg_versions/rich-13.5.3
๐๏ธ Deleting bubble directory: .../.omnipkg_versions/rich-13.4.2
โ
Main environment (v13.7.1) preserved.
How It Works¶
- Stability Protection: When the script requested
rich==13.5.3, OmniPkg saw that13.7.1was already installed. Instead of downgrading (which would break the main environment), it triggered Stability Protection. - Bubble Storage: The older versions were installed into hidden directories (
.omnipkg_versions/). - Daemon Isolation: The main process kept using v13.7.1. The verification requests for older versions were sent to the Worker Daemon, which dynamically loaded the bubble paths into
sys.pathfor that specific execution context.