QuantConnect / lean-cli

CLI for running the LEAN engine locally and in the cloud
https://www.lean.io/cli
Apache License 2.0
194 stars 99 forks source link

400 client error from Docker running lean local backtest #4

Closed chadwickade closed 3 years ago

chadwickade commented 3 years ago

Below is the verbose output I am getting when I try to run the lean local backtest command.
Can you let me know what I'm doing wrong? Thanks.

(base) chadwick@chadwick-Satellite-S70-B:~/Desktop/QuantConnect_Lean$ lean backtest --verbose "My Project" Traceback (most recent call last): File "/home/chadwick/.local/lib/python3.8/site-packages/docker/api/client.py", line 268, in _raise_for_status response.raise_for_status() File "/home/chadwick/.local/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http+docker://localhost/v1.40/containers/create

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/chadwick/anaconda3/lib/python3.8/site-packages/lean/main.py", line 30, in main lean.main(standalone_mode=False) File "/home/chadwick/anaconda3/lib/python3.8/site-packages/click/core.py", line 782, in main rv = self.invoke(ctx) File "/home/chadwick/anaconda3/lib/python3.8/site-packages/click/core.py", line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/chadwick/anaconda3/lib/python3.8/site-packages/lean/click.py", line 68, in invoke result = super().invoke(ctx) File "/home/chadwick/anaconda3/lib/python3.8/site-packages/click/core.py", line 1066, in invoke return ctx.invoke(self.callback, *ctx.params) File "/home/chadwick/anaconda3/lib/python3.8/site-packages/click/core.py", line 610, in invoke return callback(args, kwargs) File "/home/chadwick/anaconda3/lib/python3.8/site-packages/lean/commands/backtest.py", line 79, in backtest lean_runner.run_lean("backtesting", algorithm_file, output, version, debugging_method) File "/home/chadwick/anaconda3/lib/python3.8/site-packages/lean/components/docker/lean_runner.py", line 90, in run_lean success = self._docker_manager.run_image(ENGINE_IMAGE, version, run_options) File "/home/chadwick/anaconda3/lib/python3.8/site-packages/lean/components/docker/docker_manager.py", line 77, in run_image container = docker_client.containers.run(f"{image}:{tag}", None, kwargs) File "/home/chadwick/.local/lib/python3.8/site-packages/docker/models/containers.py", line 811, in run container = self.create(image=image, command=command, File "/home/chadwick/.local/lib/python3.8/site-packages/docker/models/containers.py", line 870, in create resp = self.client.api.create_container(create_kwargs) File "/home/chadwick/.local/lib/python3.8/site-packages/docker/api/container.py", line 430, in create_container return self.create_container_from_config(config, name) File "/home/chadwick/.local/lib/python3.8/site-packages/docker/api/container.py", line 441, in create_container_from_config return self._result(res, True) File "/home/chadwick/.local/lib/python3.8/site-packages/docker/api/client.py", line 274, in _result self._raise_for_status(response) File "/home/chadwick/.local/lib/python3.8/site-packages/docker/api/client.py", line 270, in _raise_for_status raise create_api_error_from_http_exception(e) File "/home/chadwick/.local/lib/python3.8/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception raise cls(e, response=response, explanation=explanation) docker.errors.APIError: 400 Client Error for http+docker://localhost/v1.40/containers/create: Bad Request ("invalid mount config for type "bind": bind source path does not exist: /tmp/tmpp_7xwf_a/config.json") Error: 400 Client Error for http+docker://localhost/v1.40/containers/create: Bad Request ("invalid mount config for type "bind": bind source path does not exist: /tmp/tmpp_7xwf_a/config.json")

jmerle commented 3 years ago

Hmm, that's an odd one. What operating system are you using and what does running ls /tmp/tmpp_7xwf_a show?

chadwickade commented 3 years ago

I am running ubuntu and the /tmp/tmpp_7xwf_a is not there. Below is the output I got from the running the ls and lsb_release commands in the terminal. Thanks for your help.

(base) chadwick@chadwick-Satellite-S70-B:~$ ls /tmp/tmpp_7xwf_a ls: cannot access '/tmp/tmpp_7xwf_a': No such file or directory (base) chadwick@chadwick-Satellite-S70-B:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.10 Release: 20.10 Codename: groovy (base) chadwick@chadwick-Satellite-S70-B:~$ ls /tmp config-err-Vhq5lf snap.docker snap.firefox snap.snap-store ssh-CDQ88fKIac3y systemd-private-18d1e4108e8a4ab29de7891a31fc54dd-colord.service-BBcefj systemd-private-18d1e4108e8a4ab29de7891a31fc54dd-fwupd.service-1xWKWg systemd-private-18d1e4108e8a4ab29de7891a31fc54dd-ModemManager.service-9xfMEh systemd-private-18d1e4108e8a4ab29de7891a31fc54dd-switcheroo-control.service-7j7tJf systemd-private-18d1e4108e8a4ab29de7891a31fc54dd-systemd-logind.service-t3XgXf systemd-private-18d1e4108e8a4ab29de7891a31fc54dd-systemd-resolved.service-5Yre7g systemd-private-18d1e4108e8a4ab29de7891a31fc54dd-systemd-timesyncd.service-6dv7Eh systemd-private-18d1e4108e8a4ab29de7891a31fc54dd-upower.service-Kekkmj tracker-extract-files.1000 tracker-extract-files.126 (base) chadwick@chadwick-Satellite-S70-B:~$

jmerle commented 3 years ago

Thanks for that information. You seem to be using the Snap version of Docker, which appears to have the limitation that it cannot access any files outside $HOME. The solution in this case is to uninstall the Snap version of Docker (sudo snap remove docker) and to re-install Docker via the official installation instructions for Ubuntu.

The reason we use /tmp is that everything in there is automatically deleted on reboot. This is useful to the CLI because occasionally we leave behind some files which are owned by root and can therefore not be deleted by the CLI itself.

chadwickade commented 3 years ago

Yes, that worked. Thanks!!!