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

possible data path and addon arg fix #161

Merged
merged 3 commits into from
Jan 29, 2024

Conversation

GeoDerp
Copy link
Contributor

@GeoDerp GeoDerp commented Jan 29, 2024

No description provided.

Copy link

codecov bot commented Jan 29, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (d9f6bfb) 74.95% compared to head (d6e12e7) 74.95%.

Files Patch % Lines
src/emhass/web_server.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #161   +/-   ##
=======================================
  Coverage   74.95%   74.95%           
=======================================
  Files           7        7           
  Lines        1861     1861           
=======================================
  Hits         1395     1395           
  Misses        466      466           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GeoDerp
Copy link
Contributor Author

GeoDerp commented Jan 29, 2024

Currently testing. May try and simulate the addon container directory structure of the add-on container as best as possible.

@davidusb-geek
Copy link
Owner

The working folder for the docker standalone mode (no add-on) is /app.
In this PR you erased the pointers to /app. This will probably break the docker standalone mode.
Yesterday I tested this mode and works perfectly.
The problem is with the add-on mode.

@GeoDerp
Copy link
Contributor Author

GeoDerp commented Jan 29, 2024

I wonder if the run.sh should be like:

#!/usr/bin/with-contenv bashio
# ==============================================================================
# Start EMHASS service
# ==============================================================================

export CONFIG_PATH="/usr/src/config_emhass.yaml"
export OPTIONS_PATH="/data/options.json"
export DATA_PATH="/data/" 

exec python3 -m emhass.web_server --url "http://supervisor/core/api" --key "$SUPERVISOR_TOKEN" --addon "True"

?

@GeoDerp
Copy link
Contributor Author

GeoDerp commented Jan 29, 2024

docker file I created to test the add-on as close as I can make it without emulating HA (ran in EMHASS root)

#Test Add-on via Docker Emulation
#Docker run example: 
## docker build . -t emhass-addon -f AddonEmulateDocker && docker run  -e CONFIG_PATH="/usr/src/config_emhass.yaml" -e "SECRETS_PATH=/usr/src/secrets_emhass.yaml"  -e DATA_PATH="/data/" -e OPTIONS_PATH="/data/options.json" emhass-addon --url $URL --key $KEY
FROM --platform=$BUILDPLATFORM debian:stable AS build
WORKDIR /usr/src

# copy the requirements file into the image
COPY ./requirements.txt /usr/src/requirements.txt

# Setup
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        libffi-dev \
        python3.11 \
        python3 \
        python3-pip \
        python3-dev \
        git \
        build-essential \
        gcc \
        coinor-cbc \
        coinor-libcbc-dev \
        libglpk-dev \
        glpk-utils \
        libhdf5-dev \
        libhdf5-serial-dev \
        netcdf-bin \
        libnetcdf-dev \
        pkg-config \
        gfortran \
        libatlas-base-dev \
    && ln -s /usr/include/hdf5/serial /usr/include/hdf5/include \
    && export HDF5_DIR=/usr/include/hdf5 \
    && pip3 install --extra-index-url=https://www.piwheels.org/simple --no-cache-dir --break-system-packages -U setuptools wheel \
    && pip3 install --extra-index-url=https://www.piwheels.org/simple --no-cache-dir --break-system-packages -r requirements.txt \
    && apt-get purge -y --auto-remove \
        python3-pip \
        python3-dev \
        git \
        build-essential \
        libhdf5-dev \
        libhdf5-serial-dev \
        pkg-config \
        gfortran \
    && rm -rf /var/lib/apt/lists/*

#install local emhass 
#RUN git clone https://github.com/davidusb-geek/emhass.git
#pip install emhass (original)
COPY ./. /tmp/emhass
WORKDIR /tmp/emhass
RUN python3 setup.py install


WORKDIR /

# copy contentsusr/src
COPY config_emhass.yaml /usr/src
COPY options.json /data/

#unused in production, used temporarily for testing
COPY secrets_emhass.yaml /usr/src/ 

# Labels
LABEL \
  io.hass.name="emhass" \
  io.hass.description="EMHASS: Energy Management for Home Assistant" \
  io.hass.version=${BUILD_VERSION} \
  io.hass.type="addon" \
  io.hass.arch="aarch64|amd64|armhf|armv7"

ENTRYPOINT [ "python3", "-m", "emhass.web_server", "--addon", "True" ]

@GeoDerp
Copy link
Contributor Author

GeoDerp commented Jan 29, 2024

When testing I couldn't find any errors besides setting paths. Let me know if you get more errors and ill test again 👍
Im assuming the Add-on change you mentioned was the problem

@davidusb-geek
Copy link
Owner

Ok thanks. I will merge, test it as it is and if that fails then I will look into the run.sh suggestion.

@davidusb-geek davidusb-geek merged commit f6ea269 into davidusb-geek:master Jan 29, 2024
12 of 13 checks passed
@GeoDerp
Copy link
Contributor Author

GeoDerp commented Jan 29, 2024

If the run.sh modification is required you may only need to parse in the options environment variable.

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