hassio-addons / addon-jupyterlab

JupyterLab - Home Assistant Community Add-ons
https://addons.community
MIT License
54 stars 27 forks source link

Feature Request : add support for fbprophet #29

Closed ejalal closed 5 years ago

ejalal commented 5 years ago

Problem/Motivation

Time series forecasting with Facebook Prophet fbprophet https://facebook.github.io/prophet/docs/quick_start.html#python-api

Expected behavior

fbprophet installation using init_command configuration

{
  "log_level": "info",
  "github_access_token": "",
  "ssl": false,
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "system_packages": [],
  "init_commands": [
    "pip install fbprophet"
  ]
}

Actual behavior

 From: Community Hass.io Add-ons
 By: Franck Nijhof <frenck@addons.community>
-----------------------------------------------------------
 armhf / Raspbian GNU/Linux 9 (stretch) / HA 0.87.0 / SU 143 / stable
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
Log level is set to INFO
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] 02-updates.sh: executing... 

INFO: You are running the latest version of this add-on
[cont-init.d] 02-updates.sh: exited 0.
[cont-init.d] 10-requirements.sh: executing... 
[cont-init.d] 10-requirements.sh: exited 0.
[cont-init.d] 11-nginx.sh: executing... 
[cont-init.d] 11-nginx.sh: exited 0.
[cont-init.d] 20-notebooks-dir.sh: executing... 
WARNING: Not updating Home Assistant notebook!
WARNING: You have made local changes, which we will not overwrite.
WARNING: Not updating Bokeh examples notebook!
WARNING: You have made local changes, which we will not overwrite.
[cont-init.d] 20-notebooks-dir.sh: exited 0.
[cont-init.d] 21-persistent-storage.sh: executing... 
[cont-init.d] 21-persistent-storage.sh: exited 0.
[cont-init.d] 51-github.sh: executing... 
[cont-init.d] 51-github.sh: exited 0.
[cont-init.d] 80-system-packages.sh: executing... 
[cont-init.d] 80-system-packages.sh: exited 0.
[cont-init.d] 81-user-scripts.sh: executing... 
Collecting fbprophet
  Downloading https://files.pythonhosted.org/packages/9b/a1/fef4ce00acbc28e75c0d33f60c9777527c4295656903b00ac4c9525cef7f/fbprophet-0.4.post2.tar.gz (45kB)
Collecting Cython>=0.22 (from fbprophet)
  Downloading https://files.pythonhosted.org/packages/e0/31/4a166556f92c469d8291d4b03a187f325c773c330fffc1e798bf83d947f2/Cython-0.29.5.tar.gz (2.0MB)
Collecting pystan>=2.14 (from fbprophet)
  Downloading https://files.pythonhosted.org/packages/96/21/6452aadcbb5807fb8858e8789c74d62f5ebaece0351ff231f44064c44b33/pystan-2.18.1.0.tar.gz (17.5MB)
Requirement already satisfied: numpy>=1.10.0 in /usr/local/lib/python3.6/dist-packages (from fbprophet) (1.15.4)
Requirement already satisfied: pandas>=0.20.1 in /usr/local/lib/python3.6/dist-packages (from fbprophet) (0.23.4)
Requirement already satisfied: matplotlib>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from fbprophet) (3.0.2)
Collecting lunardate>=0.1.5 (from fbprophet)
  Downloading https://files.pythonhosted.org/packages/4e/7e/377a3cbba646ec0cf79433ef858881d809a3b87eb887b0901cb83c66a758/lunardate-0.2.0-py3-none-any.whl
Collecting convertdate>=2.1.2 (from fbprophet)
  Downloading https://files.pythonhosted.org/packages/74/83/d0fa07078f4d4ae473a89d7d521aafc66d82641ea0af0ef04a47052e8f17/convertdate-2.1.3-py2.py3-none-any.whl
Collecting holidays>=0.9.5 (from fbprophet)
  Downloading https://files.pythonhosted.org/packages/40/b0/3dfe3d3ed79087848a22de46d379462e371517571ee64668791f3d49ea29/holidays-0.9.9.tar.gz (68kB)
Collecting setuptools-git>=1.2 (from fbprophet)
  Downloading https://files.pythonhosted.org/packages/05/97/dd99fa9c0d9627a7b3c103a00f1566d8193aca8d473884ed258cca82b06f/setuptools_git-1.2-py2.py3-none-any.whl
Requirement already satisfied: python-dateutil>=2.5.0 in /usr/local/lib/python3.6/dist-packages (from pandas>=0.20.1->fbprophet) (2.7.5)
Requirement already satisfied: pytz>=2011k in /usr/local/lib/python3.6/dist-packages (from pandas>=0.20.1->fbprophet) (2018.7)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib>=2.0.0->fbprophet) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib>=2.0.0->fbprophet) (1.0.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib>=2.0.0->fbprophet) (2.3.0)
Collecting ephem<3.8,>=3.7.5.3 (from convertdate>=2.1.2->fbprophet)
  Downloading https://files.pythonhosted.org/packages/c3/2c/9e1a815add6c222a0d4bf7c644e095471a934a39bc90c201f9550a8f7f14/ephem-3.7.6.0.tar.gz (739kB)
Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from holidays>=0.9.5->fbprophet) (1.12.0)
Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from kiwisolver>=1.0.1->matplotlib>=2.0.0->fbprophet) (40.6.3)
Building wheels for collected packages: fbprophet, Cython, pystan, holidays, ephem
  Running setup.py bdist_wheel for fbprophet: started
  Running setup.py bdist_wheel for fbprophet: finished with status 'error'
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-hh6l25_i/fbprophet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-bk2slxf9 --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib
  creating build/lib/fbprophet
  creating build/lib/fbprophet/stan_model
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-hh6l25_i/fbprophet/setup.py", line 120, in <module>
      """
    File "/usr/local/lib/python3.6/dist-packages/setuptools/__init__.py", line 143, in setup
      return distutils.core.setup(**attrs)
    File "/usr/lib/python3.6/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/lib/python3.6/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.6/dist-packages/wheel/bdist_wheel.py", line 188, in run
      self.run_command('build')
    File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/usr/lib/python3.6/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/tmp/pip-install-hh6l25_i/fbprophet/setup.py", line 44, in run
      build_stan_model(target_dir)
    File "/tmp/pip-install-hh6l25_i/fbprophet/setup.py", line 27, in build_stan_model
      from pystan import StanModel
  ModuleNotFoundError: No module named 'pystan'

  ----------------------------------------
  Failed building wheel for fbprophet
  Running setup.py clean for fbprophet

Steps to reproduce

Proposed changes

ejalal commented 5 years ago

It looks like it was fixed by adding a few apt-get installs, but I think I fried my Rpi since it started compiling code.

{
  "log_level": "info",
  "github_access_token": "",
  "ssl": false,
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "system_packages": [],
  "init_commands": [
    "apt-get update"
    "apt-get -y --no-install-recommends build-essential python-dev python3-dev"
    "pip install fbprophet"
  ]
}

BUT, it could be fixed in the build by adding this line to the requirements.txt file bfprophet==0.4.post2

ejalal commented 5 years ago

Hi Frenck, I'm trying to do this by myself and build the docker on my system but I'm getting this error at step 6/12 If you can guide me on what I'm doing wrong that would be very helpful.

$sudo docker run -it --rm --privileged --name build hassioaddons/build-env:latest --repository https://github.com/ejalal/addon-jupyterlab-lite --target jupyterlab --git --armhf --image "ejalal/jupyterlab"
[armhf] Step 6/12 : RUN     MAKEFLAGS="-j$(nproc)"     && export MAKEFLAGS         && apt-get update     && apt-get install -y --no-install-recommends         build-essential=12.4ubuntu1         dirmngr=2.2.4-1ubuntu1.1         git=1:2.17.1-1ubuntu0.4         gpg-agent=2.2.4-1ubuntu1.1         gpg=2.2.4-1ubuntu1.1         libffi-dev=3.2.1-8         libffi6=3.2.1-8         libfreetype6-dev=2.8.1-2ubuntu2         libfreetype6=2.8.1-2ubuntu2         libjpeg-turbo8-dev=1.5.2-0ubuntu5.18.04.1         libjpeg-turbo8=1.5.2-0ubuntu5.18.04.1         libmysqlclient-dev=5.7.21-1ubuntu1         libmysqlclient20=5.7.21-1ubuntu1         libnginx-mod-http-lua=1.14.0-0ubuntu1.2         libpng-dev=1.6.34-1ubuntu0.18.04.1         libpng16-16=1.6.34-1ubuntu0.18.04.1         libpq-dev=10.6-0ubuntu0.18.04.1         libpq5=10.6-0ubuntu0.18.04.1         libssl-dev=1.1.0g-2ubuntu4.3         libtiff5-dev=4.0.9-5         libxml2-dev=2.9.4+dfsg1-6.1ubuntu1.2         libxml2=2.9.4+dfsg1-6.1ubuntu1.2         libxslt1-dev=1.1.29-5         libxslt1.1=1.1.29-5         libzmq3-dev=4.2.5-1         libzmq5=4.2.5-1         luarocks=2.4.2+dfsg-1         nginx=1.14.0-0ubuntu1.2         pandoc=1.19.2.4~dfsg-1build4         pkg-config=0.29.1-0ubuntu2         python-dev=2.7.15~rc1-1         python3-dev=3.6.7-1~18.04         python3-distutils=3.6.7-1~18.04         python3-minimal=3.6.7-1~18.04         zlib1g-dev=1:1.2.11.dfsg-0ubuntu2         && luarocks install lua-resty-http 0.12-0         && curl -sL https://deb.nodesource.com/setup_8.x | bash -         && apt-get install -y --no-install-recommends         nodejs=8.15.0-1nodesource1         && curl https://bootstrap.pypa.io/get-pip.py | python3         && update-alternatives         --install /usr/bin/python python /usr/bin/python3 10         && pip3 install --no-cache-dir -r /opt/requirements.txt         && jupyter labextension install         @jupyter-widgets/jupyterlab-manager@0.38 --no-build     && jupyter labextension install jupyterlab_bokeh --no-build     && jupyter labextension install @jupyterlab/github --no-build     && jupyter lab build         && apt-get purge -y --auto-remove         build-essential         dirmngr         gpg         gpg-agent         libffi-dev         libfreetype6-dev         libjpeg-turbo8-dev         libmysqlclient-dev         libpng-dev         libpq-dev         libssl-dev         libtiff5-dev         libxml2-dev         libxslt1-dev         libzmq3-dev         pkg-config         python-dev         python3-dev         zlib1g-dev         && find /usr/local/lib/python3.6/ -type d -name tests -depth -exec rm -rf {} \;     && find /usr/local/lib/python3.6/ -type d -name test -depth -exec rm -rf {} \;     && find /usr/local/lib/python3.6/ -name __pycache__ -depth -exec rm -rf {} \;     && find /usr/local/lib/python3.6/ -name "*.pyc" -depth -exec rm -f {} \;         && npm cache clean --force         && rm -fr         /tmp/*         /root/{.cache,.config,.gnupg,.local,.log,.npm}         /usr/local/share/.cache         /var/{cache,log}/*         /var/lib/apt/lists/*
[armhf]  ---> Running in e8613e3f96bf
[armhf] standard_init_linux.go:190: exec user process caused "no such file or directory"
The command '/bin/bash -o pipefail -c MAKEFLAGS="-j$(nproc)"     && export MAKEFLAGS         && apt-get update     && apt-get install -y --no-install-recommends         build-essential=12.4ubuntu1         dirmngr=2.2.4-1ubuntu1.1         git=1:2.17.1-1ubuntu0.4         gpg-agent=2.2.4-1ubuntu1.1         gpg=2.2.4-1ubuntu1.1         libffi-dev=3.2.1-8         libffi6=3.2.1-8         libfreetype6-dev=2.8.1-2ubuntu2         libfreetype6=2.8.1-2ubuntu2         libjpeg-turbo8-dev=1.5.2-0ubuntu5.18.04.1         libjpeg-turbo8=1.5.2-0ubuntu5.18.04.1         libmysqlclient-dev=5.7.21-1ubuntu1         libmysqlclient20=5.7.21-1ubuntu1         libnginx-mod-http-lua=1.14.0-0ubuntu1.2         libpng-dev=1.6.34-1ubuntu0.18.04.1         libpng16-16=1.6.34-1ubuntu0.18.04.1         libpq-dev=10.6-0ubuntu0.18.04.1         libpq5=10.6-0ubuntu0.18.04.1         libssl-dev=1.1.0g-2ubuntu4.3         libtiff5-dev=4.0.9-5         libxml2-dev=2.9.4+dfsg1-6.1ubuntu1.2         libxml2=2.9.4+dfsg1-6.1ubuntu1.2         libxslt1-dev=1.1.29-5         libxslt1.1=1.1.29-5         libzmq3-dev=4.2.5-1         libzmq5=4.2.5-1         luarocks=2.4.2+dfsg-1         nginx=1.14.0-0ubuntu1.2         pandoc=1.19.2.4~dfsg-1build4         pkg-config=0.29.1-0ubuntu2         python-dev=2.7.15~rc1-1         python3-dev=3.6.7-1~18.04         python3-distutils=3.6.7-1~18.04         python3-minimal=3.6.7-1~18.04         zlib1g-dev=1:1.2.11.dfsg-0ubuntu2         && luarocks install lua-resty-http 0.12-0         && curl -sL https://deb.nodesource.com/setup_8.x | bash -         && apt-get install -y --no-install-recommends         nodejs=8.15.0-1nodesource1         && curl https://bootstrap.pypa.io/get-pip.py | python3         && update-alternatives         --install /usr/bin/python python /usr/bin/python3 10         && pip3 install --no-cache-dir -r /opt/requirements.txt         && jupyter labextension install         @jupyter-widgets/jupyterlab-manager@0.38 --no-build     && jupyter labextension install jupyterlab_bokeh --no-build     && jupyter labextension install @jupyterlab/github --no-build     && jupyter lab build         && apt-get purge -y --auto-remove         build-essential         dirmngr         gpg         gpg-agent         libffi-dev         libfreetype6-dev         libjpeg-turbo8-dev         libmysqlclient-dev         libpng-dev         libpq-dev         libssl-dev         libtiff5-dev         libxml2-dev         libxslt1-dev         libzmq3-dev         pkg-config         python-dev         python3-dev         zlib1g-dev         && find /usr/local/lib/python3.6/ -type d -name tests -depth -exec rm -rf {} \;     && find /usr/local/lib/python3.6/ -type d -name test -depth -exec rm -rf {} \;     && find /usr/local/lib/python3.6/ -name __pycache__ -depth -exec rm -rf {} \;     && find /usr/local/lib/python3.6/ -name "*.pyc" -depth -exec rm -f {} \;         && npm cache clean --force         && rm -fr         /tmp/*         /root/{.cache,.config,.gnupg,.local,.log,.npm}         /usr/local/share/.cache         /var/{cache,log}/*         /var/lib/apt/lists/*' returned a non-zero code: 1

[armhf]  !     ERROR: Docker build failed

 !     ERROR: Build failed, exited with errors
frenck commented 5 years ago

Multiple reasons:

ejalal commented 5 years ago

I get it now, I need to build the docker on the rpi, but what's the alternative to the hassioaddons/build-env ?

frenck commented 5 years ago

@ejalal Building on an ARM device is the only option. Other build environments will not help since our base images do not contain have a CPU emulator.

ejalal commented 5 years ago

Hi @frenck,

Trying to build now on my rpi,

pi@raspberrypi:~/build/addon-jupyterlab-lite/jupyterlab $ sudo docker build -t jupyterlab .

but getting another error

E: Version '2.2.4-1ubuntu1.1' for 'dirmngr' was not found
E: Version '2.2.4-1ubuntu1.1' for 'gpg-agent' was not found
E: Version '2.2.4-1ubuntu1.1' for 'gpg' was not found
frenck commented 5 years ago

I'm sorry @ejalal, this is not an issue anymore at this point. If the above error causes an issue for you, it clearly indicates that you have no idea what you are doing at this point.

If you are looking for support, I suggest dropping by in our Discord server.

I like to keep GitHub solely for tracking issues.

ejalal commented 5 years ago

I'm clearly new to docker, but thanks for the support.

addons-assistant[bot] commented 5 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.