Skip to content

Handle shared installer venvs by Python/platform compatibility - #263

Merged
arjunsuresh merged 29 commits into
devfrom
copilot/mlcflow-262-reuse-existing-venv
Jul 19, 2026
Merged

Handle shared installer venvs by Python/platform compatibility#263
arjunsuresh merged 29 commits into
devfrom
copilot/mlcflow-262-reuse-existing-venv

Conversation

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

The Unix installer currently reuses any existing venv at the requested path, which breaks when $HOME is shared across architectures or Python minor versions. This updates reuse logic to validate venv compatibility first and fall back to a versioned sibling path when needed.

  • Compatibility check

    • Compare the current interpreter and the existing venv by architecture|major.minor.
    • Reuse only when both match.
  • Deterministic fallback naming

    • When the requested venv path exists but is incompatible, use a suffixed sibling path:
      • mlcflow_x86_64_py3.11
      • mlcflow_aarch64_py3.12
    • The suffix is derived from normalized architecture and Python major/minor version.
  • Installer behavior

    • Keep the originally requested directory untouched when incompatible.
    • Create or reuse the compatible suffixed directory instead.
    • Add helper functions to centralize suffix generation and compatibility detection.
  • Coverage and docs

    • Add focused tests for:
      • fresh venv creation
      • compatible venv reuse
      • incompatible existing directory fallback
      • stubbed end-to-end installer main flow
    • Update install docs to describe the suffixed venv behavior.
  • Example

    # requested path already exists but was created on another platform/Python
    --venv-dir ~/mlcflow
    
    # installer resolves to a compatible sibling such as
    ~/mlcflow_x86_64_py3.12

✅ PR Checklist

  • Target branch is dev

📌 Note: PRs must be raised against dev. Do not commit directly to main.

✅ Testing & CI

  • Have tested the changes in my local environment, else have properly conveyed in the PR description
  • The change includes a GitHub Action to test the script(if it is possible to be added).
  • No existing GitHub Actions are failing because of this change.

📚 Documentation

  • README or help docs are updated for new features or changes.
  • CLI help messages are meaningful and complete.

📁 File Hygiene & Output Handling

  • No unintended files (e.g., logs, cache, temp files, pycache, output folders) are committed.

🛡️ Safety & Security

  • No secrets or credentials are committed.
  • Paths, shell commands, and environment handling are safe and portable.

🙌 Contribution Hygiene

  • PR title and description are concise and clearly state the purpose of the change.
  • All reviewer feedback has been addressed.

@arjunsuresh arjunsuresh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should call the test in a suitable github action test

@arjunsuresh
arjunsuresh changed the base branch from main to dev July 18, 2026 20:06
@arjunsuresh

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Copilot AI changed the title [WIP] Fix venv detection for platform compatibility Handle shared installer venvs by Python/platform compatibility Jul 18, 2026
Copilot AI requested a review from arjunsuresh July 18, 2026 20:10
@github-actions

Copy link
Copy Markdown

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@github-actions

Copy link
Copy Markdown

🤖 AI PR Review Summary\n\nRefactor the Unix installer script to improve virtual environment (venv) compatibility handling by introducing platform and Python version suffixes to venv directories. This avoids overwriting incompatible venvs by creating or reusing platform- and Python-specific sibling directories. The PR centralizes architecture normalization and Python version extraction, enhances venv compatibility checks, and updates the GitHub workflow and documentation accordingly. Risks include potential edge cases in architecture normalization and compatibility detection, but extensive test coverage mitigates these. The design improves robustness and user experience when managing multiple Python environments.

@github-actions

Copy link
Copy Markdown

🤖 AI PR Review Summary\n\nRefactor the Unix installer script to improve virtual environment (venv) compatibility handling by introducing platform and Python version suffixes for venv directories. This avoids conflicts when multiple Python versions or architectures are used. The changes include defining helper functions for architecture normalization, Python version extraction, and compatibility checks. The installer now resolves and uses a compatible venv directory, removing stale incompatible ones. The workflow and documentation are updated accordingly. Risks include potential edge cases in architecture normalization and compatibility checks, but tests are added to validate behavior.

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved in 39afc32 by merging dev into this branch and fixing the installer conflict; follow-up validation fixes are in b158902.

@arjunsuresh

Copy link
Copy Markdown
Contributor

@copilot please address the above review comment

Copilot AI commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please address the above review comment

Addressed in 3a97c5c.

@github-actions

Copy link
Copy Markdown

🤖 AI PR Review Summary\n\nThis PR improves the mlcflow Unix installer and related CI workflows by enhancing Python virtual environment compatibility handling based on platform and Python minor version. It introduces functions to normalize architecture names, generate compatibility signatures, and resolve or fallback virtual environment directories accordingly. The installer script now uses a configurable Python command variable and better logs compatibility decisions. The repo_action.py adds validation for extra_git_args to prevent injection of newlines or carriage returns and ensures type correctness. Minor fixes in GitHub workflows improve code clarity and robustness. Risks include potential edge cases in architecture normalization and compatibility checks, and the complexity of venv resolution logic, but overall changes improve maintainability and user experience.

@github-actions

Copy link
Copy Markdown

🤖 AI PR Review Summary\n\nThis PR improves the mlcflow Unix installer and related CI workflows by enhancing Python virtual environment compatibility checks and management. It introduces architecture normalization, Python version detection helpers, and a more robust mechanism to select or create compatible virtual environments based on platform and Python minor version. The PR also refactors subprocess error handling and adds validation for extra git arguments in repo actions. Documentation is updated to explain the new venv directory suffix behavior. Risks include potential edge cases in architecture normalization and compatibility detection, and the need to ensure backward compatibility with existing venvs. Overall, the design improves maintainability and user experience by avoiding venv conflicts across Python versions and platforms.

@arjunsuresh

Copy link
Copy Markdown
Contributor

@copilot the format of the AI PR review comments are broken. Please fix it

Copilot AI commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the format of the AI PR review comments are broken. Please fix it

Addressed in bdf2d80.

@github-actions

Copy link
Copy Markdown

🤖 AI PR Review Summary\n\nThis PR improves the AI PR review GitHub workflow by adding robust validation and base64 encoding/decoding for inline comments to handle special characters safely. It also refactors the Unix installer script to better handle Python virtual environments by detecting platform and Python minor version compatibility, creating or reusing suffixed venv directories accordingly. The installer now uses a configurable Python command variable and normalizes architecture names. Documentation is updated to explain the new venv suffix behavior. Risks include potential shell compatibility issues with the new base64 decoding approach and subtle bugs in venv compatibility detection, but overall the changes improve reliability and maintainability.

@arjunsuresh
arjunsuresh marked this pull request as ready for review July 19, 2026 10:50
@arjunsuresh
arjunsuresh requested a review from a team as a code owner July 19, 2026 10:50
@arjunsuresh
arjunsuresh merged commit ed5706e into dev Jul 19, 2026
82 checks passed
@arjunsuresh
arjunsuresh deleted the copilot/mlcflow-262-reuse-existing-venv branch July 19, 2026 10:50
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reusing existing venv should be done in a proper way

3 participants