From 8e1a5f5e99f493d30bd487717b4ce4eec0930e8f Mon Sep 17 00:00:00 2001 From: Linlang Date: Thu, 27 Jun 2024 10:03:55 +0800 Subject: [PATCH 1/7] add dockerfile --- .dockerignore | 8 ++++++++ Dockerfile | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..bc00efde3a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +__pycache__ +*.pyc +*.pyo +*.pyd +.Python +.env +.git + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..019d045c86 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM continuumio/miniconda3:latest + +WORKDIR /qlib + +COPY . . + +RUN apt-get update && \ + apt-get install -y build-essential + +RUN conda create --name qlib_source python=3.8 +RUN echo "conda activate qlib_source" >> ~/.bashrc +ENV PATH /opt/conda/envs/qlib_source/bin:$PATH + +RUN python -m pip install --upgrade pip + +RUN python -m pip install numpy==1.23.5 +RUN python -m pip install pandas==1.5.3 +RUN python -m pip install importlib-metadata==5.2.0 +RUN python -m pip install "cloudpickle<3" +RUN python -m pip install scikit-learn==1.3.2 + +RUN pip install cython packaging tables matplotlib statsmodels + +RUN python setup.py install + +EXPOSE 10050 From 459af514d9263204e3e648ed25b2a4b89fb90670 Mon Sep 17 00:00:00 2001 From: Linlang Date: Thu, 27 Jun 2024 10:21:37 +0800 Subject: [PATCH 2/7] add execute script --- build_docker_image.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 build_docker_image.sh diff --git a/build_docker_image.sh b/build_docker_image.sh new file mode 100644 index 0000000000..89429fe646 --- /dev/null +++ b/build_docker_image.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Build the Docker image +sudo docker build -t qlib_image -f ./Dockerfile . + +# Log in to Docker Hub +sudo docker login + +# Tag the Docker image +sudo docker tag qlib_image linlanglv/qlib_image:stable + +# Push the Docker image to Docker Hub +sudo docker push linlanglv/qlib_image:stable From 0214b3004c85e5447749ffae1f11660628366d4b Mon Sep 17 00:00:00 2001 From: Linlang Date: Thu, 27 Jun 2024 12:34:24 +0800 Subject: [PATCH 3/7] add docs --- Dockerfile | 4 ++-- README.md | 19 +++++++++++++++++++ build_docker_image.sh | 5 +++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 019d045c86..4ed2c048c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,8 +19,8 @@ RUN python -m pip install importlib-metadata==5.2.0 RUN python -m pip install "cloudpickle<3" RUN python -m pip install scikit-learn==1.3.2 -RUN pip install cython packaging tables matplotlib statsmodels +RUN python -m pip install cython packaging tables matplotlib statsmodels -RUN python setup.py install +RUN python -m pip install pyqlib EXPOSE 10050 diff --git a/README.md b/README.md index 773eeaf39b..c827cba7cf 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,25 @@ We recommend users to prepare their own data if they have a high-quality dataset ``` --> +## Build docker images +Running `build_docker_image.sh` is the right choice when you want to create a docker image for qlib. Of course, before running it, please open this file and make some necessary changes according to your docker hub account. + ```bash + #!/bin/bash + + # Build the Docker image + sudo docker build -t qlib_image -f ./Dockerfile . + + # Log in to Docker Hub + # If you are a new docker hub user, please verify your email address before proceeding with this step. + sudo docker login + + # Tag the Docker image + sudo docker tag qlib_image /qlib_image:stable + + # Push the Docker image to Docker Hub + sudo docker push /qlib_image:stable + ``` + ## Auto Quant Research Workflow Qlib provides a tool named `qrun` to run the whole workflow automatically (including building dataset, training models, backtest and evaluation). You can start an auto quant research workflow and have a graphical reports analysis according to the following steps: diff --git a/build_docker_image.sh b/build_docker_image.sh index 89429fe646..ecca14f1cc 100644 --- a/build_docker_image.sh +++ b/build_docker_image.sh @@ -4,10 +4,11 @@ sudo docker build -t qlib_image -f ./Dockerfile . # Log in to Docker Hub +# If you are a new docker hub user, please verify your email address before proceeding with this step. sudo docker login # Tag the Docker image -sudo docker tag qlib_image linlanglv/qlib_image:stable +sudo docker tag qlib_image /qlib_image:stable # Push the Docker image to Docker Hub -sudo docker push linlanglv/qlib_image:stable +sudo docker push /qlib_image:stable From 883815979c34eddf61439672dc80b585f6fa62fe Mon Sep 17 00:00:00 2001 From: Linlang Date: Thu, 27 Jun 2024 20:26:33 +0800 Subject: [PATCH 4/7] optimize docs --- README.md | 18 +----------------- docs/start/installation.rst | 19 +++++++++++++++++++ setup.py | 4 ++++ 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c827cba7cf..7376d05325 100644 --- a/README.md +++ b/README.md @@ -273,23 +273,7 @@ We recommend users to prepare their own data if they have a high-quality dataset --> ## Build docker images -Running `build_docker_image.sh` is the right choice when you want to create a docker image for qlib. Of course, before running it, please open this file and make some necessary changes according to your docker hub account. - ```bash - #!/bin/bash - - # Build the Docker image - sudo docker build -t qlib_image -f ./Dockerfile . - - # Log in to Docker Hub - # If you are a new docker hub user, please verify your email address before proceeding with this step. - sudo docker login - - # Tag the Docker image - sudo docker tag qlib_image /qlib_image:stable - - # Push the Docker image to Docker Hub - sudo docker push /qlib_image:stable - ``` +Running `build_docker_image.sh` is the right choice when you want to create a docker image for `Qlib`. Of course, before running it, please open this file and make some necessary changes according to your docker hub account. For more information, please see: https://qlib.readthedocs.io/en/latest/start/installation.html ## Auto Quant Research Workflow Qlib provides a tool named `qrun` to run the whole workflow automatically (including building dataset, training models, backtest and evaluation). You can start an auto quant research workflow and have a graphical reports analysis according to the following steps: diff --git a/docs/start/installation.rst b/docs/start/installation.rst index 451fc0a426..f617182fcf 100644 --- a/docs/start/installation.rst +++ b/docs/start/installation.rst @@ -44,3 +44,22 @@ Use the following code to make sure the installation successful: >>> import qlib >>> qlib.__version__ + + +Running ``build_docker_image.sh`` is the right choice when you want to create a docker image for ``Qlib``. +Of course, before running it, please open this file and make some necessary changes according to your docker hub account. +.. code-block:: bash + #!/bin/bash + + # Build the Docker image + sudo docker build -t qlib_image -f ./Dockerfile . + + # Log in to Docker Hub + # If you are a new docker hub user, please verify your email address before proceeding with this step. + sudo docker login + + # Tag the Docker image + sudo docker tag qlib_image /qlib_image:stable + + # Push the Docker image to Docker Hub + sudo docker push /qlib_image:stable diff --git a/setup.py b/setup.py index a0dc9962c6..bce3b812d0 100644 --- a/setup.py +++ b/setup.py @@ -47,6 +47,10 @@ def get_version(rel_path: str) -> str: "numpy>=1.12.0, <1.24", "pandas>=0.25.1", "scipy>=1.7.3", + # scs is a dependency package, + # and the latest version of scs: scs-3.2.4.post3.tar.gz causes the documentation build to fail, + # so we have temporarily limited the version of scs. + "scs<=3.2.4", "requests>=2.18.0", "sacred>=0.7.4", "python-socketio", From ee7e64fd0ad1030c28428c539a6e3d4ecba65656 Mon Sep 17 00:00:00 2001 From: Linlang Date: Thu, 27 Jun 2024 20:43:02 +0800 Subject: [PATCH 5/7] optimize dockerfile --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4ed2c048c2..4aa8ba125a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,5 +22,3 @@ RUN python -m pip install scikit-learn==1.3.2 RUN python -m pip install cython packaging tables matplotlib statsmodels RUN python -m pip install pyqlib - -EXPOSE 10050 From c5a864397cbdb1001589de8720aa809ff1f0bc6f Mon Sep 17 00:00:00 2001 From: Linlang Date: Thu, 27 Jun 2024 21:18:55 +0800 Subject: [PATCH 6/7] optimize docs --- docs/start/installation.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/start/installation.rst b/docs/start/installation.rst index f617182fcf..7a6dafadff 100644 --- a/docs/start/installation.rst +++ b/docs/start/installation.rst @@ -49,6 +49,7 @@ Use the following code to make sure the installation successful: Running ``build_docker_image.sh`` is the right choice when you want to create a docker image for ``Qlib``. Of course, before running it, please open this file and make some necessary changes according to your docker hub account. .. code-block:: bash + #!/bin/bash # Build the Docker image From e93935b92fcb8c7672f1a4e75763c864424dc9f8 Mon Sep 17 00:00:00 2001 From: Linlang Date: Thu, 27 Jun 2024 21:44:09 +0800 Subject: [PATCH 7/7] optimize dockerfile --- build_docker_image.sh | 4 ++-- docs/start/installation.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build_docker_image.sh b/build_docker_image.sh index ecca14f1cc..8e76e923cb 100644 --- a/build_docker_image.sh +++ b/build_docker_image.sh @@ -8,7 +8,7 @@ sudo docker build -t qlib_image -f ./Dockerfile . sudo docker login # Tag the Docker image -sudo docker tag qlib_image /qlib_image:stable +sudo docker tag qlib_image /qlib_image: # Push the Docker image to Docker Hub -sudo docker push /qlib_image:stable +sudo docker push /qlib_image: diff --git a/docs/start/installation.rst b/docs/start/installation.rst index 7a6dafadff..a50ac1677e 100644 --- a/docs/start/installation.rst +++ b/docs/start/installation.rst @@ -60,7 +60,7 @@ Of course, before running it, please open this file and make some necessary chan sudo docker login # Tag the Docker image - sudo docker tag qlib_image /qlib_image:stable + sudo docker tag qlib_image /qlib_image: # Push the Docker image to Docker Hub - sudo docker push /qlib_image:stable + sudo docker push /qlib_image: