Commit 40f8aa0a authored by Baptiste CHOCOT's avatar Baptiste CHOCOT
Browse files

Revert "Merge branch 'development'"

This reverts merge request !65
parent ff945a03
Pipeline #177477 failed with stage
......@@ -4,7 +4,7 @@ stages:
test-abstract-cli:
stage: build-test
image: python:3.7-stretch
image: python:3.5-stretch
script:
- python3 -m pip install pycodestyle
......@@ -16,7 +16,7 @@ test-abstract-cli:
test-baseline:
stage: test-baseline
image: python:3.7-stretch
image: python:3.5-stretch
script:
- python3 -m pip install -r ./requirements.txt
......
MAKE=make
check:
@(echo "** Linting **\n")
(pycodestyle test/**/*.py diva_evaluation_cli/bin/)
@(echo "** Running UnitTests **\n")
(python3 -m unittest test/test_*/*.py)
\ No newline at end of file
(python3 -m unittest discover test)
\ No newline at end of file
......@@ -116,10 +116,7 @@ class ActevCommand():
except KeyboardInterrupt:
logging.info("Ctrl-C detected. Exiting.")
sys.exit(0)
except Exception as e:
# Necessary for testing purposes
if not isinstance(e, NotImplementedError):
logging.exception("Issue during %s" % self.command)
StatusFactory.generate_status(self, 'issue', args.__dict__)
sys.exit(1)
raise NotImplementedError
except Exception:
logging.exception("Issue during %s" % self.command)
StatusFactory.generate_status(self, 'issue', args.__dict__)
sys.exit(1)
......@@ -41,8 +41,8 @@ class ActevMergeChunks(ActevCommand):
required_named = arg_parser.add_argument_group(
'required named arguments')
required_named.add_argument("-s", "--system-cache-dir",
help="path to system cache directory",
required_named.add_argument("-r", "--result-location",
help="path to the chunks merge result",
required=True)
required_named.add_argument("-o", "--output-file",
help="path to save the output file",
......@@ -50,8 +50,8 @@ class ActevMergeChunks(ActevCommand):
required_named.add_argument("-c", "--chunks-file",
help="path to save the chunks in a json",
required=True)
arg_parser.add_argument("-r", "--result-location",
help="DEPRECATED /!\\ path to the result")
arg_parser.add_argument("-i", "--chunk-ids", help="list of chunk ids",
nargs='+')
arg_parser.add_argument("-s", "--system-cache-dir",
help="path to system cache directory")
arg_parser.set_defaults(func=ActevMergeChunks.command, object=self)
......@@ -4,9 +4,6 @@ This file should not be modified.
"""
import os
from diva_evaluation_cli.bin.private_src.implementation.utils.\
shell_wrapper import run_shell
def entry_point():
"""Private entry point.
......@@ -17,4 +14,15 @@ def entry_point():
# go into the right directory to execute the script
path = os.path.dirname(__file__)
script = os.path.join(path, '../implementation/clear_logs/clear_logs.sh')
run_shell(script)
# status is a 16-bit long integer
# The 8 strongest bits are exit_code
# The 8 weakest bits are signal_number
status = os.system(script)
exit_code = status >> 8
signal_number = status & (2**8 - 1)
if status != 0:
if signal_number == 2: # SIGINT
raise KeyboardInterrupt
else:
raise Exception("Error occured in clear_logs.sh")
......@@ -9,8 +9,6 @@ from diva_evaluation_cli.bin.private_src.implementation.utils.\
from diva_evaluation_cli.bin.private_src.implementation.get_system.\
system_types_definition import system_types
from diva_evaluation_cli.bin.private_src.implementation.utils.\
shell_wrapper import run_shell
def entry_point(url, system_type, location=None, user=None, password=None,
......@@ -88,4 +86,16 @@ def entry_point(url, system_type, location=None, user=None, password=None,
" " + install_cli + \
" " + sha + \
" " + name
run_shell(script)
# status is a 16-bit long integer
# The 8 strongest bits are exit_code
# The 8 weakest bits are signal_number
status = os.system(script)
exit_code = status >> 8
signal_number = status & (2**8 - 1)
if status != 0:
if signal_number == 2: # SIGINT
raise KeyboardInterrupt
else:
raise Exception("Error occured in %s (error code: %d)" % (
command.entry_point, exit_code))
......@@ -9,9 +9,6 @@ import os
from collections import Counter
from diva_evaluation_cli.bin.private_src.implementation.utils.\
shell_wrapper import run_shell
logger = logging.getLogger(__name__)
......@@ -35,7 +32,7 @@ def entry_point(output, reference, activity_index, file_index, result, score):
execution_validation_dir = os.path.join(
current_path, '../implementation/validate_execution')
installation_script = os.path.join(execution_validation_dir, 'install.sh')
scoring_cmd = 'python3 ' + os.path.join(
scoring_cmd = 'python2 ' + os.path.join(
execution_validation_dir, 'ActEV_Scorer',
'ActEV_Scorer.py ActEV18_AD -v ')
......@@ -49,9 +46,19 @@ 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
run_shell(cmd)
status = os.system(cmd)
exit_code = status >> 8
signal_number = status & (2**8 - 1)
if status != 0:
if signal_number == 2: # SIGINT
raise KeyboardInterrupt
else:
raise Exception("Error occured in install.sh or score.sh")
# If the system output is scored, make it also check the alignments
# Produced by the scorer. This is a reproducibility check made to compare
......
......@@ -36,16 +36,8 @@ fi
git clone --recursive $url $name
if [ $? -eq 0 ];then
# sanitize URL (can be /repo or /repo.git or /repo/)
if [[ ! $url =~ \.git$ ]];then
if [[ $url =~ /$ ]];then
url=`echo $url | sed s/.$//`
fi
url=$url.git
fi
repo_name=`echo $url | rev | cut -d '.' -f2 | rev`
repo_name=`echo $repo_name | rev | cut -d '/' -f1 | rev`
# If sha or tag is specified
if [ $sha != "None" ];then
cd $repo_name
......
"""Utils module
Can be used by any other module of the CLI
Implements function to call shell commands and get correct informations on fail
"""
import subprocess
class ShellException(Exception):
"""
Bare exception class for running shell commands.
"""
def __init__(self, exception):
Exception.__init__(self)
self.exception = exception
def __str__(self):
return "Failed to execute: {}\nError code: {}\nstderr: {}".format(
self.exception.cmd, self.exception.returncode,
self.exception.stderr)
def run_shell(command: tuple):
"""
Run shell script or command.
"""
try:
process = subprocess.run(command, shell=True, capture_output=True,
text=True, check=True)
except subprocess.CalledProcessError as e:
raise ShellException(e)
{
"hand_interacts_with_person": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_abandons_package": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_carries_heavy_object": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_closes_facility_door": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_closes_trunk": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_closes_vehicle_door": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_embraces_person": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_enters_scene_through_structure": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_enters_vehicle": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_exits_scene_through_structure": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_exits_vehicle": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_interacts_with_laptop": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_loads_vehicle": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_opens_facility_door": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_opens_trunk": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_opens_vehicle_door": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_picks_up_object": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_purchases": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_puts_down_object": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_reads_document": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_rides_bicycle": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_sits_down": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_stands_up": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_steals_object": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_talks_on_phone": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_talks_to_person": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_texts_on_phone": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_transfers_object": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"person_unloads_vehicle": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"vehicle_drops_off_person": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"vehicle_makes_u_turn": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"vehicle_picks_up_person": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"vehicle_reverses": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"
},
"objectTypes": [
"vehicle",
"person"
]
},
"vehicle_starts": {
"objectTypeMap": {
"person": "*person*",
"vehicle": "*vehicle*"