SCIInstitute / UncertainSCI

MIT License
8 stars 10 forks source link

Installing UncertainSCI #90

Closed Mazze closed 2 years ago

Mazze commented 3 years ago

I am trying a minimal installation of UnvertainSCI but it fails. Flowing the documentation python 3 should be used. The requirements need to be installed with pip and the package itself. The first observation is, that the python version 3.9 will fail to install the requirements. Thus, I use python version 3.8. To install UncertainSCI, I use the official python 3.8 docker image and follow the instructions from your documentation. This results in the Dockerfile, which is saved in the root folder of this repo.

FROM python:3.8
RUN useradd -ms /bin/bash User # Add a user so we do not run as root
USER User
WORKDIR /home/User

COPY ./ /opt/UncertainSCI  # Let's assume we build from the root folder of the repo
COPY demos /home/User/code/demos # Copy them in a place which is accessible by the user

RUN pip install -r /opt/UncertainSCI/requirements.txt  # Install requirements
RUN pip install /opt/UncertainSCI/UncertainSCI # Install UncertainSCI
CMD python

I can build this Dockerfile, plus minus a few expected warnings

docker build -t uncertainsci ./

From the python console docker run -it --rm uncertainsci:latest I try to import UnvertainSCI

>>> import UncertainSCI.distributions
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'UncertainSCI'
>>> 

Which is not available.

Using the same container, but with bash docker run -it --rm uncertainsci:latest /bin/bash and reinstalling UncertainSCI, shows first that it is already installed and then that, a reinstallation does not solve the problem.

The question is, where do I go wrong in the installation?

jab0707 commented 3 years ago

I am unfamiliar with using Docker, but from my experience when it behaves this way it is because the sys.path does not include the directory for uncertain sci. At the top of your python could you try:

import sys
sys.path.append('path/UncertainSCI/')
import UncertainSCI.distributions
Mazze commented 3 years ago

Okey, that helped to load the module. Resulting in a docker file of

FROM python:3.8
RUN useradd -ms /bin/bash User # Add a user so we do not run as root
USER User
WORKDIR /home/User

COPY ./ /opt/UncertainSCI  # Let's assume we build from the root folder of the repo
COPY demos /home/User/code/demos # Copy them in a place which is accessible by the user

RUN pip install -r /opt/UncertainSCI/requirements.txt  # Install requirements
RUN pip install /opt/UncertainSCI/UncertainSCI # Install UncertainSCI
ENV PYTHONPATH=/opt/UncertainSCI
CMD python

after startup of the container, UncertainSCI can just be imported.

jessdtate commented 2 years ago

This should be resolved in the newest version. Installing from code and pypi work better now