Hello, all!

I'm working on writing a support library for use with Python-based algorithms in QuantConnect. Presently, I'm trying to figure out how to set up this library for testing with main.py under ‘lean backtest’, such as before distributing the support library to PyPI.

Using lean CLI, I noticed that the ‘lean backtest’ command provides an --extra-docker-config arg. I tried the following, but this doesn't appear to have mounted the corresponding docker volume:

lean backtest --extra-docker-config '{"volume_driver": "volume", "mounts": [{"Target": "/env", "Source": "env_lean", "Type": "volume", "ReadOnly": false}]}' mytest00

The value for the --extra-docker-config is from the following python code:

import docker
import json
json.dumps({"volume_driver": "volume", "mounts": [docker.types.Mount("/env", "env_lean")]})

 

My idea here was to create a docker volume named ‘env_lean’ then to mount this under ‘/env’ in the backtest environment. This docker volume would then be available for creating a Python virtual environment using the miniconda Python and the set of system libraries installed in the lean backtest image. I was hoping that the ‘lib’ and ‘lib64’ directories from the Python virtual environment at /env could then be used with the following in lean.json:

    "python-additional-paths": [
        "/env/lib",
        "/env/lib64"
    ],

 

My idea was to ensure that anything installed in the virtual environment in /env  would be installed using only the system libraries, along with the python implementation and system pathnames available under the backtest image. I was also hoping to be able to synchronize this with something on the docker host, ideally to simplify the testing procedure. 

I'm just not certain of how to make the ‘env_lean’ docker volume available under ‘lean backtest’. So, i tried using the --extra-docker-config arg for ‘lean backtest’. 

For the usage above, it does not appear to have resulted in any error message. However, it does not seem to have resulted in any docker volume being mounted at ‘/env’, the section of shell scripting above:

lean backtest --extra-docker-config '{"volume_driver": "volume", "mounts": [{"Target": "/env", "Source": "env_lean", "Type": "volume", "ReadOnly": false}]}' mytest00

 

Previously, I'd tried using the --extra-docker-config arg to pass certain settings to the python environment under the lean backtest, e.g `PYTHONOPTIMIZE=1'. This also does not seem to have quite worked out, though it did not result in any error message. 

Could there be any documentation illustrating how to use this ‘--extra-docker-config’ arg for lean backtest? I think it could really simplify the unit testing process for Python libraries with QuantConnect, if it can be used for instance to mount a custom docker volume within the backtest environment