Commit 457f0e22 authored by Alexandre Boyer's avatar Alexandre Boyer
Browse files

Add actev status command

parent 8ac3932b
# Basic gitignore config
*.swp
*.pyc
*.egg-info
# Commands history
diva_evaluation_cli/bin/private_src/implementation/status/command_history.json
1.0.3 - 11.09.18
================
* Add a new command: actev status
* Add documentation about actev status
* Fix a bug in actev exec when nb_videos_per_chunk was missing
* Add actions before and after command: check video files validity in experiment-init
1.0.2 - 10.26.18
================
......
__version__ = '1.0.2'
__version__ = '1.0.3'
......@@ -21,24 +21,26 @@ import logging
import argparse
import sys
from diva_evaluation_cli.bin.actev_get_system import ActevGetSystem
from diva_evaluation_cli.bin.actev_system_setup import ActevSystemSetup
from diva_evaluation_cli.bin.actev_validate_system import ActevValidateSystem
from diva_evaluation_cli.bin.actev_design_chunks import ActevDesignChunks
from diva_evaluation_cli.bin.actev_experiment_init import ActevExperimentInit
from diva_evaluation_cli.bin.actev_pre_process_chunk import ActevPreProcessChunk
from diva_evaluation_cli.bin.actev_process_chunk import ActevProcessChunk
from diva_evaluation_cli.bin.actev_post_process_chunk import ActevPostProcessChunk
from diva_evaluation_cli.bin.actev_reset_chunk import ActevResetChunk
from diva_evaluation_cli.bin.actev_experiment_cleanup import ActevExperimentCleanup
from diva_evaluation_cli.bin.actev_merge_chunks import ActevMergeChunks
from diva_evaluation_cli.bin.actev_exec import ActevExec
from diva_evaluation_cli.bin.commands.actev_get_system import ActevGetSystem
from diva_evaluation_cli.bin.commands.actev_system_setup import ActevSystemSetup
from diva_evaluation_cli.bin.commands.actev_validate_system import ActevValidateSystem
from diva_evaluation_cli.bin.commands.actev_design_chunks import ActevDesignChunks
from diva_evaluation_cli.bin.commands.actev_experiment_init import ActevExperimentInit
from diva_evaluation_cli.bin.commands.actev_pre_process_chunk import ActevPreProcessChunk
from diva_evaluation_cli.bin.commands.actev_process_chunk import ActevProcessChunk
from diva_evaluation_cli.bin.commands.actev_post_process_chunk import ActevPostProcessChunk
from diva_evaluation_cli.bin.commands.actev_reset_chunk import ActevResetChunk
from diva_evaluation_cli.bin.commands.actev_experiment_cleanup import ActevExperimentCleanup
from diva_evaluation_cli.bin.commands.actev_merge_chunks import ActevMergeChunks
from diva_evaluation_cli.bin.commands.actev_exec import ActevExec
from diva_evaluation_cli.bin.commands.actev_status import ActevStatus
private_subcommands = [
ActevGetSystem(),
ActevValidateSystem(),
ActevExec()
ActevExec(),
ActevStatus()
]
public_subcommands = [
......@@ -58,7 +60,7 @@ def cli_parser():
"""
logging.getLogger().setLevel(logging.INFO)
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(logging.Formatter('[%(asctime)s] %(name)s-%(levelname)s: %(message)s'))
handler.setFormatter(logging.Formatter('[%(asctime)s] diva_evaluation_cli-%(levelname)s: %(message)s'))
logging.getLogger().addHandler(handler)
# Initialize parser
......
import abc
import logging
import sys
from diva_evaluation_cli.bin.private_src.implementation.status.status_factory import StatusFactory
class ActevCommand():
""" Abstract class that represents an actev command.
"""
__metaclass__ = abc.ABCMeta
def __init__(self, command, entry_point):
def __init__(self, command, entry_point, before_entry_point=None, after_entry_point=None):
"""
@param command: string representing the name of the command
"""
self.command = command
self.entry_point = entry_point
self.before_entry_point = before_entry_point
self.after_entry_point = after_entry_point
@abc.abstractmethod
def cli_parser(self, arg_parser):
......@@ -21,6 +26,18 @@ class ActevCommand():
"""
return
def before_command(self, args):
""" Execute an action before executing the command
"""
if self.before_entry_point:
self.before_entry_point(**args.__dict__)
def after_command(self, args):
""" Execute an action after executing the command
"""
if self.after_entry_point:
self.after_entry_point(**args.__dict__)
def command(self, args):
""" Gets arguments and passe them to an entry point. Catch the exception occured.
......@@ -28,10 +45,19 @@ class ActevCommand():
"""
del args.__dict__['object']
del args.__dict__['func']
try:
logging.info("Starting %s" % self.command)
StatusFactory.generateStatus(self, 'start', args.__dict__)
self.before_command(args)
self.entry_point(**args.__dict__)
self.after_command(args)
logging.info("%s done" % self.command)
StatusFactory.generateStatus(self, 'done', args.__dict__)
except:
logging.exception("Issue during %s" % self.command)
raise
StatusFactory.generateStatus(self, 'issue', args.__dict__)
sys.exit(1)
......@@ -15,7 +15,7 @@ nb_video-per-chunk or n: number of videos in the chunk
Warning: this file should not be modified: see src/entry_points to add your source code.
"""
from diva_evaluation_cli.bin.actev_command import ActevCommand
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
from diva_evaluation_cli.src.entry_points.actev_design_chunks import entry_point
......
......@@ -22,8 +22,8 @@ Warning: this file should not be modified: see src/entry_points to add your sour
"""
import logging
from diva_evaluation_cli.bin.actev_command import ActevCommand
from diva_evaluation_cli.bin.private_src.private_entry_points.actev_exec import entry_point
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
from diva_evaluation_cli.bin.private_src.entry_points.actev_exec import entry_point
class ActevExec(ActevCommand):
......
......@@ -10,7 +10,7 @@ Warning: this file should not be modified: see src/entry_points to add your sour
"""
import logging
from diva_evaluation_cli.bin.actev_command import ActevCommand
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
from diva_evaluation_cli.src.entry_points.actev_experiment_cleanup import entry_point
......
......@@ -19,13 +19,14 @@ Warning: this file should not be modified: see src/entry_points to add your sour
"""
import logging
from diva_evaluation_cli.bin.actev_command import ActevCommand
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
from diva_evaluation_cli.bin.private_src.entry_points.actev_experiment_init import before_entry_point
from diva_evaluation_cli.src.entry_points.actev_experiment_init import entry_point
class ActevExperimentInit(ActevCommand):
def __init__(self):
super(ActevExperimentInit, self).__init__('experiment-init', entry_point)
super(ActevExperimentInit, self).__init__('experiment-init', entry_point, before_entry_point=before_entry_point)
def cli_parser(self, arg_parser):
""" Configure the description and the arguments (positional and optional) to parse.
......
......@@ -18,9 +18,9 @@ Warning: this file should not be modified: see src/entry_points to add your sour
"""
import logging
from diva_evaluation_cli.bin.actev_command import ActevCommand
from diva_evaluation_cli.bin.private_src.private_entry_points.actev_get_system import entry_point
from diva_evaluation_cli.bin.private_src.system_types.system_types_definition import system_types
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
from diva_evaluation_cli.bin.private_src.entry_points.actev_get_system import entry_point
from diva_evaluation_cli.bin.private_src.implementation.get_system.system_types_definition import system_types
class ActevGetSystem(ActevCommand):
......
......@@ -14,7 +14,7 @@ password or p: password to access the url
Warning: this file should not be modified.
"""
from diva_evaluation_cli.bin.actev_command import ActevCommand
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
class ActevGetSystemDocker(ActevCommand):
......
......@@ -17,7 +17,7 @@ install-cli or i: install the cli to use it
Warning: this file should not be modified.
"""
from diva_evaluation_cli.bin.actev_command import ActevCommand
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
class ActevGetSystemGit(ActevCommand):
......
......@@ -16,7 +16,7 @@ token or t: token to access the url
Warning: this file should not be modified.
"""
from diva_evaluation_cli.bin.actev_command import ActevCommand
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
class ActevGetSystemOther(ActevCommand):
......
......@@ -15,7 +15,7 @@ chunk-ids or i: list of chunk ids
Warning: this file should not be modified: see src/entry_points to add your source code.
"""
from diva_evaluation_cli.bin.actev_command import ActevCommand
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
from diva_evaluation_cli.src.entry_points.actev_merge_chunks import entry_point
......
......@@ -15,7 +15,7 @@ Warning: this file should not be modified: see src/entry_points to add your sour
"""
import logging
from diva_evaluation_cli.bin.actev_command import ActevCommand
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
from diva_evaluation_cli.src.entry_points.actev_post_process_chunk import entry_point
......
......@@ -15,7 +15,7 @@ Warning: this file should not be modified: see src/entry_points to add your sour
"""
import logging
from diva_evaluation_cli.bin.actev_command import ActevCommand
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
from diva_evaluation_cli.src.entry_points.actev_pre_process_chunk import entry_point
class ActevPreProcessChunk(ActevCommand):
......
......@@ -15,7 +15,7 @@ Warning: this file should not be modified: see src/entry_points to add your sour
"""
import logging
from diva_evaluation_cli.bin.actev_command import ActevCommand
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
from diva_evaluation_cli.src.entry_points.actev_process_chunk import entry_point
......
......@@ -15,7 +15,7 @@ Warning: this file should not be modified: see src/entry_points to add your sour
"""
import logging
from diva_evaluation_cli.bin.actev_command import ActevCommand
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
from diva_evaluation_cli.src.entry_points.actev_reset_chunk import entry_point
......
Markdown is supported
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