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

Framework as package #1784

Merged
merged 21 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f34da94
Converting main raven framework to using framework as a package.
joshua-cogliati-inl Mar 7, 2022
10a8ef5
Switching test harness to framework as a package.
joshua-cogliati-inl Mar 7, 2022
c7fd7d2
Switching tests to using framework as a package.
joshua-cogliati-inl Mar 7, 2022
94d3344
Switching ExamplePlugin to support framework as a package.
joshua-cogliati-inl Mar 7, 2022
29b4c6c
Print better debugging information when Testers or Differs fail.
joshua-cogliati-inl Mar 7, 2022
893c75d
Adding setuptools to dependency list.
joshua-cogliati-inl Mar 7, 2022
9e6c793
Switching to framework as a package.
joshua-cogliati-inl Mar 7, 2022
9f37680
Adding license for raven_framework.py
joshua-cogliati-inl Mar 7, 2022
c80c840
Moving framework to ravenframework
joshua-cogliati-inl Mar 15, 2022
0b570f5
Converting to ravenframework
joshua-cogliati-inl Mar 15, 2022
1522da8
Removing unneeded commented out lines.
joshua-cogliati-inl Mar 16, 2022
046457e
Converting to ravenframework
joshua-cogliati-inl Mar 15, 2022
03d3739
Updating pickle to ravenframework.
joshua-cogliati-inl Mar 15, 2022
137cf9a
Fixing crow tests.
joshua-cogliati-inl Mar 15, 2022
4dc241e
Fixing more tests.
joshua-cogliati-inl Mar 15, 2022
6cce8a0
Fixing building doc.
joshua-cogliati-inl Mar 15, 2022
00cac1f
Fixing cluster tests.
joshua-cogliati-inl Mar 15, 2022
6f224ad
Updating .gitignore.
joshua-cogliati-inl Mar 16, 2022
5475d00
Fix whitespace.
joshua-cogliati-inl Mar 16, 2022
b3751db
Adding missing __init__.py files.
joshua-cogliati-inl Mar 15, 2022
6d79372
Updating documents for new framework directory.
joshua-cogliati-inl Mar 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ build/
.failed_tests
.ravenrc
*.ravenStatus
install/
src/crow_modules/distribution1D.py
src/crow_modules/distribution1D_wrap.cpp
src/crow_modules/interpolationND.py
src/crow_modules/interpolationND_wrap.cpp
src/crow_modules/randomENG.py
src/crow_modules/randomENG_wrap.cpp
build_out*
test_out*
framework/contrib/PythonFMU/pythonfmu.egg-info/
raven_framework.egg-info/
raven_framework*.whl

# eclipse
.project
Expand Down
10 changes: 7 additions & 3 deletions build_raven
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RAVEN_BUILD_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# source read ravenrc script
RAVEN_RC_SCRIPT=$RAVEN_BUILD_DIR/scripts/read_ravenrc.sh
RAVEN_RC_SCRIPT="${RAVEN_RC_SCRIPT//\\//}"
PYTHON_FMU_DIR="$RAVEN_BUILD_DIR/framework/contrib/PythonFMU"
PYTHON_FMU_DIR="$RAVEN_BUILD_DIR/ravenframework/contrib/PythonFMU"
PYTHON_FMU_DIR="${PYTHON_FMU_DIR//\\//}"
source $RAVEN_RC_SCRIPT

Expand Down Expand Up @@ -107,6 +107,10 @@ fi
PIP_COMMAND=pip3
(cd $RAVEN_BUILD_DIR && ${PIP_COMMAND} --verbose install . --upgrade --target ./install)

#pip install will add a duplicate ravenframework directory, so delete so there isn't
# confusion over which of the two copies to use.
(cd $RAVEN_BUILD_DIR && rm -Rf install/ravenframework)

(cd $PYTHON_FMU_DIR && ./build_pythonfmu || echo PythonFMU build failed)

if [ ! -z "$RAVEN_SIGNATURE" ];
Expand All @@ -117,8 +121,8 @@ then
# https://developer.apple.com/library/archive/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html
# RAVEN_SIGNATURE can be added to .ravenrc
echo "... Signing code with '$RAVEN_SIGNATURE' ..."
(cd $CROW_DIR/install/crow_modules && pwd && codesign -s "$RAVEN_SIGNATURE" -v *.so)
(cd $RAVEN_BUILD_DIR/framework/contrib/AMSC && pwd && codesign -s "$RAVEN_SIGNATURE" -v *.so)
(cd $RAVEN_BUILD_DIR/install/crow_modules && pwd && codesign -s "$RAVEN_SIGNATURE" -v *.so)
(cd $RAVEN_BUILD_DIR/install/AMSC && pwd && codesign -s "$RAVEN_SIGNATURE" -v *.so)
fi

echo ... done!
14 changes: 7 additions & 7 deletions clean_raven
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
RAVEN_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CROW_DIR=${RAVEN_DIR}/crow

rm -f ${RAVEN_DIR}/framework/contrib/AMSC/_amsc*.so \
${RAVEN_DIR}/framework/contrib/AMSC/amsc*egg-info \
${RAVEN_DIR}/framework/contrib/AMSC/amsc.py \
${RAVEN_DIR}/framework/contrib/AMSC/amsc.pyc \
rm -f ${RAVEN_DIR}/ravenframework/contrib/AMSC/_amsc*.so \
${RAVEN_DIR}/ravenframework/contrib/AMSC/amsc*egg-info \
${RAVEN_DIR}/ravenframework/contrib/AMSC/amsc.py \
${RAVEN_DIR}/ravenframework/contrib/AMSC/amsc.pyc \
${RAVEN_DIR}/src/contrib/amsc_wrap.cxx \
${RAVEN_DIR}/src/contrib/amsc_wrap.cpp \
${RAVEN_DIR}/src/contrib/amsc.py \
${RAVEN_DIR}/src/contrib/amsc.pyc
rm -Rf ${RAVEN_DIR}/build \
${RAVEN_DIR}/crow/install/ \
${RAVEN_DIR}/install/
find ${RAVEN_DIR}/framework -name '*.pyc' -exec rm '{}' \;
find ${RAVEN_DIR}/ravenframework -name '*.pyc' -exec rm '{}' \;
find ${RAVEN_DIR}/scripts -name '*.pyc' -exec rm '{}' \;
find ${RAVEN_DIR}/rook -name '*.pyc' -exec rm '{}' \;
find ${RAVEN_DIR}/tests -name '*.pyc' -exec rm '{}' \;
find ${RAVEN_DIR}/plugins -name '*.pyc' -exec rm '{}' \;
find ${RAVEN_DIR}/framework -name '*.pyo' -exec rm '{}' \;
find ${RAVEN_DIR}/ravenframework -name '*.pyo' -exec rm '{}' \;
find ${RAVEN_DIR}/scripts -name '*.pyo' -exec rm '{}' \;
find ${RAVEN_DIR}/rook -name '*.pyo' -exec rm '{}' \;
find ${RAVEN_DIR}/tests -name '*.pyo' -exec rm '{}' \;
find ${RAVEN_DIR}/plugins -name '*.pyo' -exec rm '{}' \;
find ${RAVEN_DIR}/framework -name '__pycache__' -exec rm -Rf '{}' \;
find ${RAVEN_DIR}/ravenframework -name '__pycache__' -exec rm -Rf '{}' \;
find ${RAVEN_DIR}/scripts -name '__pycache__' -exec rm -Rf '{}' \;
find ${RAVEN_DIR}/rook -name '__pycache__' -exec rm -Rf '{}' \;
find ${RAVEN_DIR}/tests -name '__pycache__' -exec rm -Rf '{}' \;
Expand Down
1 change: 1 addition & 0 deletions dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Note all install methods after "main" take
<pywavelets optional='True'>1.1</pywavelets>
<fmpy optional='True'/>
<xmlschema source="pip"/>
<setuptools/>
</main>
<alternate name="pip">
<hdf5>remove</hdf5>
Expand Down
4 changes: 2 additions & 2 deletions doc/user_guide/HowToRun.tex
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ \section{Running RAVEN}
After following the instructions in the previous Section, RAVEN is ready to be
used.
%
The RAVEN driver is contained in the folder ``\texttt{raven/framework}.''
The RAVEN driver is contained in the folder ``\texttt{raven}.''
%
To run RAVEN, open a terminal and use the following command (replace \texttt{inputFileName.xml} with your RAVEN input file):

\begin{lstlisting}[language=bash]
python raven/framework/Driver.py inputFileName.xml
python raven/raven_framework.py inputFileName.xml
\end{lstlisting}

Alternatively, the \texttt{raven\_framework} script can be used. In this case, the command is:
Expand Down
6 changes: 3 additions & 3 deletions doc/user_guide/introduction.tex
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ \subsection{Acquiring and Installing RAVEN}
\begin{lstlisting}[language=bash]
raven_framework <inputFileName.xml>
\end{lstlisting}
where the \texttt{raven\_framework} script can be found in the RAVEN folder. Alternatively, the \texttt{Driver.py} script
contained in the folder ``\texttt{raven/framework}'' can be directly used:
where the \texttt{raven\_framework} script can be found in the RAVEN folder. Alternatively, the \texttt{raven\_framework.py} script
contained in the folder ``\texttt{raven}'' can be directly used:
\begin{lstlisting}[language=bash]
python raven/framework/Driver.py <inputFileName.xml>
python raven/raven_framework.py <inputFileName.xml>
\end{lstlisting}
\item \textit{Participate in RAVEN user communities}
\\ Join RAVEN mail lists to get help and updates of RAVEN: \url{https://groups.google.com/forum/#!forum/inl-raven-users}.
Expand Down
4 changes: 2 additions & 2 deletions doc/user_guide/writeTex.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import sys, os, time
import xml.etree.ElementTree as ET
#load XML navigation tools
sys.path.append(os.path.join(os.getcwd(),'..','..','framework'))
from utils import xmlUtils
sys.path.append(os.path.join(os.getcwd(),'..','..'))
from ravenframework.utils import xmlUtils

def getNode(fname,nodepath):
"""
Expand Down
2 changes: 1 addition & 1 deletion doc/user_manual/HowToRun.tex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ \section{Running RAVEN}

Using \texttt{raven\_framework} is the recommended way to run RAVEN. In the event bypassing the typical
environment loading and checks is desired, it can also be run via
the \texttt{Driver.py} script using python, with the input file as argument. However, this is not
the \texttt{raven\_framework.py} script using python, with the input file as argument. However, this is not
recommended, as it will use whatever default versions of Python and other libraries are discovered, rather
than the matching libraries set up during installation.

Expand Down
2 changes: 1 addition & 1 deletion doc/user_manual/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LIB_FILES = ../../scripts/library_handler.py ../../dependencies.xml
all: raven_user_manual.pdf

raven_user_manual.pdf: $(MANUAL_FILES) ../version.tex conda_command.txt pip_commands.txt
pdflatex $(LATEX_FLAGS) $(SRCFILE).tex
pdflatex $(LATEX_FLAGS) $(SRCFILE).tex || echo expected to fail
bibtex $(SRCFILE)
pdflatex $(LATEX_FLAGS) $(SRCFILE).tex
pdflatex $(LATEX_FLAGS) $(SRCFILE).tex
Expand Down
4 changes: 2 additions & 2 deletions doc/user_manual/couplingAcode.tex
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ \subsection{Code Interface Creation}
\\ When loading a ``Code Interface'', RAVEN expects to find, in the class representing the code,
the following required methods:
\begin{lstlisting}[language=python]
from CodeInterfaceBaseClass import CodeInterfaceBase
from ravenframework.CodeInterfaceBaseClass import CodeInterfaceBase
class NewCode(CodeInterfaceBase):
def generateCommand(self, inputFiles, executable, clargs=None, fargs=None, preExec=None)
def createNewInput(self, currentInputFiles, oriInputFiles,
samplerType, **Kwargs)
\end{lstlisting}
In addition, the following optional methods can be specified:
\begin{lstlisting}[language=python]
from CodeInterfaceBaseClass import CodeInterfaceBase
from ravenframework.CodeInterfaceBaseClass import CodeInterfaceBase
class NewCode(CodeInterfaceBase):
...
def initialize(self, runInfoDict, oriInputFiles)
Expand Down
10 changes: 5 additions & 5 deletions doc/user_manual/generated/generateOptimizerDoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
# get driver and path and import it, to get RAVEN paths correct
import os
import sys
ravenFramework = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'framework'))
sys.path.append(ravenFramework)
ravenDir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
sys.path.append(ravenDir)
try:
import Driver
import ravenframework.Driver
except Exception as e:
print('\nWe did not find the modules needed for RAVEN; maybe the conda env is not activated?')
raise e
sys.path.pop()

from utils.InputData import wrapText
from ravenframework.utils.InputData import wrapText

def insertSolnExport(tex, obj):
"""
Expand Down Expand Up @@ -219,7 +219,7 @@ def insertSolnExport(tex, obj):
#------------#
# OPTIMIZERS #
#------------#
import Optimizers
from ravenframework import Optimizers
msg = ''
# base classes first
optDescr = wrapText(Optimizers.Optimizer.userManualDescription(), ' ')
Expand Down
12 changes: 6 additions & 6 deletions doc/user_manual/generated/generateRomDoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
# get driver and path and import it, to get RAVEN paths correct
import os
import sys
ravenFramework = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'framework'))
sys.path.append(ravenFramework)
ravenDir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
sys.path.append(ravenDir)
try:
import Driver
import ravenframework.Driver
except Exception as e:
print('\nWe did not find the modules needed for RAVEN; maybe the conda env is not activated?')
raise e
sys.path.pop()

from utils.InputData import wrapText
from ravenframework.utils.InputData import wrapText

# examples
ndSpline = r"""
Expand Down Expand Up @@ -737,8 +737,8 @@
\end{itemize}
"""

import SupervisedLearning
from SupervisedLearning import ScikitLearnBase
from ravenframework import SupervisedLearning
from ravenframework.SupervisedLearning import ScikitLearnBase
excludeObj = ['SupervisedLearning',
'ScikitLearnBase',
'KerasBase',
Expand Down
6 changes: 3 additions & 3 deletions doc/user_manual/runInfo.tex
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ \subsection{RunInfo: Example Cluster Usage}
module load raven-devel-gcc

#Start Raven
python ../../framework/Driver.py test_mpi.xml
python ../../raven_framework.py test_mpi.xml
\end{lstlisting}

Alternatively, RAVEN can be asked to submit the qsub directory. With
Expand All @@ -472,7 +472,7 @@ \subsection{RunInfo: Example Cluster Usage}
In this case, the command run from the cluster submit node:

\begin{lstlisting}[language=bash]
python ../../framework/Driver.py test_mpiqsub_local.xml
python ../../raven_framework.py test_mpiqsub_local.xml
\end{lstlisting}

%\begin{itemize}
Expand Down Expand Up @@ -580,7 +580,7 @@ \subsection{RunInfo: Advanced Users}
overridden:

\begin{lstlisting}[language=python]
import Simulation
from ravenframework import Simulation
class NewMode(Simulation.SimulationMode):
def remoteRunCommand(self, runInfoDict):
# If it returns a dictionary, then run the command in args
Expand Down
6 changes: 3 additions & 3 deletions doc/workshop/forwardSampling/Inputs/AssembleTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import os
import sys
import copy
frameworkPath = os.path.join(os.path.dirname(__file__), *['..']*4, 'framework')
sys.path.append(frameworkPath)
from utils import xmlUtils
ravenPath = os.path.join(os.path.dirname(__file__), *['..']*4,)
sys.path.append(ravenPath)
from ravenframework.utils import xmlUtils

def write1():
"""
Expand Down
7 changes: 7 additions & 0 deletions plugins/ExamplePlugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tests/interfacedPostProcessor/PrintHistorySet_dump.xml
tests/interfacedPostProcessor/PrintPPHistorySet_dump.xml
tests/interfacedPostProcessorParallel/DatabaseStorage/
tests/interfacedPostProcessorParallel/PrintHistorySet_dump.xml
tests/interfacedPostProcessorParallel/PrintPPHistorySet_dump.xml
tests/interfacedPostProcessor_PointSet/PrintPPPointSetSet_dump.xml
tests/interfacedPostProcessor_PointSet/PrintPointSet_dump.xml
2 changes: 1 addition & 1 deletion plugins/ExamplePlugin/src/CorrelationPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import matplotlib.pyplot as plt

from PluginBaseClasses.OutStreamPlotPlugin import PlotPlugin, InputTypes, InputData
from ravenframework.PluginBaseClasses.OutStreamPlotPlugin import PlotPlugin, InputTypes, InputData


class Correlation(PlotPlugin):
Expand Down
4 changes: 2 additions & 2 deletions plugins/ExamplePlugin/src/LinearROM.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import numpy as np
from scipy import interpolate

from PluginBaseClasses.SupervisedLearningPlugin import SupervisedLearningPlugin
from utils import InputData, InputTypes
from ravenframework.PluginBaseClasses.SupervisedLearningPlugin import SupervisedLearningPlugin
from ravenframework.utils import InputData, InputTypes

class LinearROM(SupervisedLearningPlugin):
"""
Expand Down
2 changes: 1 addition & 1 deletion plugins/ExamplePlugin/src/SumOfExponential.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import math

from PluginBaseClasses.ExternalModelPluginBase import ExternalModelPluginBase
from ravenframework.PluginBaseClasses.ExternalModelPluginBase import ExternalModelPluginBase


class SumOfExponential(ExternalModelPluginBase):
Expand Down
4 changes: 2 additions & 2 deletions plugins/ExamplePlugin/src/testInterfacedPP.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import copy
import numpy as np

from PluginBaseClasses.PostProcessorPluginBase import PostProcessorPluginBase
from utils import InputData, InputTypes
from ravenframework.PluginBaseClasses.PostProcessorPluginBase import PostProcessorPluginBase
from ravenframework.utils import InputData, InputTypes

class testInterfacedPP(PostProcessorPluginBase):
""" This class represents the most basic interfaced post-processor
Expand Down
4 changes: 2 additions & 2 deletions plugins/ExamplePlugin/src/testInterfacedPP_PointSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

'''
import copy
from PluginBaseClasses.PostProcessorPluginBase import PostProcessorPluginBase
from utils import InputData, InputTypes
from ravenframework.PluginBaseClasses.PostProcessorPluginBase import PostProcessorPluginBase
from ravenframework.utils import InputData, InputTypes

class testInterfacedPP_PointSet(PostProcessorPluginBase):
""" This class represents the most basic interfaced post-processor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<!-- MODELS -->
<Models>
<Code name="raven_running_plugin" subType="RAVEN">
<executable>python %FRAMEWORK_DIR%/../framework/Driver.py</executable>
<executable>%FRAMEWORK_DIR%/../raven_framework</executable>
<outputExportOutStreams>dumpSumOfExpOutput</outputExportOutStreams>
<alias variable="b" type="input">Samplers|MonteCarlo@name:test_MC|constant@name:b</alias>
<alias variable="a" type="input">Samplers|MonteCarlo@name:test_MC|constant@name:a</alias>
Expand Down
6 changes: 3 additions & 3 deletions raven_framework
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ fi
case $MODE in
'opt' )
echo 'Running RAVEN in "opt" mode.'
$PYTHON_COMMAND -O $RAVEN_DIR/framework/Driver.py "${ARGS[@]}"
$PYTHON_COMMAND -O $RAVEN_DIR/raven_framework.py "${ARGS[@]}"
;;
'dev' )
echo 'Running RAVEN in "dev" mode.'
$PYTHON_COMMAND $RAVEN_DIR/framework/Driver.py "${ARGS[@]}"
$PYTHON_COMMAND $RAVEN_DIR/raven_framework.py "${ARGS[@]}"
;;
'profile' )
echo 'Running RAVEN in "profiling" mode.'
kernprof -l -v $RAVEN_DIR/framework/Driver.py "${ARGS[@]}"
kernprof -l -v $RAVEN_DIR/raven_framework.py "${ARGS[@]}"
;;
'help' )
echo ''
Expand Down
26 changes: 26 additions & 0 deletions raven_framework.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python
# Copyright 2017 Battelle Energy Alliance, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Created on Feb 14, 2022

@author: cogljj

This is a package that properly imports Driver and runs it.
"""
import re
import sys
from ravenframework.Driver import main
if __name__ == '__main__':
sys.exit(main(True))
4 changes: 2 additions & 2 deletions framework/Application.py → ravenframework/Application.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#External Modules End-----------------------------------------------------------

#Internal Modules---------------------------------------------------------------
from BaseClasses import MessageUser
from Interaction import Interaction
from .BaseClasses import MessageUser
from .Interaction import Interaction
#Internal Modules End-----------------------------------------------------------

try:
Expand Down
Loading