From 9f67735c3dacfb95989307fea3c512be24019ad0 Mon Sep 17 00:00:00 2001 From: d3j331 Date: Thu, 30 Nov 2023 13:06:40 -0800 Subject: [PATCH] Update docker files --- examples/capabilities/te30/eplus.json | 1 + examples/capabilities/te30/eplus_agent.json | 1 + examples/capabilities/te30/pypower.json | 1 + scripts/docker/Dockerfile | 11 +++++------ scripts/docker/Dockerfile.eplus | 12 +++--------- scripts/docker/Dockerfile.fncs | 2 +- scripts/docker/Dockerfile.gridlabd | 14 ++------------ scripts/docker/Dockerfile.helics | 5 +---- scripts/docker/Dockerfile.ns3 | 11 ++--------- scripts/docker/Dockerfile.python | 11 ++--------- scripts/docker/Dockerfile.tespapi | 19 ++++++------------- scripts/docker/build-tesp-image.sh | 2 +- scripts/docker/run-tespDocker.sh | 5 +++++ .../tesp_support/weather/weather_agent.py | 4 ++++ 14 files changed, 35 insertions(+), 64 deletions(-) mode change 100644 => 100755 scripts/docker/build-tesp-image.sh mode change 100644 => 100755 scripts/docker/run-tespDocker.sh diff --git a/examples/capabilities/te30/eplus.json b/examples/capabilities/te30/eplus.json index dff1444c..b4d81ada 100644 --- a/examples/capabilities/te30/eplus.json +++ b/examples/capabilities/te30/eplus.json @@ -1,5 +1,6 @@ { "name": "eplus", + "broker_address": "10.5.0.2", "period": 300, "logging": "warning", "publications": [ diff --git a/examples/capabilities/te30/eplus_agent.json b/examples/capabilities/te30/eplus_agent.json index 483ef771..1d042ba7 100644 --- a/examples/capabilities/te30/eplus_agent.json +++ b/examples/capabilities/te30/eplus_agent.json @@ -1,5 +1,6 @@ { "name": "eplus_agent", + "broker_address": "10.5.0.2", "period": 300, "logging": "warning", "time_delta": 1, diff --git a/examples/capabilities/te30/pypower.json b/examples/capabilities/te30/pypower.json index 9feefcbb..b74e1413 100644 --- a/examples/capabilities/te30/pypower.json +++ b/examples/capabilities/te30/pypower.json @@ -1,5 +1,6 @@ { "name": "pypower", + "brokeraddress": "10.5.0.2", "period": 15, "logging": "warning", "publications": [ diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile index 705bb059..2bb20702 100644 --- a/scripts/docker/Dockerfile +++ b/scripts/docker/Dockerfile @@ -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}" && \ diff --git a/scripts/docker/Dockerfile.eplus b/scripts/docker/Dockerfile.eplus index 210bdbc2..c03d5c2e 100644 --- a/scripts/docker/Dockerfile.eplus +++ b/scripts/docker/Dockerfile.eplus @@ -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} \ No newline at end of file + apt-get dist-upgrade -y diff --git a/scripts/docker/Dockerfile.fncs b/scripts/docker/Dockerfile.fncs index 0cdde503..45c56b53 100644 --- a/scripts/docker/Dockerfile.fncs +++ b/scripts/docker/Dockerfile.fncs @@ -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 && \ diff --git a/scripts/docker/Dockerfile.gridlabd b/scripts/docker/Dockerfile.gridlabd index 4f08b528..6b6c2358 100644 --- a/scripts/docker/Dockerfile.gridlabd +++ b/scripts/docker/Dockerfile.gridlabd @@ -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 && \ @@ -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} \ No newline at end of file + libsuitesparse-dev diff --git a/scripts/docker/Dockerfile.helics b/scripts/docker/Dockerfile.helics index 0cdde503..6bd24f87 100644 --- a/scripts/docker/Dockerfile.helics +++ b/scripts/docker/Dockerfile.helics @@ -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 && \ @@ -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} \ No newline at end of file diff --git a/scripts/docker/Dockerfile.ns3 b/scripts/docker/Dockerfile.ns3 index 11f23497..34a49c12 100644 --- a/scripts/docker/Dockerfile.ns3 +++ b/scripts/docker/Dockerfile.ns3 @@ -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} \ No newline at end of file + apt-get dist-upgrade -y diff --git a/scripts/docker/Dockerfile.python b/scripts/docker/Dockerfile.python index 52bdc373..dc374cbd 100644 --- a/scripts/docker/Dockerfile.python +++ b/scripts/docker/Dockerfile.python @@ -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 && \ @@ -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} \ No newline at end of file + pip3 install helics[cli] >> "$TESPDIR/tesp_pypi.log" diff --git a/scripts/docker/Dockerfile.tespapi b/scripts/docker/Dockerfile.tespapi index 96e55cd7..52dd2d6f 100644 --- a/scripts/docker/Dockerfile.tespapi +++ b/scripts/docker/Dockerfile.tespapi @@ -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 && \ @@ -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" diff --git a/scripts/docker/build-tesp-image.sh b/scripts/docker/build-tesp-image.sh old mode 100644 new mode 100755 index 70436e84..43dbecbe --- a/scripts/docker/build-tesp-image.sh +++ b/scripts/docker/build-tesp-image.sh @@ -2,7 +2,7 @@ images=( - "tesp-$(cat $TESPDIR/scripts/version):latest" + "tesp-build:latest" "tesp-helics:latest" "tesp-gridlabd:latest" "tesp-eplus:latest" diff --git a/scripts/docker/run-tespDocker.sh b/scripts/docker/run-tespDocker.sh old mode 100644 new mode 100755 index d1c5d9df..cfbc96e4 --- a/scripts/docker/run-tespDocker.sh +++ b/scripts/docker/run-tespDocker.sh @@ -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 \ No newline at end of file diff --git a/src/tesp_support/tesp_support/weather/weather_agent.py b/src/tesp_support/tesp_support/weather/weather_agent.py index feb07167..1f1cfb63 100644 --- a/src/tesp_support/tesp_support/weather/weather_agent.py +++ b/src/tesp_support/tesp_support/weather/weather_agent.py @@ -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: @@ -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: @@ -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: