Commit 819dd0d4 authored by Baptiste CHOCOT's avatar Baptiste CHOCOT
Browse files

Fix conflicts and add jsonschema to conda deps list

parents ef587bd2 59ccad50
Pipeline #224122 failed
......@@ -4,21 +4,24 @@ Introduction
Consult the documentation to learn more about the CLI: [introduction](doc/introduction.md)
This repository contains:
* an abstract CLI to implement on the `master` branch
* an implementation example on the branch `baseline_system_master`.
* an abstract CLI to implement on the `master` branch.
* an implementation example on the branch `baseline_system_master`.
You should fork the project and use the `master` branch in order to implement the entry point methods and get the updates.
Test it
============
Get the CLI
-----------
**Requirements: python3.X**
**Requirements:** python > 3.7
Clone the repository:
```
```bash
git clone https://gitlab.kitware.com/actev/diva_evaluation_cli.git
```
......@@ -27,29 +30,33 @@ Install it
* Go into the clone of this repository:
```
$ cd diva_evaluation_cli
```bash
cd diva_evaluation_cli
```
* Execute the following script:
```bash
diva_evaluation_cli/bin/install.sh
```
$ diva_evaluation_cli/bin/install.sh
```
See `diva_evaluation_cli/bin/install.sh -h` for more options. If using `--all`, make sure to install the submodules before.
N.B.: We recommend to set the `-c` and `-s` options to what will be used as `system_cache_dir` by the entry_points ; otherwise, some operations like `validate-execution` will likely fail.
Test the installation
---------------------
Run the following command:
```
$ actev
```bash
actev
```
You should be able to see the available subcommands.
Usage
=====
Command line
......@@ -57,8 +64,8 @@ Command line
Run the following command to obtain help with the CLI:
```
$ actev -h
```bash
actev -h
```
Documentation
......@@ -66,8 +73,8 @@ Documentation
Consult the documentation to have information: [CLI](doc/cli_commands/index.md)
Fork it and develop your own implementation
===========================================
Fork it
......@@ -75,8 +82,8 @@ Fork it
Click on the “Fork” button to make a copy of the repository in your own space and add this repository as a remote upstream to get the latest updates
```
$ git remote add upstream https://gitlab.kitware.com/actev/diva_evaluation_cli.git
```bash
git remote add upstream https://gitlab.kitware.com/actev/diva_evaluation_cli.git
```
Update it
......@@ -84,10 +91,10 @@ Update it
Execute the following commands to update it:
```
$ git fetch upstream
$ git checkout master
$ git rebase upstream/master
```bash
git fetch upstream
git checkout master
git rebase upstream/master
```
Develop it
......@@ -100,6 +107,7 @@ We suggest you to call your scripts in the entry point methods and store them in
More information about the development and the update of the CLI here: [development](doc/development.md)
Contact
=======
* diva-nist@nist.gov
......@@ -4,54 +4,95 @@
# Command Line Interface actev: installation script #
#####################################################
usage() {
echo "usage: install.sh [-h | --help] [--cli-env | -c CLI_ENV_PATH] [--scorer-env | -s SCORER_ENV_PATH] [--force-conda | -f] [--all]"
}
CURRENT_DIR=`pwd`
cd "$(dirname "$0")"
# Make sure we are using python3.7
source update_python.sh
# Requirements
python3 -h &> /dev/null
if [[ $? -ne "0" ]]; then
echo "Python3 is required to install and run the CLI."
echo "Please install Python3.X >= 3.7 and make sure \`python3 -h\` is working."
exit 1
fi
conda -h &> /dev/null
if [[ $? -ne "0" ]]; then
echo "conda is required to install and run the CLI."
echo "Please install conda and make sure \`conda -h\` is working."
exit 1
fi
# Determine if python3.7 is running in a virtual environment
python3.7 private_src/implementation/utils/is_virtual_env.py
cd "${CURRENT_DIR}"
# Check that .local/bin path is in $PATH
echo $PATH | grep /.local/bin > /dev/null
EXIT_STATUS=$?
cd "${CURRENT_DIR}"
if [ $EXIT_STATUS -ne 0 ];then
# Check that .local/bin path is in $PATH
echo $PATH | grep /.local/bin > /dev/null
EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 0 ];then
echo "Please add ~/.local/bin to your PATH before running the script:"
echo "export PATH=\"${PATH}:${HOME}/.local/bin\""
exit 1
fi
# Install using python3
options='--user'
else
# Install using venv python
options=''
echo "Please add ~/.local/bin to your PATH before running the script:"
echo "export PATH=\"${PATH}:${HOME}/.local/bin\""
exit 1
fi
cd "$(dirname "$0")"
sudo apt-get install python3-pip -y
sudo apt-get install python3.7-dev -y
python3.7 -m pip install pip --upgrade
python3.7 -m pip install setuptools $options
python3.7 -m pip install -r ../../requirements.txt $options
python3.7 -m pip install -e ../../. -U $options
# Install dependencies (e.g. ActEV scorer) contained in `install.sh` scripts
# if '--all' is passed as an argument
if [ ! -z "$1" ] && [ "$1" == "--all" ];then
installation_scripts=`find private_src | grep "install.sh"`
for install_script in $installation_scripts; do
echo "Installation in progress: $install_script"
./$install_script
echo "Installation done: $install_script"
done
envs="~/.conda_envs"
cli_env="$envs/cli.env"
scorer_env="$envs/scorer.env"
all=0
force_env=0
while [ "$1" != "" ]; do
case $1 in
-c | --cli-env ) shift
cli_env=$1
;;
-s | --scorer-env ) shift
scorer_env=$1
;;
-f | --force-conda ) force_env=1
;;
-h | --help ) usage
exit
;;
--all ) all=1
;;
* ) usage
exit 1
esac
shift
done
# back to ./, creating CLI conda env
cd ../..
conda env create -f environment.yml -p $cli_env
conda_script="$(conda shell.bash hook)"
# Adding it to bashrc for execution flow
if [[ $force_env -eq 1 ]]; then
echo "# Activate ActEV-CLI conda environment" >> ~/.bashrc
echo $conda_script >> ~/.bashrc
echo "conda activate $cli_env" >> ~/.bashrc
echo '' >> ~/.bashrc
fi
# Activating it and installing the CLI
eval "$conda_script"
conda activate $cli_env
python3 setup.py develop --prefix $cli_env
conda deactivate
# Exporting scorer env directory to the CLI shell env
cd "$(dirname "$0")"
echo "SCORER_CONDA_ENV=$scorer_env" >> ./private_src/implementation/utils/actev_cli_environment.env
# TODO replace ca par juste lui du scorer
# conda le scorer etc
if [[ $all -eq 1 ]]; then
cd "$(dirname "$0")"
echo "Installation in progress: ActEV_Scorer"
./private_src/implementation/validate_execution/install.sh $scorer_env
echo "Installation done: ActEV_Scorer"
fi
......@@ -12,6 +12,9 @@ import sys
from collections import Counter
from diva_evaluation_cli.bin.private_src.implementation.utils.\
actev_cli_environment import activate_environment
logger = logging.getLogger(__name__)
......@@ -38,7 +41,7 @@ def entry_point(output, reference, activity_index, file_index, result, score,
current_path, '../implementation/validate_execution')
"""
installation_script = os.path.join(execution_validation_dir, 'install.sh')
scoring_cmd = 'python3.7 ' + os.path.join(
scoring_cmd = 'python3 ' + os.path.join(
execution_validation_dir, 'ActEV_Scorer',
'ActEV_Scorer.py ActEV18_AD -v ')
......@@ -52,11 +55,12 @@ def entry_point(output, reference, activity_index, file_index, result, score,
if not result and score:
raise Exception("Please provide a -R option when using --score")
"""
# status is a 16-bit long integer
# The 8 strongest bits are exit_code
# The 8 weakest bits are signal_number
cmd = 'cd ' + execution_validation_dir + '; '
cmd += '. ' + installation_script + ';' + scoring_cmd
cmd += 'bash ' + installation_script + ';' + scoring_cmd
status = os.system(cmd)
exit_code = status >> 8
signal_number = status & (2**8 - 1)
......@@ -65,6 +69,11 @@ def entry_point(output, reference, activity_index, file_index, result, score,
raise KeyboardInterrupt
else:
raise Exception("Error occured in install.sh or score.sh")
"""
# Loading dotenv and running scorer
activate_environment()
os.system('eval "$(conda shell.bash hook)"; conda activate %s; %s; \
conda deactivate' % (os.getenv('SCORER_CONDA_ENV'), scoring_cmd))
# If the system output is scored, make it also check the alignments
# Produced by the scorer. This is a reproducibility check made to compare
......
ACTEV_GET_SYSTEM_URL="https://gitlab.kitware.com/actev/diva_evaluation_cli.git"
\ No newline at end of file
"""Utils module
Can be used by any other module of the CLI
Determine if python3 is running in a virtual environment
"""
import sys
if __name__ == "__main__":
if hasattr(sys, 'real_prefix'):
sys.exit(0)
else:
sys.exit(1)
#!/bin/bash
env_dir="python_env"
current_path=`realpath $(dirname $0)`
path_to_env_dir="$current_path/$env_dir"
sudo apt-get install -y python3-dev python3-pip
python3.7 -m pip install virtualenv
if [ -d $path_to_env_dir ];then
. $path_to_env_dir/bin/activate
else
virtualenv $path_to_env_dir
. $path_to_env_dir/bin/activate
python3.7 -m pip --no-cache-dir install -r $current_path/ActEV_Scorer/requirements.txt
if [[ $# -ne 1 ]]; then
echo "usage: install.sh <scorer_conda_env_path>"
exit 1
fi
current_path=`realpath $(dirname $0)`
conda env create -f $current_path/ActEV_Scorer/environment.yml -p $1
eval "$(conda shell.bash hook)"
conda activate $1
conda deactivate
#!/bin/bash
bin_dir="/usr/bin"
if [ ! -f $bin_dir/python3.7 ];then
sudo apt install -y python3.7
fi
if [ -f $bin_dir/python3 ];then
sudo rm -rf $bin_dir/python3
fi
sudo ln -s $bin_dir/python3.7 $bin_dir/python3
name: CLI
channels:
- conda-forge
- defaults
- fastai
dependencies:
- python=3.8
- psutil=5.7.2
- python-dotenv=0.13.0
- nvidia-ml-py3=7.352.0
- pycodestyle
- pyyaml
- jsonschema=3.2.0
......@@ -57,18 +57,18 @@ git clone https://gitlab.kitware.com/actev/actev-data-repo $TMP_DIR/actev-data-r
# Create an environment to run the data download script
pushd $TMP_DIR
virtualenv envpy3 -p python3.7
virtualenv envpy3 -p python3
popd
source $TMP_DIR/envpy3/bin/activate
python3.7 -m pip install jsonschema pandas
python3 -m pip install jsonschema pandas
# Add the credentials to download the videos
python3.7 $TMP_DIR/actev-data-repo/scripts/actev-corpora-maint.py --operation summary --corpus MEVA --add_credential `echo $ACTEV_DATA_REPO_CREDENTIALS_MEVA | tr -d ' '`
python3.7 $TMP_DIR/actev-data-repo/scripts/actev-corpora-maint.py --operation summary --corpus VIRAT-V1 --add_credential `echo $ACTEV_DATA_REPO_CREDENTIALS_VIRAT1 | tr -d ' '`
python3.7 $TMP_DIR/actev-data-repo/scripts/actev-corpora-maint.py --operation summary --corpus VIRAT-V2 --add_credential `echo $ACTEV_DATA_REPO_CREDENTIALS_VIRAT2 | tr -d ' '`
python3 $TMP_DIR/actev-data-repo/scripts/actev-corpora-maint.py --operation summary --corpus MEVA --add_credential `echo $ACTEV_DATA_REPO_CREDENTIALS_MEVA | tr -d ' '`
python3 $TMP_DIR/actev-data-repo/scripts/actev-corpora-maint.py --operation summary --corpus VIRAT-V1 --add_credential `echo $ACTEV_DATA_REPO_CREDENTIALS_VIRAT1 | tr -d ' '`
python3 $TMP_DIR/actev-data-repo/scripts/actev-corpora-maint.py --operation summary --corpus VIRAT-V2 --add_credential `echo $ACTEV_DATA_REPO_CREDENTIALS_VIRAT2 | tr -d ' '`
# Download the video
python3.7 $TMP_DIR/actev-data-repo/scripts/actev-corpora-maint.py --operation download --partitions $VALIDATION_SET
python3 $TMP_DIR/actev-data-repo/scripts/actev-corpora-maint.py --operation download --partitions $VALIDATION_SET
deactivate
## CLI EXECUTION
......
......@@ -12,7 +12,7 @@ import diva_evaluation_cli
setup(name='diva_evaluation_cli',
version=diva_evaluation_cli.__version__,
package=find_packages(),
packages=find_packages(),
include_package_data=True,
entry_points='''
[console_scripts]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment