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

A prebuild docker image #4

Open
weihongliang233 opened this issue Jul 9, 2023 · 2 comments
Open

A prebuild docker image #4

weihongliang233 opened this issue Jul 9, 2023 · 2 comments

Comments

@weihongliang233
Copy link

I am raising an issue for a repository that includes three interrelated projects: yetfl, etfl, and pytfa. It seems that these projects have not been maintained for a while, and the requirements.txt file does not specify the exact version numbers for the libraries. Therefore, for someone who is new to this project, it is challenging to configure the environment correctly and easily obtain the desired results.

After a series of fixes, I have successfully created a pre-built Docker image that can be pulled and used directly, eliminating the need to solve the environment issues individually.

Prerequisite steps: You must clone all three projects onto your computer and organize the file directory as follows; otherwise, the Docker image will not run:

└───parent_folder
    └───pytfa (git cloned)
    └───etfl (git cloned)
    └───yetfl (git cloned)

Then, execute the following command to pull the Docker image:

docker pull device0/yetfl:latest

Once the image is successfully pulled, you can use the docker images command to view the image's ID.

To run the container, you need to correctly mount the Docker volumes. Here are the specific steps:

Navigate to parent_folder/etfl/docker. You should see a file named run or run.bat.

The content of this file should be as follows:

docker run 	--rm -it 	^
		-v %CD%\work:/home/pytfa/work 	^
		-v %CD%\..\..\pytfa:/src/pytfa		^
		-v %CD%\..:/src/etfl		^
		etfl-docker %*

The volumes are already mounted correctly for you in this script. You only need to replace the last line, etfl-docker, with the ID of my image:

docker run 	--rm -it 	^
		-v %CD%\work:/home/pytfa/work 	^
		-v %CD%\..\..\pytfa:/src/pytfa		^
		-v %CD%\..:/src/etfl		^
		<ID of my image> %*

After making this change, run the run file, and you will enter the container.

Once inside the container, navigate to:

cd /home/root/yetfl/code

Then run the following command:

python ./helper_gen_models_yeast.py

You will see that it starts working.

Please note that the instructions provided assume familiarity with Docker and assume that you have already cloned the necessary repositories.

@weihongliang233
Copy link
Author

This Docker image is built in two steps. First, the pytfa image is built, followed by the etfl image. For building these two images, I used my own requirements.txt and Dockerfile to address dependency issues.

pytfa requirements.txt

bokeh==2.3.0
cobra==0.22.0
equilibrator-api
equilibrator-cache==0.2.6
ipdb==0.13.6
lxml==4.6.4
networkx==2.5
openpyxl
pymysql
pytest==6.2.2
python-libsbml==5.19.0
scipy==1.5.4
sqlalchemy==1.4.0
tabulate==0.8.9
tqdm==4.59.0
sphinx==4.3.1
sphinx-rtd-theme==0.5.1

pytfa Dockerfile

FROM python:3.6
# Warning: cplex 12.7.1 is only compatible with python 3.5, while
# Gurobi 7.5 is only compatbile with with python 3.6. If you wan to
# install both, I recommend downgrading the gurobi version.
# Another way (not recommended) is tweaking the setup.py python version
# requirements of either one of them, but this might alter stability
# of the solvers

# Install missing deps
USER root

RUN echo 'root:a187J3X1' | chpasswd

RUN apt-get update && apt-get install -y --no-install-recommends \
        libxml2-dev     \
        libxslt1-dev    \
        less            \
        sudo            \
        vim             \
    && rm -rf /var/lib/apt/lists/*

ENV USER root
ENV HOME /home/$USER

# RUN useradd -ms "/bin/bash" "$USER"
USER $USER
WORKDIR $HOME

USER root

# Copy python package requirements
COPY requirements.txt .


RUN mkdir package_store

# Install python packages
RUN pip download -r requirements.txt --dest package_store

RUN pip install --no-index --find-links=package_store -r requirements.txt


# Take care of the solvers
COPY ./solvers /solvers
COPY ./utils /utils

RUN git clone https://github.com/EPFL-LCSB/pytfa

RUN chmod u+x /utils/*.sh

# Install CPLEX
RUN /utils/install_cplex.sh
# Install gurobi
COPY ./utils/gurobi.lic* ./
RUN /utils/install_gurobi.sh

# Remove installers
RUN rm -rf /solvers

# Add extra src if needed
RUN mkdir /src
COPY src/ /src/

# Make the /src/pytfa folder that will link the sources
RUN mkdir /src/pytfa

COPY .bashrc $HOME
RUN chown "$USER" "$HOME/.bashrc"

#Finalizing installation

RUN chmod +x /utils/activate_gurobi.sh 

USER $USER
RUN mkdir ./work

# Activation of necessary licenses
RUN /utils/activate_gurobi.sh

# Load your package in development mode on startup
ENTRYPOINT ["/bin/bash", "-c", "pip install --user -e /src/pytfa && $0 $*"]
CMD /bin/bash

etfl requirements.txt

bokeh==2.3.0
biopython==1.79
cobra==0.22.0
ipdb==0.13.6
lxml==4.6.4
openpyxl
pymysql
pytest==6.2.2
python-libsbml==5.19.0
scipy==1.5.4
sklearn
sqlalchemy==1.4.0
tabulate==0.8.9
sphinx==4.3.1
sphinx-rtd-theme==0.5.1
xlrd==2.0.1

etfl Dockerfile

FROM pytfa_docker

# Install missing deps
USER root
#RUN apt-get update && apt-get install -y --no-install-recommends \
#        libxml2-dev     \
#        libxslt1-dev    \
#		less			\
#    && rm -rf /var/lib/apt/lists/*

# Copy python package requirements
COPY requirements.txt .

RUN mkdir package_store_

# Install python packages
RUN pip download -r requirements.txt --dest package_store_

RUN pip install --no-index --find-links=package_store_ -r requirements.txt



# For SVG export
COPY utils/setup_svg_export.sh .
RUN chmod +x setup_svg_export.sh && ./setup_svg_export.sh

# Make the /src/etfl folder that will link the sources
RUN mkdir /src/etfl


RUN git clone https://github.com/EPFL-LCSB/etfl.git

RUN git clone https://github.com/EPFL-LCSB/yetfl.git


RUN ls /home/root/work

# RUN "cp -r /home/root/work/store/store/*  yetfl/"

ENTRYPOINT ["/bin/bash", "-c", "pip install --user -e /src/pytfa && pip install --user -e /src/etfl && $0 $*"]
CMD /bin/bash

Please note that I have only tested running helper_gen_models_yeast.py, and there were several error logs while running it. In short, this image only guarantees that you can complete helper_gen_models_yeast.py without interruptions, but it does not guarantee correctness.

@weihongliang233
Copy link
Author

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

No branches or pull requests

1 participant