Diagnose and resolve package version mismatches between local and distributed worker environments.
When running Geneva UDFs on distributed workers, your code is serialized locally and executed on remote workers. If the worker environment differs from your local environment, you may encounter subtle and difficult-to-debug errors.
These issues are notoriously difficult to debug because the error messages often don’t indicate the root cause.
The compare_ray_environments Tool
Geneva provides a diagnostic tool to compare your local environment against Ray workers.If you are encountering a hang or exception you can use the following diagnosis worklflow to resolve the problem.
1
Run the diagnostic tool programatically or via the CLI.
2
Check PACKAGES and ENV VARS output sections for mismatches.
from geneva.manifest.builder import PipManifestBuildermanifest = PipManifestBuilder.create("fix").pip(["numpy==1.26.4"]).build()
6
OPTIONAL: Build custom image for production (if using KubeRay).
Programmatic Usage
from geneva.runners.ray.compare_env import compare_ray_environments# Compare and print (requires Geneva context to be initialize via `with db.context(..)`)result = compare_ray_environments()# Compare environments, filtering environment variables with specified prefixresult = compare_ray_environments(env_prefix="PY")
CLI Usage
# Connect to existing Ray clusterpython -m geneva.runners.ray.compare_env# Start new local Ray clusterpython -m geneva.runners.ray.compare_env --address local# Filter env vars by prefixpython -m geneva.runners.ray.compare_env --env-prefix RAY# Show full JSON snapshotspython -m geneva.runners.ray.compare_env --show-all# Skip sys.path comparisonpython -m geneva.runners.ray.compare_env --no-sys-path
Understanding the Output
The tool outputs several sections to help you identify mismatches.
PYTHON / PLATFORM
Shows Python version and OS information for both environments:
Watch for different Python versions or different OS types (macOS local vs Linux remote).
Architecture Mismatch (macOS to Linux)
If you see different OS types (e.g., Darwin locally vs Linux remotely), compiled extensions may fail with ModuleNotFoundError or segfaults.Solution: Run Geneva from the same OS/architecture as your cluster (typically Linux x86_64). Use a Linux VM, container, or remote development environment.
Environment Variables
Environment variables present in only one environment:
=== ENV VARS: keys only in LOCAL === + CONDA_PREFIX + VIRTUAL_ENV=== ENV VARS: keys only in REMOTE === + RAY_ADDRESS + KUBERNETES_SERVICE_HOST
Missing AWS_* or GOOGLE_APPLICATION_CREDENTIALS can cause storage authentication failures.
Passing Environment Variables to Workers
If critical environment variables are missing on workers, you can pass them via the manifest or cluster configuration. Set the values in the shell before starting the Python program:
Pros: Quick, reusable across sessions, stored with your database.Cons: Slower startup (downloads packages), may not work for complex dependencies.Option 2: Custom Ray Worker ImageFor KubeRay deployments, build a custom worker image:
Pros: Fastest startup, reproducible.Cons: Requires image build/push workflow.Option 3: Conda EnvironmentUse a conda environment on workers via the cluster builder: