Skip to content

Commit

Permalink
Update docker files
Browse files Browse the repository at this point in the history
  • Loading branch information
d3j331 committed Nov 30, 2023
1 parent 529a095 commit 9f67735
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 64 deletions.
1 change: 1 addition & 0 deletions examples/capabilities/te30/eplus.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "eplus",
"broker_address": "10.5.0.2",
"period": 300,
"logging": "warning",
"publications": [
Expand Down
1 change: 1 addition & 0 deletions examples/capabilities/te30/eplus_agent.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "eplus_agent",
"broker_address": "10.5.0.2",
"period": 300,
"logging": "warning",
"time_delta": 1,
Expand Down
1 change: 1 addition & 0 deletions examples/capabilities/te30/pypower.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "pypower",
"brokeraddress": "10.5.0.2",
"period": 15,
"logging": "warning",
"publications": [
Expand Down
11 changes: 5 additions & 6 deletions scripts/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,17 @@ RUN git config --global user.name "${USER_NAME}" && \
cd ${HOME} || exit && \
echo "++++++++++++++ TESP" && \
git clone -b main https://github.com/pnnl/tesp.git && \
cd tesp || exit && \
cd ${TESPDIR} || exit && \
mkdir -p repository && \
mkdir -p tenv && \
python3.8 -m pip install virtualenv && \
"${HOME}/.local/bin/virtualenv" venv --prompt TESP && \
cd repository || exit && \
echo "Download all relevant repositories..." && \
echo "++++++++++++++ PSST" && \
echo "Copy TESP environment variables to $HOME/tespEnv" && \
cp tesp/scripts/tespEnv "$HOME/" && \
cp ${TESPDIR}/scripts/tespEnv "$HOME/" && \
echo "Activate the python virtual environment" && \
. $HOME/tesp/venv/bin/activate && \
. ${TESPDIR}/venv/bin/activate && \
echo "Download all relevant repositories..." && \
cd ${REPODIR} || exit && \
echo "++++++++++++++ PSST" && \
git clone -b master https://github.com/ames-market/AMES-V5.0.git && \
echo "Applying the patch for AMES...... from ${TESPBUILD}" && \
Expand Down
12 changes: 3 additions & 9 deletions scripts/docker/Dockerfile.eplus
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@ ENV INSTDIR=${TESPDIR}/tenv
ENV PATH=$PATH:$INSTDIR/energyplus
ENV PATH=$PATH:$INSTDIR/energyplus/PreProcess
ENV PATH=$PATH:$INSTDIR/energyplus/PostProcess
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INSTDIR/lib

# Copy Binaries
# COPY --from=tesp-1.3.0:latest $INSTDIR/ $INSTDIR/
# COPY --from=tesp-build:latest $INSTDIR/ $INSTDIR/

RUN echo "===== BUILD RUN EPLUS =====" && \
export DEBIAN_FRONTEND=noninteractive && \
export DEBCONF_NONINTERACTIVE_SEEN=true && \
echo "===== Install Libraries =====" && \
apt-get update && \
apt-get dist-upgrade -y && \
# protect images by changing root password
echo "root:tesp" | chpasswd && \
echo "<<<< Adding the TESP user >>>>" && \
useradd -m -s /bin/bash ${USER_NAME} && \
echo "<<<< Changing new user password >>>>" && \
echo "${USER_NAME}:${USER_NAME}" | chpasswd && \
usermod -aG sudo ${USER_NAME}
apt-get dist-upgrade -y
2 changes: 1 addition & 1 deletion scripts/docker/Dockerfile.fncs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ENV PYHELICS_INSTALL=$INSTDIR
ENV PATH=$JAVA_HOME:$INSTDIR/bin:$PATH

# Copy Binaries
COPY --from=tesp-1.3.0:latest $INSTDIR/ $INSTDIR/
COPY --from=tesp-build:latest $INSTDIR/ $INSTDIR/

RUN echo "===== BUILD RUN HELICS =====" && \
export DEBIAN_FRONTEND=noninteractive && \
Expand Down
14 changes: 2 additions & 12 deletions scripts/docker/Dockerfile.gridlabd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ENV INSTDIR=${TESPDIR}/tenv
ENV GLPATH=$INSTDIR/lib/gridlabd:$INSTDIR/share/gridlabd

# Copy Binaries
# COPY --from=tesp-1.3.0:latest $INSTDIR/ $INSTDIR/
# COPY --from=tesp-build:latest $INSTDIR/ $INSTDIR/

RUN echo "===== BUILD RUN GridLabD =====" && \
export DEBIAN_FRONTEND=noninteractive && \
Expand All @@ -23,14 +23,4 @@ RUN echo "===== BUILD RUN GridLabD =====" && \
# GridLAB-D support libraries
libxerces-c-dev \
libhdf5-serial-dev \
libsuitesparse-dev && \
# protect images by changing root password
echo "root:tesp" | chpasswd && \
echo "<<<< Adding the TESP user >>>>" && \
useradd -m -s /bin/bash ${USER_NAME} && \
echo "<<<< Changing new user password >>>>" && \
echo "${USER_NAME}:${USER_NAME}" | chpasswd && \
usermod -aG sudo ${USER_NAME}

USER ${USER_NAME}
WORKDIR ${USER_HOME}
libsuitesparse-dev
5 changes: 1 addition & 4 deletions scripts/docker/Dockerfile.helics
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ENV PYHELICS_INSTALL=$INSTDIR
ENV PATH=$JAVA_HOME:$INSTDIR/bin:$PATH

# Copy Binaries
COPY --from=tesp-1.3.0:latest $INSTDIR/ $INSTDIR/
COPY --from=tesp-build:latest $INSTDIR/ $INSTDIR/

RUN echo "===== BUILD RUN HELICS =====" && \
export DEBIAN_FRONTEND=noninteractive && \
Expand All @@ -43,6 +43,3 @@ RUN echo "===== BUILD RUN HELICS =====" && \
echo "<<<< Changing new user password >>>>" && \
echo "${USER_NAME}:${USER_NAME}" | chpasswd && \
usermod -aG sudo ${USER_NAME}

USER ${USER_NAME}
WORKDIR ${USER_HOME}
11 changes: 2 additions & 9 deletions scripts/docker/Dockerfile.ns3
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,11 @@ ENV TESPDIR=${USER_HOME}/tesp
ENV INSTDIR=${TESPDIR}/tenv

# Copy Binaries
# COPY --from=tesp-1.3.0:latest $INSTDIR/ $INSTDIR/
# COPY --from=tesp-build:latest $INSTDIR/ $INSTDIR/

RUN echo "===== BUILD RUN NS3 =====" && \
export DEBIAN_FRONTEND=noninteractive && \
export DEBCONF_NONINTERACTIVE_SEEN=true && \
echo "===== Install Libraries =====" && \
apt-get update && \
apt-get dist-upgrade -y && \
# protect images by changing root password
echo "root:tesp" | chpasswd && \
echo "<<<< Adding the TESP user >>>>" && \
useradd -m -s /bin/bash ${USER_NAME} && \
echo "<<<< Changing new user password >>>>" && \
echo "${USER_NAME}:${USER_NAME}" | chpasswd && \
usermod -aG sudo ${USER_NAME}
apt-get dist-upgrade -y
11 changes: 2 additions & 9 deletions scripts/docker/Dockerfile.python
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ENV TESPDIR=${USER_HOME}/tesp
ENV INSTDIR=${TESPDIR}/tenv

# Copy Binaries
# COPY --from=tesp-1.3.0:latest $INSTDIR/ $INSTDIR/
# COPY --from=tesp-build:latest $INSTDIR/ $INSTDIR/

RUN echo "===== BUILD RUN Python =====" && \
export DEBIAN_FRONTEND=noninteractive && \
Expand All @@ -24,11 +24,4 @@ RUN echo "===== BUILD RUN Python =====" && \
python3-tk \
python3-pil.imagetk && \
pip3 install helics > "$TESPDIR/tesp_pypi.log" && \
pip3 install helics[cli] >> "$TESPDIR/tesp_pypi.log" && \
# protect images by changing root password
echo "root:tesp" | chpasswd && \
echo "<<<< Adding the TESP user >>>>" && \
useradd -m -s /bin/bash ${USER_NAME} && \
echo "<<<< Changing new user password >>>>" && \
echo "${USER_NAME}:${USER_NAME}" | chpasswd && \
usermod -aG sudo ${USER_NAME}
pip3 install helics[cli] >> "$TESPDIR/tesp_pypi.log"
19 changes: 6 additions & 13 deletions scripts/docker/Dockerfile.tespapi
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ ENV TESPDIR=${USER_HOME}/tesp
ENV INSTDIR=${TESPDIR}/tenv

# Copy Binaries
# COPY --from=tesp-1.3.0:latest $INSTDIR/ $INSTDIR/
COPY --from=tesp-1.3.0:latest $TESPDIR/requirements.txt $TESPDIR
COPY --from=tesp-1.3.0:latest $TESPDIR/data/ $TESPDIR/data/
COPY --from=tesp-1.3.0:latest $TESPDIR/repository/AMES-V5.0/README.rst $TESPDIR
COPY --from=tesp-1.3.0:latest $TESPDIR/repository/AMES-V5.0/psst/ $TESPDIR/psst/
# COPY --from=tesp-build:latest $INSTDIR/ $INSTDIR/
COPY --from=tesp-build:latest $TESPDIR/requirements.txt $TESPDIR
COPY --from=tesp-build:latest $TESPDIR/data/ $TESPDIR/data/
COPY --from=tesp-build:latest $TESPDIR/repository/AMES-V5.0/README.rst $TESPDIR
COPY --from=tesp-build:latest $TESPDIR/repository/AMES-V5.0/psst/ $TESPDIR/psst/

RUN echo "===== BUILD RUN TESPAPI =====" && \
export DEBIAN_FRONTEND=noninteractive && \
Expand All @@ -30,11 +30,4 @@ RUN echo "===== BUILD RUN TESPAPI =====" && \
# Install Python Libraries
pip3 install -r "$TESPDIR/requirements.txt" > "$TESPDIR/tesp_pypi.log" && \
cd $TESPDIR/psst || exit && \
pip3 install -e . >> "$TESPDIR/tesp_pypi.log" && \
# protect images by changing root password
echo "root:tesp" | chpasswd && \
echo "<<<< Adding the TESP user >>>>" && \
useradd -m -s /bin/bash ${USER_NAME} && \
echo "<<<< Changing new user password >>>>" && \
echo "${USER_NAME}:${USER_NAME}" | chpasswd && \
usermod -aG sudo ${USER_NAME}
pip3 install -e . >> "$TESPDIR/tesp_pypi.log"
2 changes: 1 addition & 1 deletion scripts/docker/build-tesp-image.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


images=(
"tesp-$(cat $TESPDIR/scripts/version):latest"
"tesp-build:latest"
"tesp-helics:latest"
"tesp-gridlabd:latest"
"tesp-eplus:latest"
Expand Down
5 changes: 5 additions & 0 deletions scripts/docker/run-tespDocker.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ DOCKER_NAME="tesp-docker"
#IMAGE_NAME="tesp-python:latest"
IMAGE_NAME="tesp-tespapi:latest"

USER_NAME=worker
USER_HOME=/home/$USER_NAME


clear
docker run -it --rm \
-e LOCAL_USER_ID="$(id -u d3j331)" \
-w=${USER_HOME} \
--name ${DOCKER_NAME} ${IMAGE_NAME} bash
4 changes: 4 additions & 0 deletions src/tesp_support/tesp_support/weather/weather_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def startWeatherAgent(file):
"""
# read the weather data file, arguments to mimic deprecated from_csv function
weatherData = pd.read_csv(file, index_col=0, parse_dates=True)
broker_address = None
config = os.environ['WEATHER_CONFIG'] # read the weather config json file
if os.path.isfile(config):
with open(config, 'r') as stream:
Expand All @@ -46,6 +47,7 @@ def startWeatherAgent(file):
publishTimeAhead = conf['PublishTimeAhead']
forecastPeriod = conf['forecastPeriod']
forecastParameters = conf['parameters']
broker_address = conf['broker_address']
except ValueError as ex:
print(ex)
else:
Expand Down Expand Up @@ -102,6 +104,8 @@ def startWeatherAgent(file):
helics.helicsFederateInfoSetCoreName(fedInfo, fedName)
helics.helicsFederateInfoSetCoreTypeFromString(fedInfo, 'zmq')
helics.helicsFederateInfoSetCoreInitString(fedInfo, '--federates=1')
if broker_address is not None:
helics.helicsFederateInfoSetCoreInitString(fedInfo, '--broker_address=' + broker_address)
helics.helicsFederateInfoSetTimeProperty(fedInfo, helics.helics_property_time_delta, timeDeltaInSeconds)
hFed = helics.helicsCreateValueFederate(fedName, fedInfo)
for col in weatherData.columns:
Expand Down

0 comments on commit 9f67735

Please sign in to comment.