Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added docker compose #154

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

added docker compose #154

wants to merge 4 commits into from

Conversation

rowellz
Copy link

@rowellz rowellz commented Mar 8, 2025

Added a simple docker-compose environment so docker users can run the project with just 1 or 2 commands. Not sure if this helps, but this implementation is based on the docker-compose & docker exec setup I contributed to this very similar repo:

https://github.com/dzhng/deep-research

However, users could use docker run as well if they wish

Dockerfile Outdated
@@ -0,0 +1,15 @@
FROM python:3.12-slim
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May use latest Python version 3.13.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using 3.13, it didn't work unfortunately. The performance of 3.12 is noticeably better than 3.10 though

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What error came with Python 3.13?

Copy link
Author

@rowellz rowellz Mar 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using 3.13 caused this error when running the poetry install step. This error appeared with both the cURL & pip install versions of poetry. Here is the error on the build step:

Step 5/6 : RUN poetry install
---> Running in bdb9face6818
Creating virtualenv ai-hedge-fund-aScRyBoL-py3.13 in /root/.cache/pypoetry/virtualenvs
Installing dependencies from lock file

Package operations: 87 installs, 0 updates, 0 removals

  • Installing certifi (2025.1.31)
  • Installing charset-normalizer (3.4.1)
  • Installing h11 (0.14.0)
  • Installing idna (3.10)
  • Installing sniffio (1.3.1)
  • Installing typing-extensions (4.12.2)
  • Installing urllib3 (2.3.0)
  • Installing annotated-types (0.7.0)
  • Installing requests (2.32.3)
  • Installing anyio (4.8.0)
  • Installing pydantic-core (2.27.2)
  • Installing httpcore (1.0.7)
  • Installing httpx (0.28.1)
  • Installing jsonpointer (3.0.0)
  • Installing orjson (3.10.15)
  • Installing requests-toolbelt (1.0.0)
  • Installing pydantic (2.10.6)
  • Installing frozenlist (1.5.0)
  • Installing packaging (24.2)
  • Installing jsonpatch (1.33)
  • Installing pyyaml (6.0.2)
  • Installing multidict (6.1.0)
  • Installing propcache (0.2.1)
  • Installing langsmith (0.1.147)
  • Installing tenacity (8.5.0)
  • Installing aiohappyeyeballs (2.4.4)
  • Installing aiosignal (1.3.2)
  • Installing attrs (25.1.0)
  • Installing greenlet (3.1.1)
  • Installing mdurl (0.1.2)
  • Installing distro (1.9.0)
  • Installing numpy (1.26.4)
  • Installing msgpack (1.1.0)
  • Installing regex (2024.11.6)
  • Installing six (1.17.0)
  • Installing langchain-core (0.3.33)
  • Installing jiter (0.8.2)
  • Installing tqdm (4.67.1)
  • Installing wcwidth (0.2.13)
  • Installing yarl (1.18.3)

PEP517 build of a dependency failed

Backend subprocess exited when trying to invoke build_wheel

| Command '['/tmp/tmppe6y2icw/.venv/bin/python', '/usr/local/lib/python3.13/site-packages/pyproject_hooks/_in_process/_in_process.py', 'build_wheel', '/tmp/tmp91qrp18c']' returned non-zero exit status 1.
| 
| + /tmp/tmppe6y2icw/.venv/bin/python /tmp/tmpj0brso70/numpy-1.26.4/vendored-meson/meson/meson.py setup /tmp/tmpj0brso70/numpy-1.26.4 /tmp/tmpj0brso70/numpy-1.26.4/.mesonpy-8o4c0uj8 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/tmp/tmpj0brso70/numpy-1.26.4/.mesonpy-8o4c0uj8/meson-python-native-file.ini
| The Meson build system
| Version: 1.2.99
| Source dir: /tmp/tmpj0brso70/numpy-1.26.4
| Build dir: /tmp/tmpj0brso70/numpy-1.26.4/.mesonpy-8o4c0uj8
| Build type: native build
| Project name: NumPy
| Project version: 1.26.4
| 
| ../meson.build:1:0: ERROR: Unknown compiler(s): [['cc'], ['gcc'], ['clang'], ['nvc'], ['pgcc'], ['icc'], ['icx']]
| The following exception(s) were encountered:
| Running `cc --version` gave "[Errno 2] No such file or directory: 'cc'"
| Running `gcc --version` gave "[Errno 2] No such file or directory: 'gcc'"
| Running `clang --version` gave "[Errno 2] No such file or directory: 'clang'"
| Running `nvc --version` gave "[Errno 2] No such file or directory: 'nvc'"
| Running `pgcc --version` gave "[Errno 2] No such file or directory: 'pgcc'"
| Running `icc --version` gave "[Errno 2] No such file or directory: 'icc'"
| Running `icx --version` gave "[Errno 2] No such file or directory: 'icx'"
| 
| A full log can be found at /tmp/tmpj0brso70/numpy-1.26.4/.mesonpy-8o4c0uj8/meson-logs/meson-log.txt

Note: This error originates from the build backend, and is likely not a problem with poetry but one of the following issues with numpy (1.26.4)

  • not supporting PEP 517 builds
  • not specifying PEP 517 build requirements correctly
  • the build requirements are incompatible with your operating system or Python version
  • the build requirements are missing system dependencies (eg: compilers, libraries, headers).

You can verify this by running pip wheel --no-cache-dir --use-pep517 "numpy (==1.26.4)".

The command '/bin/sh -c poetry install' returned a non-zero code: 1
ERROR: Service 'ai-hedge-fund' failed to build : Build failed

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like that the build-essentialare missing.

May you can try the following Dockerfile:

FROM python:3.13-slim

ENV PATH="${PATH}:/root/.local/bin"

WORKDIR /ai-hedge-fund

COPY . .

RUN apt update && apt install -y build-essential \
    && rm -rf /var/lib/apt/lists/* \
    && pip install poetry \
    && poetry install

ENTRYPOINT ["poetry", "run", "python", "src/main.py"]

CMD ["--ticker", "AAPL,MSFT,NVDA"]

Copy link
Author

@rowellz rowellz Mar 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was able to install 3.13 with that configuration. But I am not sure if I agree with requiring a ENTRYPOINT & CMD. What if a user wanted to use the backtester or a different set of tickers? Id much rather run a different docker exec command than having to edit the Dockerfile

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was able to install 3.13 with that configuration. But I am not sure if I agree with requiring a ENTRYPOINT & CMD. What if a user wanted to use the backtester or a different set of tickers? Id much rather run a different docker exec command than having to edit the Dockerfile

take a look into my comment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed it when I left that previous comment. I think I get it now. Going to add instructions for both docker run and docker compose in the README in my next commit. Thanks!

Dockerfile Outdated
Comment on lines 3 to 7
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*

RUN curl -sSL https://install.python-poetry.org | python3 -
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace it with RUN pip install poetry to get rid of not needed docker layer

Dockerfile Outdated

COPY . .

RUN poetry install
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMD or ENTRYPOINT line is missing.
Dockerfile should specify at least one of CMD or ENTRYPOINT commands.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you suggest it should be? adding something like the code snippet below would break the flexibility of running the scripts dynamically via docker exec

ENTRYPOINT ["poetry", "run", "python", "-u", "src/main.py"]
CMD ["--ticker", "AAPL,MSFT,NVDA"]  # Optional default arguments

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can overwrite the ENTRYPOINT by parameter --entrypoint and CMD by adding it to the end of the docker run <image-name> poetry run 'poetry run abc.py' command.

docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...]

Or by the command:element in the docker-compose.yml

Copy link
Author

@rowellz rowellz Mar 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think I took care of most of the initial feedback, thanks for reviewing this! Also thanks for your patience as I am a bit of a docker-compose power user and not too familiar with the nuances of CMD & ENTRYPOINT with docker run. Please let me know if there is anything else you may want refactored

@r0b2g1t r0b2g1t mentioned this pull request Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants