-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add dockerfile * add execute script * add docs * optimize docs * optimize dockerfile * optimize docs * optimize dockerfile * update code & update README * doc build error * update docs * update code
- Loading branch information
1 parent
ca9f186
commit f2caf45
Showing
9 changed files
with
189 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
__pycache__ | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
.Python | ||
.env | ||
.git | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM continuumio/miniconda3:latest | ||
|
||
WORKDIR /qlib | ||
|
||
COPY . . | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y build-essential | ||
|
||
RUN conda create --name qlib_env python=3.8 -y | ||
RUN echo "conda activate qlib_env" >> ~/.bashrc | ||
ENV PATH /opt/conda/envs/qlib_env/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 python -m pip install cython packaging tables matplotlib statsmodels | ||
RUN python -m pip install pybind11 cvxpy | ||
|
||
ARG IS_STABLE="yes" | ||
|
||
RUN if [ "$IS_STABLE" = "yes" ]; then \ | ||
python -m pip install pyqlib; \ | ||
else \ | ||
python setup.py install; \ | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
docker_user="your_dockerhub_username" | ||
|
||
read -p "Do you want to build the nightly version of the qlib image? (default is stable) (yes/no): " answer; | ||
answer=$(echo "$answer" | tr '[:upper:]' '[:lower:]') | ||
|
||
if [ "$answer" = "yes" ]; then | ||
# Build the nightly version of the qlib image | ||
docker build --build-arg IS_STABLE=no -t qlib_image -f ./Dockerfile . | ||
image_tag="nightly" | ||
else | ||
# Build the stable version of the qlib image | ||
docker build -t qlib_image -f ./Dockerfile . | ||
image_tag="stable" | ||
fi | ||
|
||
read -p "Is it uploaded to docker hub? (default is no) (yes/no): " answer; | ||
answer=$(echo "$answer" | tr '[:upper:]' '[:lower:]') | ||
|
||
if [ "$answer" = "yes" ]; then | ||
# Log in to Docker Hub | ||
# If you are a new docker hub user, please verify your email address before proceeding with this step. | ||
docker login | ||
# Tag the Docker image | ||
docker tag qlib_image "$docker_user/qlib_image:$image_tag" | ||
# Push the Docker image to Docker Hub | ||
docker push "$docker_user/qlib_image:$image_tag" | ||
else | ||
echo "Not uploaded to docker hub." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
.. _docker_image: | ||
|
||
================== | ||
Build Docker Image | ||
================== | ||
|
||
Dockerfile | ||
========== | ||
|
||
There is a **Dockerfile** file in the root directory of the project from which you can build the docker image. There are two build methods in Dockerfile to choose from. | ||
When executing the build command, use the ``--build-arg`` parameter to control the image version. The ``--build-arg`` parameter defaults to ``yes``, which builds the ``stable`` version of the qlib image. | ||
|
||
1.For the ``stable`` version, use ``pip install pyqlib`` to build the qlib image. | ||
|
||
.. code-block:: bash | ||
docker build --build-arg IS_STABLE=yes -t <image name> -f ./Dockerfile . | ||
.. code-block:: bash | ||
docker build -t <image name> -f ./Dockerfile . | ||
2. For the ``nightly`` version, use current source code to build the qlib image. | ||
|
||
.. code-block:: bash | ||
docker build --build-arg IS_STABLE=no -t <image name> -f ./Dockerfile . | ||
Auto build of qlib images | ||
========================= | ||
|
||
1. There is a **build_docker_image.sh** file in the root directory of your project, which can be used to automatically build docker images and upload them to your docker hub repository(Optional, configuration required). | ||
|
||
.. code-block:: bash | ||
sh build_docker_image.sh | ||
>>> Do you want to build the nightly version of the qlib image? (default is stable) (yes/no): | ||
>>> Is it uploaded to docker hub? (default is no) (yes/no): | ||
2. If you want to upload the built image to your docker hub repository, you need to edit your **build_docker_image.sh** file first, fill in ``docker_user`` in the file, and then execute this file. | ||
|
||
How to use qlib images | ||
====================== | ||
1. Start a new Docker container | ||
|
||
.. code-block:: bash | ||
docker run -it --name <container name> -v <Mounted local directory>:/app <image name> | ||
2. At this point you are in the docker environment and can run the qlib scripts. An example: | ||
|
||
.. code-block:: bash | ||
>>> python scripts/get_data.py qlib_data --name qlib_data_simple --target_dir ~/.qlib/qlib_data/cn_data --interval 1d --region cn | ||
>>> python qlib/workflow/cli.py examples/benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yaml | ||
3. Exit the container | ||
|
||
.. code-block:: bash | ||
>>> exit | ||
4. Restart the container | ||
|
||
.. code-block:: bash | ||
docker start -i -a <container name> | ||
5. Stop the container | ||
|
||
.. code-block:: bash | ||
docker stop -i -a <container name> | ||
6. Delete the container | ||
|
||
.. code-block:: bash | ||
docker rm <container name> | ||
7. For more information on using docker see the `docker documentation <https://docs.docker.com/reference/cli/docker/>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters