Skip to content

Conversation

@joaomariolago
Copy link
Collaborator

@joaomariolago joaomariolago commented Dec 5, 2025

  • Split main python runtime in 2 separate environments to allow for partial service libraries upgrade.

Summary by Sourcery

Introduce a second Python runtime environment for selected services and wire it into the core image build and startup configuration.

New Features:

  • Add a dedicated secondary Python virtual environment for services requiring newer dependencies while keeping the existing primary environment intact.

Bug Fixes:

  • Add missing python-multipart dependency to the versionchooser service to satisfy its runtime requirements.

Enhancements:

  • Update the Python libraries installation script to support installing into multiple virtual environments or system Python based on environment variables.
  • Adjust core Docker image to build, sync, and export both primary and secondary Python virtual environments and expose them via environment variables and PATH configuration.
  • Split core Python dependencies so selected services (kraken, versionchooser, commonwealth consumers) are moved into the new secondary environment.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 5, 2025

Reviewer's Guide

Splits the core Python runtime into two separate virtual environments so selected services (kraken, versionchooser, commonwealth) can run with newer dependencies, wiring the new venv through build, install, and runtime scripts.

Sequence diagram for installing python tools into multiple environments

sequenceDiagram
    participant Docker_build as docker_install_services_and_libs
    participant install_script as install_python_libs_sh
    participant determine_envs as determine_target_envs
    participant install_env as install_for_env
    participant venv1 as venv_primary_/home/pi/.venv
    participant venv2 as venv_secondary_/home/pi/.venv2

    Docker_build->>install_script: run with BLUEOS_PYTHON_ENVS="/home/pi/.venv /home/pi/.venv2"
    activate install_script
    install_script->>determine_envs: determine_target_envs
    activate determine_envs
    determine_envs-->>install_script: TARGET_ENVS=(/home/pi/.venv /home/pi/.venv2)
    deactivate determine_envs

    loop for each env_path in TARGET_ENVS
        install_script->>install_env: install_for_env(env_path)
        activate install_env
        alt env_path is non_empty
            install_env->>venv1: when env_path=/home/pi/.venv set VIRTUAL_ENV
            install_env->>venv2: when env_path=/home/pi/.venv2 set VIRTUAL_ENV
        else env_path is empty
            install_env->>install_env: unset VIRTUAL_ENV (system python)
        end
        install_env->>install_env: parallel run /home/pi/tools/*/setup-python-libs.sh
        install_env-->>install_script: installation complete for env_path
        deactivate install_env
    end

    install_script-->>Docker_build: python tools installed in all target envs
    deactivate install_script
Loading

File-Level Changes

Change Details Files
Make install-python-libs.sh target one or more Python environments instead of a single implicit VIRTUAL_ENV.
  • Add determine_target_envs to derive target environments from BLUEOS_PYTHON_ENVS, current VIRTUAL_ENV, or system Python as fallback.
  • Add install_for_env helper that sets/unsets VIRTUAL_ENV per target env and runs setup-python-libs.sh for all tools.
  • Replace single parallel invocation with a loop over TARGET_ENVS calling install_for_env for each.
core/tools/install-python-libs.sh
Create and wire a second Python virtualenv during image build and expose both venvs at runtime.
  • Copy python-venv2 project files into the build context and ensure it has its own .python-version.
  • Create /home/pi/.venv2 using uv, activate it, and run uv sync for the secondary environment.
  • Run install-python-libs.sh once with BLUEOS_PYTHON_ENVS set to both /home/pi/.venv and /home/pi/.venv2 so tools are installed into both.
  • Copy both .venv and .venv2 into the final image and export BLUEOS_VENV_PRIMARY/SECONDARY plus an updated PATH including both venv bin dirs.
core/Dockerfile
Split service dependencies so some services are moved to the new venv2 workspace with newer dependencies.
  • Remove kraken and versionchooser from the main core runtime dependencies to decouple them from the primary venv.
  • Introduce a new python-venv2 project with its own pyproject.toml and uv.lock, depending on commonwealth, kraken, and versionchooser via workspace sources.
  • Define a dedicated workspace for python-venv2 referencing commonwealth and the kraken/versionchooser services.
core/pyproject.toml
core/python-venv2/pyproject.toml
core/python-venv2/uv.lock
Adjust versionchooser service dependencies for compatibility with the new environment.
  • Add python-multipart as a locked dependency to versionchooser to support multipart handling under the updated stack.
core/services/versionchooser/pyproject.toml
Propagate and/or adjust startup/runtime configuration to account for the new dual-venv layout.
  • Update or add start-blueos-core and uv.lock to align with the new multi-env setup (details to be inspected in the diff).
core/start-blueos-core
core/uv.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant