Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider f72737a7 rédigé par R's avatar R
Parcourir les fichiers

Created install (w. conda env), updated test script

parent 9fe24849
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
################################################################
# Makefile
#
# LgEval
# Feb 8, 2022 - R. Zanibbi
#################################################################
all: conda
# Install python environment for LgEval
conda:
./install
# 'make conda-remove' - remove LgEval conda environment
conda-remove:
conda env remove -n lgeval
......@@ -100,11 +100,31 @@ In addition to metrics, the library provides visualization of label graphs at th
2. perl (**with LibXML**)
3. python 3.x
4. Graphviz (for 'dot')
5. BeautifulSoup4 (`pip install beautifulsoup4`) (required for pretty printing output mathml)
Make sure that *CROHMELibDir* and *LgEvalDir* are defined in
your shell enviroment, e.g. by including the following in your .bashrc initialization script for bash shell. The last line adds the
tools to your search path.
5. Conda (e.g., from Anaconda) and pip for Python environments
**Conda LgEval Environment Install (preferred approach).** To install
the conda environment for lgeval, which will set up both Python packages and
necessary paths for LgEval command line tools, issue:
```
make
```
After installation, the LgEval conda environment can be started by issuing:
```
conda activate lgeval
```
at which point all LgEval tools (e.g., `evaluate`) should be usable as commands at the command line.
To stop using the lgeval conda environment, issue:
```
conda deactivate
```
Note: this will reset shell variables to their previous values.
**Alternative: Bash shell modification (for LgEval and CROHMELib).**
To use the LgEval tools from the command anywhere on your system, make sure that *CROHMELibDir* and *LgEvalDir* are defined in
your shell enviroment, e.g. by including the following in your .bashrc initialization script for bash shell. The last line adds the
tools to your search path.
export LgEvalDir=<path_to_LgEval>
export CROHMELibDir=<path_to_CROHMELib>
......
#!/bin/bash
# This should be run from the top level directory (lgeval/)
echo "Running test for issue 2 (inside relationship mapping)..."
# Do not modify user environment.
# User can install virtualenv for python if not installed.
#pip install virtualenv
# NOTE: Assumes 'make' has been run, and lgeval conda env. built
# This provides necessary packages AND paths
source `conda info | grep 'base environment' | awk '{print $4}'`/etc/profile.d/conda.sh
conda activate lgeval
# Create the virtual environment only once.
if [ ! -f .venv/bin/activate ]
then
virtualenv .venv
source .venv/bin/activate
pip install beautifulsoup4==4.9.2
fi
# RZ -- need to set LgEvalDir and PYTHONPATH for
# this to work.
#
# NOTE: These definitions are lost after the
# script ends (they are associated only with the
# invoked process that the shell program runs in)
#
# NOTE 2: You *must* use export to define a variable
# that you want to be visible in child processes
# (e.g., where lg2mml is called below)
export LgEvalDir=`cd ../..; pwd`
export PYTHONPATH=`cd ../../../; pwd`/
export PATH=$LgEvalDir/bin:$PATH
# Show environment (for checking and debugging)
echo "Environment Variables:"
echo " LgEvalDir $LgEvalDir"
echo " PYTHONPATH $PYTHONPATH"
echo " PATH $PATH"
echo ""
TEST_FILES=`ls ../../tests/sqrt_lg/*.lg`
TEST_FILES=`ls tests/sqrt_lg/*.lg`
for file in $TEST_FILES
do
lg2mml ../../tests/sqrt_lg/$file
lg2mml $file
filename=`basename $file .lg`
echo Input:" "$file
echo " >>MathML: $filename.mml"
echo Input:" "$file
echo ">> MathML: $filename.mml <<"
echo ""
cat $filename.mml
echo ""
done
# Clean up MML files
# Delete ONLY the files that we created.
echo "Deleting .mml files..."
for file in $TEST_FILES
do
rm `basename $file .lg`.mml
done
# Deactivate virtualenv
deactivate
# Deactivate lgeval environment
conda deactivate
echo "done."
#!/bin/bash
################################################################
# Functions
################################################################
# Report message
mymsg () {
echo " >> $@"
echo ""
}
# Pass number of arguments sent to outer script and success message to invoke.
testSuccess () {
if [ $? -ne 0 ]
then
echo ""
echo "** Installation error ** -- please review error messages above."
# Pass any additional argument, program will not halt.
if [ $1 -eq 0 ]
then
exit $?
else
echo "** Continuing..."
echo ""
fi
else
# Success.
mymsg $2
fi
}
################################################################
# LgEval Conda Environment
################################################################
# Set up Conda environment
echo "[ Creating LgEval Python Environment ]"
CENV=`conda info --envs`
if grep -w "lgeval" <<< "$CENV"
then
mymsg "Conda lgeval environment already created."
else
conda create -n lgeval python=3.6.9
testSuccess $# "Environment (lgeval) created successfully."
CONDSH=`conda info | grep 'base environment' | awk '{print $4}'`/etc/profile.d/conda.sh
source $CONDSH
conda activate lgeval
pip install -r requirements.txt
testSuccess $# "Additional packages installed successfully."
# Set environment variables in scripts run by conda on start/end of activation
# Define and record existing path definitions
LGEVALDIR=`pwd`
PARENTDIR=`cd ..;pwd`
OLDPYTHONPATH=$PYTHONPATH
OLDPATH=$PATH
OLDLGEVALDIR=$LgEvalDir
# Create shell files executed on lgeval conda env activate/deactivate
cd $CONDA_PREFIX
mkdir -p ./etc/conda/activate.d
mkdir -p ./etc/conda/deactivate.d
ACTIVE_ENV=./etc/conda/activate.d/env_vars.sh
DEACTIVE_ENV=./etc/conda/deactivate.d/end_vars.sh
# Activation script
echo "#!/bin/bash" > $ACTIVE_ENV
echo export LgEvalDir="$LGEVALDIR" >> $ACTIVE_ENV
echo export PYTHONPATH="$PARENTDIR:$PYTHONPATH" >> $ACTIVE_ENV
echo export PATH="$LGEVALDIR/bin:$PATH" >> $ACTIVE_ENV
echo "" >> $ACTIVE_ENV
echo export OLDLGEVALDIR="$OLDLGEVALDIR" >> $ACTIVE_ENV
echo export OLDPYTHONPATH="$PYTHONPATH" >> $ACTIVE_ENV
echo export OLDPATH="$PATH" >> $ACTIVE_ENV
# Deactivation script
echo "#!/bin/bash" > $DEACTIVE_ENV
echo export LgEvalDir=$OLDLGEVALDIR >> $DEACTIVE_ENV
echo export PYTHONPATH=$OLDPYTHONPATH >> $DEACTIVE_ENV
echo export PATH=$OLDPATH >> $DEACTIVE_ENV
echo "" >> $DEACTIVE_ENV
echo unset OLDLGEVALDIR >> $DEACTIVE_ENV
echo unset OLDPYTHONPATH >> $DEACTIVE_ENV
echo unset OLDPATH >> $DEACTIVE_ENV
mymsg "Created environment variables for lgeval conda shell."
conda deactivate
fi
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter