Skip to content

Commit

Permalink
Merge pull request #133 from pnnl/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
d3j331 authored Dec 7, 2023
2 parents 480ce11 + 53d6b6b commit 1dcd35e
Show file tree
Hide file tree
Showing 16 changed files with 232 additions and 56 deletions.
2 changes: 1 addition & 1 deletion scripts/build/stamp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if [[ -z ${INSTDIR} ]]; then
. "${HOME}/tespEnv"
fi

ver="1.3.3"
ver="1.3.5"

echo
echo "Stamping TESP $ver, if you want to change the version, edit this file."
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/tesp_pypi.id
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ tables 3.8.0
tabulate 0.9.0
tenacity 8.2.3
termcolor 2.3.0
tesp-support 1.3.2 /home/tesp/tesp/repository/tesp/src/tesp_support
tesp-support 1.3.5 /home/tesp/tesp/repository/tesp/src/tesp_support
text-unidecode 1.3
threadpoolctl 3.2.0
tomli 2.0.1
Expand Down
4 changes: 2 additions & 2 deletions scripts/docker/Dockerfile.eplus
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ FROM tesp-helics:latest AS tesp-run
# TESP user name and work directory
ENV USER_NAME=worker
ENV USER_HOME=/home/$USER_NAME
ENV TESPDIR=${USER_HOME}/tesp
ENV INSTDIR=${TESPDIR}/tenv
ENV TESPDIR=$USER_HOME/tesp
ENV INSTDIR=$TESPDIR/tenv

# PATH
ENV PATH=$PATH:$INSTDIR/energyplus
Expand Down
6 changes: 3 additions & 3 deletions scripts/docker/Dockerfile.fncs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Delcare arguments
# Declare arguments
ARG UBUNTU=ubuntu
ARG UBUNTU_VERSION=:20.04

Expand All @@ -8,8 +8,8 @@ FROM ${UBUNTU}${UBUNTU_VERSION} AS tesp-run
# TESP user name and work directory
ENV USER_NAME=worker
ENV USER_HOME=/home/$USER_NAME
ENV TESPDIR=${USER_HOME}/tesp
ENV INSTDIR=${TESPDIR}/tenv
ENV TESPDIR=$USER_HOME/tesp
ENV INSTDIR=$TESPDIR/tenv

# Compile exports
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
Expand Down
4 changes: 2 additions & 2 deletions scripts/docker/Dockerfile.gridlabd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ FROM tesp-helics:latest AS tesp-run
# TESP user name and work directory
ENV USER_NAME=worker
ENV USER_HOME=/home/$USER_NAME
ENV TESPDIR=${USER_HOME}/tesp
ENV INSTDIR=${TESPDIR}/tenv
ENV TESPDIR=$USER_HOME/tesp
ENV INSTDIR=$TESPDIR/tenv

# Compile exports
ENV GLPATH=$INSTDIR/lib/gridlabd:$INSTDIR/share/gridlabd
Expand Down
6 changes: 3 additions & 3 deletions scripts/docker/Dockerfile.helics
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Delcare arguments
# Declare arguments
ARG UBUNTU=ubuntu
ARG UBUNTU_VERSION=:20.04

Expand All @@ -8,8 +8,8 @@ FROM ${UBUNTU}${UBUNTU_VERSION} AS tesp-run
# TESP user name and work directory
ENV USER_NAME=worker
ENV USER_HOME=/home/$USER_NAME
ENV TESPDIR=${USER_HOME}/tesp
ENV INSTDIR=${TESPDIR}/tenv
ENV TESPDIR=$USER_HOME/tesp
ENV INSTDIR=$TESPDIR/tenv

# Compile exports
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
Expand Down
4 changes: 2 additions & 2 deletions scripts/docker/Dockerfile.ns3
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ FROM tesp-helics:latest AS tesp-run
# TESP user name and work directory
ENV USER_NAME=worker
ENV USER_HOME=/home/$USER_NAME
ENV TESPDIR=${USER_HOME}/tesp
ENV INSTDIR=${TESPDIR}/tenv
ENV TESPDIR=$USER_HOME/tesp
ENV INSTDIR=$TESPDIR/tenv

# Copy Binaries
# COPY --from=tesp-build:latest $INSTDIR/ $INSTDIR/
Expand Down
4 changes: 2 additions & 2 deletions scripts/docker/Dockerfile.python
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ FROM tesp-helics:latest AS tesp-run
# TESP user name and work directory
ENV USER_NAME=worker
ENV USER_HOME=/home/$USER_NAME
ENV TESPDIR=${USER_HOME}/tesp
ENV INSTDIR=${TESPDIR}/tenv
ENV TESPDIR=$USER_HOME/tesp
ENV INSTDIR=$TESPDIR/tenv

# Copy Binaries
# COPY --from=tesp-build:latest $INSTDIR/ $INSTDIR/
Expand Down
6 changes: 3 additions & 3 deletions scripts/docker/Dockerfile.tespapi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ FROM tesp-python:latest AS tesp-run
# TESP user name and work directory
ENV USER_NAME=worker
ENV USER_HOME=/home/$USER_NAME
ENV TESPDIR=${USER_HOME}/tesp
ENV INSTDIR=${TESPDIR}/tenv
ENV TESPDIR=$USER_HOME/tesp
ENV INSTDIR=$TESPDIR/tenv

# Copy Binaries
# COPY --from=tesp-build:latest $INSTDIR/ $INSTDIR/
Expand All @@ -14,7 +14,7 @@ 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 =====" && \
RUN echo "===== BUILD RUN TESP API =====" && \
export DEBIAN_FRONTEND=noninteractive && \
export DEBCONF_NONINTERACTIVE_SEEN=true && \
echo "===== Install Libraries =====" && \
Expand Down
6 changes: 3 additions & 3 deletions scripts/tespEnv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
. $HOME/tesp/venv/bin/activate
. $HOME/.tvenv/bin/activate

# TESP exports
export TESPDIR=$HOME/tesp
export INSTDIR=$HOME/tesp/tenv
export REPODIR=$HOME/tesp/repository
export INSTDIR=$TESPDIR/tenv
export REPODIR=$TESPDIR/repository
export TESPBUILD=$TESPDIR/scripts/build
export TESPHELPR=$TESPDIR/scripts/helpers

Expand Down
88 changes: 88 additions & 0 deletions scripts/tespInstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash

echo
echo "Install git and python, must be installed for other components"
sudo apt-get -y upgrade
sudo apt-get -y install git python3-venv python3-pip python3-tk python3-pil.imagetk

echo
if [[ -z $1 && -z $2 ]]; then
echo "No user name set for git repositories!"
else
git config --global user.name "$1"
git config --global user.email "$2"
echo "User .name=$1 and .email=$2 have been set for git repositories!"
fi
git config --global credential.helper store

echo
if [[ -z $3 ]]; then
WORKDIR=$HOME/tesp
else
WORKDIR=$HOME/$3
fi
echo "Install TESP home directory"
echo "TESP home dirctory is $WORKDIR"

cat > "$HOME/tespEnv" << EOF
. $HOME/.tvenv/bin/activate
# TESP exports
export TESPDIR=$WORKDIR
export INSTDIR=\$TESPDIR/tenv
export REPODIR=\$TESPDIR/repository
export TESPBUILD=\$TESPDIR/scripts/build
export TESPHELPR=\$TESPDIR/scripts/helpers
# COMPILE exports
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PYHELICS_INSTALL=\$INSTDIR
export GLPATH=\$INSTDIR/lib/gridlabd:\$INSTDIR/share/gridlabd
export CPLUS_INCLUDE_PATH=/usr/include/hdf5/serial:\$INSTDIR/include
export FNCS_INCLUDE_DIR=\$INSTDIR/include
export FNCS_LIBRARY=\$INSTDIR/lib
export LD_LIBRARY_PATH=\$INSTDIR/lib
export LD_RUN_PATH=\$INSTDIR/lib
# export BENCH_PROFILE=1
# PATH
export PATH=\$INSTDIR/bin:\$PATH
export PATH=\$JAVA_HOME:\$PATH
export PATH=\$PATH:\$INSTDIR/energyplus
export PATH=\$PATH:\$INSTDIR/energyplus/PreProcess
export PATH=\$PATH:\$INSTDIR/energyplus/PostProcess
export PATH=\$PATH:\$TESPHELPR
# PSST environment variables
export PSST_SOLVER=cbc
# 'PSST_SOLVER path' -- one of "cbc", "ipopt", "/ibm/cplex/bin/x86-64_linux/cplexamp"
export PSST_WARNING=ignore
# 'PSST_WARNING action' -- one of "error", "ignore", "always", "default", "module", or "once"
# PROXY export if needed
# export HTTPS_PROXY=http://proxy01.pnl.gov:3128
EOF

echo
echo "Install a virtual python environment to $HOME/.tvenv"
python3 -m pip install --upgrade pip
python3 -m pip install virtualenv
python3 -m venv "$HOME/.tvenv" --prompt TESP

source "$HOME/tespEnv"

echo "Installing Python Libraries..."
which python > "$HOME/tesp.log" 2>&1
pip install --upgrade pip >> "$HOME/tesp.log" 2>&1

echo "Installing TESP empty repo..."
git clone --no-checkout https://github.com/pnnl/tesp "$TESPDIR"
cd "$TESPDIR" || exit

echo "Installing Python Libraries..."
git checkout HEAD requirements.txt
pip install -r "$TESPDIR/requirements.txt" >> "$HOME/tesp.log" 2>&1

echo "Installing Python TESP API..."
pip install tesp_support >> "$HOME/tesp.log" 2>&1

49 changes: 49 additions & 0 deletions scripts/tespPip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

git checkout HEAD requirements.txt
pip install -r "$HOME/tesp/requirements.txt" >> "$HOME/tesp.log"

if [[ -z $VIRTUAL_ENV ]]; then
VIRTUAL=""
else
VIRTUAL=$VIRTUAL_ENV/bin/activate
fi

cat >> "$HOME/tespEnv" << EOF
$VIRTUAL
# TESP exports
export TESPDIR=$HOME/tesp
export INSTDIR=\$TESPDIR/tenv
export REPODIR=\$TESPDIR/repository
export TESPBUILD=\$TESPDIR/scripts/build
export TESPHELPR=\$TESPDIR/scripts/helpers
# COMPILE exports
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PYHELICS_INSTALL=\$INSTDIR
export GLPATH=\$INSTDIR/lib/gridlabd:\$INSTDIR/share/gridlabd
export CPLUS_INCLUDE_PATH=/usr/include/hdf5/serial:\$INSTDIR/include
export FNCS_INCLUDE_DIR=\$INSTDIR/include
export FNCS_LIBRARY=\$INSTDIR/lib
export LD_LIBRARY_PATH=\$INSTDIR/lib
export LD_RUN_PATH=\$INSTDIR/lib
# export BENCH_PROFILE=1
# PATH
export PATH=\$INSTDIR/bin:\$PATH
export PATH=\$JAVA_HOME:\$PATH
export PATH=\$PATH:\$INSTDIR/energyplus
export PATH=\$PATH:\$INSTDIR/energyplus/PreProcess
export PATH=\$PATH:\$INSTDIR/energyplus/PostProcess
export PATH=\$PATH:\$TESPHELPR
# PSST environment variables
export PSST_SOLVER=cbc
# 'PSST_SOLVER path' -- one of "cbc", "ipopt", "/ibm/cplex/bin/x86-64_linux/cplexamp"
export PSST_WARNING=ignore
# 'PSST_WARNING action' -- one of "error", "ignore", "always", "default", "module", or "once"
# PROXY export if needed
# export HTTPS_PROXY=http://proxy01.pnl.gov:3128
EOF
2 changes: 1 addition & 1 deletion scripts/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.3
1.3.5
37 changes: 20 additions & 17 deletions src/tesp_support/tesp_support/api/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""Path and Data functions for use within tesp_support.
"""

from os import path, chdir, mkdir, environ
from os import path, chdir, environ
from importlib_resources import files
import argparse
import subprocess
Expand Down Expand Up @@ -34,6 +34,8 @@

# uncomment for debug
# tesp_path = path.expanduser('~') + '/tesp'
# chdir(tesp_path)
# tesp_path = path.expanduser('~') + '/tesp/tesp'

if path.isdir(tesp_path):
for _dir in components:
Expand All @@ -47,11 +49,17 @@
else:
# New instance
try:
mkdir(tesp_path)
# print("Writing the TESP setting config file -> " + tesp_path)
# make_settings(tesp_path)
chdir(path.expanduser('~'))
cmd = 'git clone --no-checkout https://github.com/pnnl/tesp'
subprocess.Popen(cmd, shell=True).wait()
chdir(tesp_path)
cmd = 'git checkout HEAD scripts/tespPip.sh'
subprocess.Popen(cmd, shell=True).wait()
chdir('scripts')
cmd = './tespPip.sh'
subprocess.Popen(cmd, shell=True).wait()
except FileExistsError:
print("Can NOT write the TESP setting config file -> " + tesp_path)
print("Can NOT write the TESP configure files -> " + tesp_path)
pass


Expand Down Expand Up @@ -129,26 +137,21 @@ def tesp_component():
if error:
return

parcel = ["svn", "checkout", "https://github.com/pnnl/tesp/trunk/"]

parcel = ['git', 'checkout', 'HEAD']
choice = int(args.component[0])
if 9 > choice > 0:
parcel[2] = parcel[2] + components[choice]
print("Component ->", parcel[2])
parcel.append(components[choice])
print("Component ->", parcel[-1])
else:
print("Bad choice, choose 1 through 9")
return

tmp = tesp_path + '/' + components[choice]
if path.isdir(tmp):
print("It seems we have a copy of " + tmp)
component = tesp_path + '/' + components[choice]
if path.isdir(component):
print("It seems we have a copy of " + component)
return

# can proceed with the copy
chdir(tesp_path)
p = subprocess.Popen(parcel, shell=False)
p.wait()
line = ["rm", "-rf", components[choice] + "/.svn"]
p = subprocess.Popen(line, shell=False)
p.wait()
subprocess.Popen(parcel, shell=False).wait()
print('Output directory: ', tesp_path + "/" + components[choice])
Loading

0 comments on commit 1dcd35e

Please sign in to comment.