ianarawjo/ChainForge

pip install -e . does not install chainforge

Closed this issue · 6 comments

If you were to git clone the repo, then do pip install -e . it will install all dependency and say it installed chainforge, however if you were to boot up the Docker container it will say chainforge isn't a module (this also happens without a docker container)

FROM python:3.10

WORKDIR /chainforge

COPY chainforge . 
COPY setup.py .
COPY MANIFEST.in .
COPY README.md .
RUN pip install -e .

ENTRYPOINT [ "chainforge", "serve", "--host", "0.0.0.0" ]

docker build -t chainforge .

docker run -p 8000:8000 chainforge

Will always result to this error

Traceback (most recent call last):
  File "/usr/local/bin/chainforge", line 33, in <module>
    sys.exit(load_entry_point('chainforge', 'console_scripts', 'chainforge')())
  File "/usr/local/bin/chainforge", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/local/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'chainforge'

I think this PR fixed the issue for Docker containers? Let me know. e9da6bc

So it does build, but inside docker you keep getting 500 error

Seems like the problem is that your setting Flask dir as
BUILD_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'react-server', 'build')

But the correct folder is public instead of build..., when I do that change then the 500 error goes away but im greeted to basically an empty page

Still debugging this and when I find what is happening ill report back

The code published here cannot be built from source.

What commands are required?

FROM python:3.12-slim AS builder

RUN pip install --upgrade pip
RUN git clone https://github.com/ianarawjo/ChainForge.git 
COPY . .
RUN pip install -e .

WORKDIR /chainforge

EXPOSE 8000
ENTRYPOINT [ "chainforge", "serve", "--host", "0.0.0.0" ]

Is there something different needed to install this?

I figured it out. Ok so I am assuming this git repo is one version behind or something close to that? I ended up having to download th tar file from https://pypi.org/project/chainforge/#files and only then could I build and run. Is it possible to update the git repo?

Welp this was a full blown circus show on my part, which was entirely my fault. I hadn't seen https://chainforge.ai/docs/for_dev/ as it was hidden (please move that out of Misc) so anyway, once I found that out it worked. As a token of appreciation here is a Dockerfile for anyone else who want to develop on this inside of Docker.

FROM node:latest

# Install dependencies for building Python
RUN apt-get update && \
    apt-get install -y \
        wget \
        build-essential \
        libreadline-dev \
        libncursesw5-dev \
        libssl-dev \
        libsqlite3-dev \
        tk-dev \
        libgdbm-dev \
        libc6-dev \
        libbz2-dev \
        libffi-dev \
        zlib1g-dev && \
    # Clean up
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Download and install Python 3.10
RUN wget https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tgz && \
    tar xzf Python-3.10.13.tgz && \
    cd Python-3.10.13 && \
    ./configure --enable-optimizations && \
    make altinstall && \
    cd .. && \
    rm -rf Python-3.10.13 Python-3.10.13.tgz

# Install pip for Python 3.10, you can go higher if wanted but stay within the 3.10 series at minimum
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

# Make python3.10 the default python3
RUN update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 1 && \
    update-alternatives --install /usr/bin/python python /usr/local/bin/python3.10 1

# Verify installations
RUN node -v && npm -v && python3 --version && pip3 --version

# Set the working directory
WORKDIR /app

#for static build
EXPOSE 8000 

#For dynamic runtime, pref for devs
EXPOSE 3000 

ENTRYPOINT [ "/bin/bash" ]