Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Feature Python Virtual Environment Support

Open C-SELLERS opened this issue 3 years ago • 2 comments

Description

  • Add support for python virtual environments in Lean, allowing overriding of base libraries with py venv directory config value ("python-venv") for local use or job packet var ("sPythonVirtualEnvironment") for cloud.

    • Refactor AddPythonPaths to prepend to path to use for this solution
    • Add static ActivatePythonVirtualEnvironment to prepend the virtual environment libraries to PythonPath, so that they are used.
  • Add "venv" virtual environment to foundation image, acts a shell install that gets mounted on later.

  • Add Jupyter Kernel for this venv to allow switching to this set of libraries

Related Issue

Closes #3189 Closes #4857 Closes #3950 Closes https://github.com/QuantConnect/Lean/issues/6291

Motivation and Context

Requires Documentation Change

How Has This Been Tested?

Regressions and unit tests ✅ Image testing successful using new foundation image with venv config value. ✅ Cloud testing ✅

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] Refactor (non-breaking change which improves implementation)
  • [ ] Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Non-functional change (xml comments/documentation/etc)

Checklist:

  • [x] My code follows the code style of this project.
  • [x] I have read the CONTRIBUTING document.
  • [x] I have added tests to cover my changes.
  • [x] All new and existing tests passed.
  • [x] My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

C-SELLERS avatar Jul 15 '21 02:07 C-SELLERS

We can review pending libraries that were blocked because of backwards compatibility/breaking changes, can see a few at https://github.com/QuantConnect/Lean/pull/5536

Martin-Molinero avatar Jul 15 '21 14:07 Martin-Molinero

Rebased and ready 👍🏽

C-SELLERS avatar Apr 22 '22 01:04 C-SELLERS

Partially replaced by https://github.com/QuantConnect/Lean/pull/6556

Martin-Molinero avatar Aug 17 '22 19:08 Martin-Molinero