Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ActEV
diva_evaluation_cli
Commits
f2f3d269
Commit
f2f3d269
authored
Feb 18, 2020
by
Baptiste CHOCOT
Committed by
Jonathan Fiscus
Feb 18, 2020
Browse files
Bare excepts & Ctrl-C fixing
parent
dcb64834
Changes
7
Hide whitespace changes
Inline
Side-by-side
diva_evaluation_cli/bin/commands/actev_command.py
View file @
f2f3d269
...
...
@@ -97,7 +97,10 @@ class ActevCommand():
logging
.
info
(
"%s done"
%
self
.
command
)
StatusFactory
.
generate_status
(
self
,
'done'
,
args
.
__dict__
)
except
:
except
KeyboardInterrupt
:
logging
.
info
(
"Ctrl-C detected. Exiting."
)
sys
.
exit
(
0
)
except
Exception
:
logging
.
exception
(
"Issue during %s"
%
self
.
command
)
StatusFactory
.
generate_status
(
self
,
'issue'
,
args
.
__dict__
)
sys
.
exit
(
1
)
...
...
diva_evaluation_cli/bin/private_src/entry_points/actev_clear_logs.py
View file @
f2f3d269
...
...
@@ -15,9 +15,15 @@ def entry_point():
path
=
os
.
path
.
dirname
(
__file__
)
script
=
os
.
path
.
join
(
path
,
'../implementation/clear_logs/clear_logs.sh'
)
# execute the script
# status is the exit status code returned by the program
# 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
:
raise
Exception
(
"Error occured in clear_logs.sh"
)
if
signal_number
==
2
:
# SIGINT
raise
KeyboardInterrupt
else
:
raise
Exception
(
"Error occured in clear_logs.sh"
)
diva_evaluation_cli/bin/private_src/entry_points/actev_get_system.py
View file @
f2f3d269
...
...
@@ -26,7 +26,7 @@ def entry_point(url, system_type, location=None, user=None, password=None, token
try
:
command
=
system_types
[
system_type
]()
script
=
command
.
entry_point
except
:
except
KeyError
:
raise
Exception
(
"Unknown system type"
)
# Init the actev_cli_environemnt variables
...
...
@@ -84,8 +84,14 @@ def entry_point(url, system_type, location=None, user=None, password=None, token
" "
+
sha
+
\
" "
+
name
# execute the script
# status is the exit status code returned by the program
# 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
:
raise
Exception
(
"Error occured in %s"
%
command
.
entry_point
)
if
signal_number
==
2
:
# SIGINT
raise
KeyboardInterrupt
else
:
raise
Exception
(
"Error occured in %s (error code: %d)"
%
(
command
.
entry_point
,
exit_code
))
diva_evaluation_cli/bin/private_src/entry_points/actev_validate_execution.py
View file @
f2f3d269
...
...
@@ -38,12 +38,18 @@ 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"
)
# execute the script
# status is the exit status code returned by the program
# 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
+
';'
+
' . '
+
installation_script
+
';'
+
scoring_cmd
status
=
os
.
system
(
cmd
)
exit_code
=
status
>>
8
signal_number
=
status
&
(
2
**
8
-
1
)
if
status
!=
0
:
raise
Exception
(
"Error occured in install.sh or score.sh"
)
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
...
...
diva_evaluation_cli/bin/private_src/implementation/exec/exec.py
View file @
f2f3d269
...
...
@@ -45,14 +45,20 @@ output, chunk_result):
pre_process_chunk
(
chunk_id
,
system_cache_dir
)
process_chunk
(
chunk_id
,
system_cache_dir
)
post_process_chunk
(
chunk_id
,
system_cache_dir
)
except
:
except
KeyboardInterrupt
:
experiment_cleanup
(
system_cache_dir
)
raise
KeyboardInterrupt
except
Exception
:
reset_chunk
(
chunk_id
,
system_cache_dir
)
continue
merge_chunks
(
system_cache_dir
,
output
,
chunk_result
,
None
)
experiment_cleanup
(
system_cache_dir
)
except
:
except
KeyboardInterrupt
:
experiment_cleanup
(
system_cache_dir
)
raise
KeyboardInterrupt
except
Exception
:
experiment_cleanup
(
system_cache_dir
)
raise
Exception
...
...
diva_evaluation_cli/bin/private_src/implementation/status/status_factory.py
View file @
f2f3d269
...
...
@@ -32,7 +32,7 @@ class StatusFactory():
if
command
in
public_subcommands
:
json_command_states
[
'id'
]
+=
1
json_command_states
[
command
.
command
].
append
({
'status'
:
status
,
'id'
:
json_command_states
[
'id'
],
'args'
:
args
})
except
:
except
(
json
.
JSONDecodeError
,
KeyError
)
:
logging
.
warning
(
"Status monitoring improperly terminated: status reset"
)
os
.
remove
(
command_states_log
)
...
...
diva_evaluation_cli/bin/private_src/implementation/validate_system/validate_system.py
View file @
f2f3d269
...
...
@@ -74,7 +74,7 @@ def validate_cli(strict):
# Is entry point exist
try
:
entry_point_module
=
importlib
.
import_module
(
'diva_evaluation_cli.src.entry_points.{}'
.
format
(
actev_command
))
except
:
except
ModuleNotFoundError
:
handle_error
(
"{} entry_point method removed"
.
format
(
actev_command
),
strict
)
entry_point_function
=
getattr
(
entry_point_module
,
'entry_point'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment