diff --git a/.gitignore b/.gitignore index 7b9923ae0ccc272b44b2199f0a5cc2a5a66b5928..5c5a4df92bb75b0f8fa8d2a52719534e0b8873f6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,8 @@ *.egg-info ## CLI gitignore config -# Commands history -diva_evaluation_cli/bin/private_src/implementation/status/command_history.json +# Monitor logs +*_monitoring.json # Virtual environments python_env/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dfc082598439b129c44b99f23400bcb3d0a67c03..50cb25320d244051303e14ed79c78f9e3d657c90 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,9 +6,10 @@ stages: build: stage: build - image: python:3.5-slim + image: python:3.5-stretch script: + - python3 -m pip install -r ./requirements.txt - python3 -m pip install -e . - actev -h - actev validate-system diff --git a/CHANGELOG.md b/CHANGELOG.md index d206f51b0404246d9efe1b6101161e3c9007f78f..e6c0f0d01f59a6eb2973869eecaaa638b4ee49ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +1.1.1 - 11.20.18 +================ + +* Add a new feature: resource monitoring +* Add some comments in the entry points +* bug fixes + 1.1 - 11.16.18 ============== @@ -21,7 +28,7 @@ * Add a new argument to pre/post/process-chunk: --system-cache-dir 1.0.1 - 10.24.18 -============== +================ * Add a new argument to reset-chunk: --system-cache-dir * Modify names of the arguments composed of multiple words. Example: --chunk_id becomes --chunk-id diff --git a/diva_evaluation_cli/__init__.py b/diva_evaluation_cli/__init__.py index 439eb0cd22a7d853a13959b9b321963a507f283a..b3ddbc41f3c4f93cf496976003953ed1e8fce026 100644 --- a/diva_evaluation_cli/__init__.py +++ b/diva_evaluation_cli/__init__.py @@ -1 +1 @@ -__version__ = '1.1' +__version__ = '1.1.1' diff --git a/diva_evaluation_cli/bin/cli.py b/diva_evaluation_cli/bin/cli.py index d0e91e8fc968807d62dc47b098e2821b665f8d85..9c8ac499ffdfbb3cf23a38c437b4b49887a41419 100644 --- a/diva_evaluation_cli/bin/cli.py +++ b/diva_evaluation_cli/bin/cli.py @@ -1,19 +1,7 @@ -""" -USAGE - -ActEV -Description ------------ -Run any common stub command. +"""Main CLI module -Args ----- -system-setup -design-chunks -experiment-init -process-chunk -experiment-cleanup -merge-chunks +Gather every actev command modules to parse and execute code in order to +test a system. Warning: this file should not be modified: see src/entry_points to add your source code. """ @@ -59,6 +47,7 @@ ActevExperimentCleanup(), def cli_parser(): """ Main command to parse commands and arguments """ + # Initialize logger logging.getLogger().setLevel(logging.INFO) handler = logging.StreamHandler(sys.stdout) handler.setFormatter(logging.Formatter('[%(asctime)s] diva_evaluation_cli-%(levelname)s: %(message)s')) @@ -86,4 +75,4 @@ def main(): cli_parser() if __name__ == '__main__': - main() + main() diff --git a/diva_evaluation_cli/bin/commands/actev_command.py b/diva_evaluation_cli/bin/commands/actev_command.py index 754aa2c923f6ab4584545ad6109277b1a64a6403..44a3f2d03e068f001b1d5fab352d51dfd8e4f589 100644 --- a/diva_evaluation_cli/bin/commands/actev_command.py +++ b/diva_evaluation_cli/bin/commands/actev_command.py @@ -1,17 +1,40 @@ +"""Actev module + +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. + +Warning: this file should not be modified: see src/entry_points to add your source code. +""" import abc import logging import sys +from diva_evaluation_cli.bin.private_src.implementation.resources_monitoring.monitor import Monitor from diva_evaluation_cli.bin.private_src.implementation.status.status_factory import StatusFactory class ActevCommand(): """ Abstract class that represents an actev command. + + Every actev modules must inherit from this class and + implement the following methods + + Attributes: + command (str): Name of the actev command + entry_point (function): Python function that represents an entry point + before_entry_point (function, optional): Python function that should be executed before entry_point method + after_entry_point (function, optional): Python function that should be executed after entry_point method + """ __metaclass__ = abc.ABCMeta def __init__(self, command, entry_point, before_entry_point=None, after_entry_point=None): - """ - @param command: string representing the name of the command + """ + Args: + command (str): Name of the actev command + entry_point (function): Python function that represents an entry point + before_entry_point (function, optional): Python function that should be executed before entry_point method + after_entry_point (function, optional): Python function that should be executed after entry_point method + """ self.command = command self.entry_point = entry_point @@ -22,18 +45,28 @@ class ActevCommand(): def cli_parser(self, arg_parser): """ Configure the description and the arguments (positional and optional) to parse. - @param arg_parser: python arg parser to describe how to parse the command - """ + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command + + """ return def before_command(self, args): """ Execute an action before executing the command + + Args: + args (:obj:`dict`): contains the arguments passed during the actev command call + """ if self.before_entry_point: self.before_entry_point(**args.__dict__) def after_command(self, args): """ Execute an action after executing the command + + Args: + args (:obj:`dict`): contains the arguments passed during the actev command call + """ if self.after_entry_point: self.after_entry_point(**args.__dict__) @@ -41,7 +74,9 @@ class ActevCommand(): def command(self, args): """ Gets arguments and passe them to an entry point. Catch the exception occured. - @param args: list of arguments passed during the command call + Args: + args (:obj:`dict`): contains the arguments passed during the actev command call + """ del args.__dict__['object'] del args.__dict__['func'] @@ -51,13 +86,14 @@ class ActevCommand(): StatusFactory.generateStatus(self, 'start', args.__dict__) self.before_command(args) - self.entry_point(**args.__dict__) + mon = Monitor(self.entry_point, args, self.command) + mon.run_monitor() self.after_command(args) logging.info("%s done" % self.command) StatusFactory.generateStatus(self, 'done', args.__dict__) except: - logging.exception("Issue during %s" % self.command) + logging.error("Issue during %s" % self.command) StatusFactory.generateStatus(self, 'issue', args.__dict__) sys.exit(1) - + diff --git a/diva_evaluation_cli/bin/commands/actev_design_chunks.py b/diva_evaluation_cli/bin/commands/actev_design_chunks.py index 420f86b6e6e46d759b74e5acf9ec4d7d6b0c8070..be11af254afb9c0601d0c06bdb4028c19038bfce 100644 --- a/diva_evaluation_cli/bin/commands/actev_design_chunks.py +++ b/diva_evaluation_cli/bin/commands/actev_design_chunks.py @@ -1,33 +1,34 @@ -""" -USAGE - -ActEV design-chunks -Description ------------ -Given a file index and an activity index, produce a chunks file that is suitable for the system. +"""Actev module: design-chunks -Args ----- -file-index or f: path to file index json file for test set -activity-index or a: path to activity index json file for test set -output or o: path to save chunks file -nb_video-per-chunk or n: number of videos in the chunk +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ from diva_evaluation_cli.bin.commands.actev_command import ActevCommand from diva_evaluation_cli.src.entry_points.actev_design_chunks import entry_point class ActevDesignChunks(ActevCommand): + """Given a file index and an activity index, produce a chunks file that is suitable for the system. + Command args: + * file-index or f: path to file index json file for test set + * activity-index or a: path to activity index json file for test set + * output or o: path to save chunks file + * nb_video-per-chunk or n: number of videos in the chunk + + """ def __init__(self): super(ActevDesignChunks, self).__init__('design-chunks', entry_point) def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description = "Produce a chunks file that is suitable for the system" required_named = arg_parser.add_argument_group('required named arguments') diff --git a/diva_evaluation_cli/bin/commands/actev_exec.py b/diva_evaluation_cli/bin/commands/actev_exec.py index f93bc3bf8b0ee2739ce21a9ddc12511ff2372002..29fc879a6bf5c7a740bd6f16ca81d6a4a8a5e1ca 100644 --- a/diva_evaluation_cli/bin/commands/actev_exec.py +++ b/diva_evaluation_cli/bin/commands/actev_exec.py @@ -1,24 +1,10 @@ -""" -USAGE - -ActEV exec -Description ------------ -Calls a team-implemented API. Captures time stamps, resource usage, etc. - -Args ----- -file-index or f: path to file index json file for test set -activity-index or a: path to activity index json file for test set -chunks or c: path to chunks json file -nb-video-per-chunk or n: number of videos in the chunk -video-location or v: path to videos content -system-cache-dir or s: path to system cache directory -config-file or C: path to config file -output-file: path to merge chunks command result -chunk_result: path to chunks json file after merge chunks execution +"""Actev module: exec + +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ import logging @@ -26,14 +12,29 @@ 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): - + """Calls a team-implemented API. Captures time stamps, resource usage, etc. + + Command args: + * file-index or f: path to file index json file for test set + * activity-index or a: path to activity index json file for test set + * chunks or c: path to chunks json file + * nb-video-per-chunk or n: number of videos in the chunk + * video-location or v: path to videos content + * system-cache-dir or s: path to system cache directory + * config-file or C: path to config file + * output-file: path to merge chunks command result + * chunk_result: path to chunks json file after merge chunks execution + + """ def __init__(self): super(ActevExec, self).__init__('exec', entry_point) def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description= "Calls a team-implemented API. Captures time stamps, resource usage, etc." required_named = arg_parser.add_argument_group('required named arguments') @@ -42,11 +43,11 @@ class ActevExec(ActevCommand): required_named.add_argument("-a", "--activity-index", help="path to activity index json file", required=True) required_named.add_argument("-c", "--chunks", help="path to chunks json file", required=True) arg_parser.add_argument("-n", "--nb-videos-per-chunk", help="number of videos in a chunk") - + required_named.add_argument("-v", "--video-location", help="path to videos content", required=True) required_named.add_argument("-s", "--system-cache-dir", help="path to system cache directory", required=True) arg_parser.add_argument("-C", "--config-file", help="path to config file") - + required_named.add_argument("-o", "--output-file", help="path to merge chunks command result", required=True) required_named.add_argument("-r", "--chunks-result", help="path to chunks json file after merge chunks execution", required=True) arg_parser.set_defaults(func=ActevExec.command, object=self) diff --git a/diva_evaluation_cli/bin/commands/actev_experiment_cleanup.py b/diva_evaluation_cli/bin/commands/actev_experiment_cleanup.py index be7a14eb465d1cd3f1a25f61d5dc5a864555cbcf..41a6c752f1305e428da953a59591055b9f0838b5 100644 --- a/diva_evaluation_cli/bin/commands/actev_experiment_cleanup.py +++ b/diva_evaluation_cli/bin/commands/actev_experiment_cleanup.py @@ -1,12 +1,10 @@ -""" -USAGE +"""Actev module: experiment-cleanup -ActEV experiment-cleanup -Description ------------ -Close any servers, terminates cluster (future functionality), etc. +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ import logging @@ -15,14 +13,18 @@ from diva_evaluation_cli.src.entry_points.actev_experiment_cleanup import entry_ class ActevExperimentCleanup(ActevCommand): + """Close any servers, terminates cluster (future functionality), etc. + """ def __init__(self): super(ActevExperimentCleanup, self).__init__('experiment-cleanup', entry_point) def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description = "Close any servers, terminates cluster, etc." arg_parser.set_defaults(func=ActevExperimentCleanup.command, object=self) diff --git a/diva_evaluation_cli/bin/commands/actev_experiment_init.py b/diva_evaluation_cli/bin/commands/actev_experiment_init.py index b30ac74f4a615cb71a0f6fbabbaa82a42d50e893..c2f4847b32b0ff9debb81a334c282b36bbe621c5 100644 --- a/diva_evaluation_cli/bin/commands/actev_experiment_init.py +++ b/diva_evaluation_cli/bin/commands/actev_experiment_init.py @@ -1,21 +1,10 @@ -""" -USAGE - -ActEV experiment-init -Description ------------ -Start servers, starts cluster, etc. - -Args ----- -file-index or f: path to file index json file for test set -activity-index or a: path to activity index json file for test set -chunks or c: path to chunks json file -video-location or v: path to videos content -system-cache-dir or s: path to system cache directory -config-file or C: path to config file +"""Actev module: experiment-init + +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ import logging @@ -24,14 +13,26 @@ from diva_evaluation_cli.bin.private_src.entry_points.actev_experiment_init impo from diva_evaluation_cli.src.entry_points.actev_experiment_init import entry_point class ActevExperimentInit(ActevCommand): + """Start servers, starts cluster, etc. + Command args: + * file-index or f: path to file index json file for test set + * activity-index or a: path to activity index json file for test set + * chunks or c: path to chunks json file + * video-location or v: path to videos content + * system-cache-dir or s: path to system cache directory + * config-file or C: path to config file + + """ def __init__(self): 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. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description= "Start servers, starts cluster, etc." required_named = arg_parser.add_argument_group('required named arguments') diff --git a/diva_evaluation_cli/bin/commands/actev_get_system.py b/diva_evaluation_cli/bin/commands/actev_get_system.py index 81bc2acbb5623c5f5dfd45328aaae3959bdefe3e..4f1df22f90fdc4958036509d5585ec7991180900 100644 --- a/diva_evaluation_cli/bin/commands/actev_get_system.py +++ b/diva_evaluation_cli/bin/commands/actev_get_system.py @@ -1,20 +1,10 @@ -""" -USAGE - -ActEV get-system -Description ------------ -Downloads a credentialed, web-accessible content into src +"""Actev module: get-system -Args ----- -url or u: url to get the system -location or l: path to store the system -user or U: username to access the url -password or p: password to access the url -token or t: token to access the url +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ import logging @@ -23,14 +13,25 @@ from diva_evaluation_cli.bin.private_src.entry_points.actev_get_system import en from diva_evaluation_cli.bin.private_src.implementation.get_system.system_types_definition import system_types class ActevGetSystem(ActevCommand): + """Downloads a credentialed, web-accessible content into src + Command args: + * url or u: url to get the system + * location or l: path to store the system + * user or U: username to access the url + * password or p: password to access the url + * token or t: token to access the url + + """ def __init__(self): super(ActevGetSystem, self).__init__('get-system', entry_point) def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description= "Downloads a credentialed, web-accessible content into src" diff --git a/diva_evaluation_cli/bin/commands/actev_get_system_subcommands/docker_command.py b/diva_evaluation_cli/bin/commands/actev_get_system_subcommands/docker_command.py index df4fe2f69d0c366e14c481b1300cd198af4e77a0..cf4e414330868263938573114a1a77dd48321d19 100644 --- a/diva_evaluation_cli/bin/commands/actev_get_system_subcommands/docker_command.py +++ b/diva_evaluation_cli/bin/commands/actev_get_system_subcommands/docker_command.py @@ -1,30 +1,31 @@ -""" -USAGE +"""Actev module: get-system docker -ActEV get-system docker -Description ------------ -Downloads a docker image +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. -Args ----- -user or U: url to get the system -password or p: password to access the url +Warning: this file should not be modified: see src/entry_points to add your source code. -Warning: this file should not be modified. """ from diva_evaluation_cli.bin.commands.actev_command import ActevCommand class ActevGetSystemDocker(ActevCommand): + """Downloads a docker image + + Command args: + * user or U: url to get the system + * password or p: password to access the url + """ def __init__(self): super(ActevGetSystemDocker, self).__init__('docker', "get_docker.sh") def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description= "Downloads a docker image" required_named = arg_parser.add_argument_group('required named arguments') diff --git a/diva_evaluation_cli/bin/commands/actev_get_system_subcommands/git_command.py b/diva_evaluation_cli/bin/commands/actev_get_system_subcommands/git_command.py index 7fcbca8aaf40ef7da1d8fef39a55ce31bdf21582..90c806da308d72b961e15453707e27dd9643ad2b 100644 --- a/diva_evaluation_cli/bin/commands/actev_get_system_subcommands/git_command.py +++ b/diva_evaluation_cli/bin/commands/actev_get_system_subcommands/git_command.py @@ -1,33 +1,33 @@ -""" -USAGE - -ActEV get-system git -Description ------------ -Clones a git repository - -Args ----- -location or l: path to store the system -user or U: url to get the system -password or p: password to access the url -token or t: token to access the url -install-cli or i: install the cli to use it - -Warning: this file should not be modified. -""" +"""Actev module: get-system git + +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. + +Warning: this file should not be modified: see src/entry_points to add your source code. +""" from diva_evaluation_cli.bin.commands.actev_command import ActevCommand class ActevGetSystemGit(ActevCommand): + """Clones a git repository + + Command Args: + * location or l: path to store the system + * user or U: url to get the system + * password or p: password to access the url + * token or t: token to access the url + * install-cli or i: install the cli to use it + """ def __init__(self): super(ActevGetSystemGit, self).__init__('git', "get_git.sh") def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description= "Downloads a git repository" required_named = arg_parser.add_argument_group('required named arguments') diff --git a/diva_evaluation_cli/bin/commands/actev_get_system_subcommands/other_command.py b/diva_evaluation_cli/bin/commands/actev_get_system_subcommands/other_command.py index ba09ea0ccd72b14ba2677384231297bd45f95db8..90f4d198af7796ab31a8dd3c8dccff026660dc92 100644 --- a/diva_evaluation_cli/bin/commands/actev_get_system_subcommands/other_command.py +++ b/diva_evaluation_cli/bin/commands/actev_get_system_subcommands/other_command.py @@ -1,32 +1,32 @@ -""" -USAGE +"""Actev module: get-system other -ActEV get-system other -Description ------------ -Downloads a web resources as a tar file +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. -Args ----- -location or l: path to store the system -user or U: url to get the system -password or p: password to access the url -token or t: token to access the url +Warning: this file should not be modified: see src/entry_points to add your source code. -Warning: this file should not be modified. """ - from diva_evaluation_cli.bin.commands.actev_command import ActevCommand class ActevGetSystemOther(ActevCommand): + """Downloads a web resources as a tar file + Command args: + * location or l: path to store the system + * user or U: url to get the system + * password or p: password to access the url + * token or t: token to access the url + + """ def __init__(self): super(ActevGetSystemOther, self).__init__('other', "get_other.sh") def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description= "Downloads a web resources as a tar file" required_named = arg_parser.add_argument_group('required named arguments') diff --git a/diva_evaluation_cli/bin/commands/actev_merge_chunks.py b/diva_evaluation_cli/bin/commands/actev_merge_chunks.py index ced2e2d609819d3c751fae123ff5bde523446f98..a276620f215cd5a7803db1dcfe1895aa661b177e 100644 --- a/diva_evaluation_cli/bin/commands/actev_merge_chunks.py +++ b/diva_evaluation_cli/bin/commands/actev_merge_chunks.py @@ -1,37 +1,38 @@ -""" -USAGE - -ActEV merge-chunks -Description ------------ -Given a list of chunk ids, merges all the chunks system output present in the list. +"""Actev module: merge-chunks -Args ----- -result-location or r: path to get the result of the chunks processing -chunk-file or c: path to directory where intermediate system output is stored -output-file or o: path to the output file generated -chunk-ids or i: list of chunk ids +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ from diva_evaluation_cli.bin.commands.actev_command import ActevCommand from diva_evaluation_cli.src.entry_points.actev_merge_chunks import entry_point class ActevMergeChunks(ActevCommand): + """Given a list of chunk ids, merges all the chunks system output present in the list. + Command args: + * result-location or r: path to get the result of the chunks processing + * chunk-file or c: path to directory where intermediate system output is stored + * output-file or o: path to the output file generated + * chunk-ids or i: list of chunk ids + + """ def __init__(self): super(ActevMergeChunks, self).__init__('merge-chunks', entry_point) def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description = "Merge given chunk ids in a file and output NIST compliant system file" required_named = arg_parser.add_argument_group('required named arguments') - + required_named.add_argument("-r", "--result-location", help="path to get the result of the chunks processing", required=True) required_named.add_argument("-o", "--output-file", help="path to save the output file generated", required=True) required_named.add_argument("-c", "--chunks-file", help="path to save the chunks in a json file", required=True) diff --git a/diva_evaluation_cli/bin/commands/actev_post_process_chunk.py b/diva_evaluation_cli/bin/commands/actev_post_process_chunk.py index f56ebb06d379152766050e5757ef169b59c97898..4fe4613d6ca160de2af0e266ceb65e6966cd3b44 100644 --- a/diva_evaluation_cli/bin/commands/actev_post_process_chunk.py +++ b/diva_evaluation_cli/bin/commands/actev_post_process_chunk.py @@ -1,17 +1,10 @@ -""" -USAGE - -ActEV post-process-chunk -Description ------------ -Post-process a chunk. +"""Actev module: post-process-chunk -Args ----- -chunk-id or i: chunk id -system-cache-dir or s: path to system cache directory +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ import logging @@ -20,14 +13,22 @@ from diva_evaluation_cli.src.entry_points.actev_post_process_chunk import entry_ class ActevPostProcessChunk(ActevCommand): + """Post-process a chunk. + Command args: + * chunk-id or i: chunk id + * system-cache-dir or s: path to system cache directory + + """ def __init__(self): super(ActevPostProcessChunk, self).__init__('post-process-chunk', entry_point) def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description = "Post-process a chunk" required_named = arg_parser.add_argument_group('required named arguments') diff --git a/diva_evaluation_cli/bin/commands/actev_pre_process_chunk.py b/diva_evaluation_cli/bin/commands/actev_pre_process_chunk.py index 20c799090068ef076ad7441a684ab00133b747e5..8c5e59de8aeab6c23aeb964cc838c8cbe623517c 100644 --- a/diva_evaluation_cli/bin/commands/actev_pre_process_chunk.py +++ b/diva_evaluation_cli/bin/commands/actev_pre_process_chunk.py @@ -1,17 +1,10 @@ -""" -USAGE - -ActEV pre-process-chunk -Description ------------ -Pre-process a chunk. +"""Actev module: pre-process-chunk -Args ----- -chunk-id or i: chunk id -system-cache-dir or s: path to system cache directory +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ import logging @@ -19,14 +12,22 @@ 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): + """Pre-process a chunk. + Command args: + * chunk-id or i: chunk id + * system-cache-dir or s: path to system cache directory + + """ def __init__(self): super(ActevPreProcessChunk, self).__init__('pre-process-chunk', entry_point) def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description = "Pre-process a chunk" required_named = arg_parser.add_argument_group('required named arguments') diff --git a/diva_evaluation_cli/bin/commands/actev_process_chunk.py b/diva_evaluation_cli/bin/commands/actev_process_chunk.py index c709ed566d37d01fa5a835654d2ab36c0b4f5693..7519e6912cdfa2faba02d468dc9233fd35a86225 100644 --- a/diva_evaluation_cli/bin/commands/actev_process_chunk.py +++ b/diva_evaluation_cli/bin/commands/actev_process_chunk.py @@ -1,17 +1,10 @@ -""" -USAGE - -ActEV process-chunk -Description ------------ -Process a chunk. +"""Actev module: process-chunk -Args ----- -chunk-id or i: chunk id -system-cache-dir or s: path to system cache directory +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ import logging @@ -20,14 +13,22 @@ from diva_evaluation_cli.src.entry_points.actev_process_chunk import entry_point class ActevProcessChunk(ActevCommand): + """Process a chunk. + Command args: + * chunk-id or i: chunk id + * system-cache-dir or s: path to system cache directory + + """ def __init__(self): super(ActevProcessChunk, self).__init__('process-chunk', entry_point) def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description = "Process a chunk" required_named = arg_parser.add_argument_group('required named arguments') diff --git a/diva_evaluation_cli/bin/commands/actev_reset_chunk.py b/diva_evaluation_cli/bin/commands/actev_reset_chunk.py index c91be42a9b47014aa6d73c0fb44a331a33d73999..bb343053e3e63988ff724bb016eba5d966ba35d1 100644 --- a/diva_evaluation_cli/bin/commands/actev_reset_chunk.py +++ b/diva_evaluation_cli/bin/commands/actev_reset_chunk.py @@ -1,17 +1,10 @@ -""" -USAGE - -ActEV reset-chunk -Description ------------ -Delete all cached information for ChunkID so that the chunk can be re-run. +"""Actev module: reset-chunk -Args ----- -chunk-id or i: chunk id -system-cache-dir or s: path to system cache directory +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ import logging @@ -20,14 +13,22 @@ from diva_evaluation_cli.src.entry_points.actev_reset_chunk import entry_point class ActevResetChunk(ActevCommand): + """Delete all cached information for ChunkID so that the chunk can be re-run. + Command args: + * chunk-id or i: chunk id + * system-cache-dir or s: path to system cache directory + + """ def __init__(self): super(ActevResetChunk, self).__init__('reset-chunk', entry_point) def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description = "Delete all cached information" required_named = arg_parser.add_argument_group('required named arguments') diff --git a/diva_evaluation_cli/bin/commands/actev_status.py b/diva_evaluation_cli/bin/commands/actev_status.py index 1f847ffa8e3a768fe43ac9cb03bb3e92a96506c3..9b6d17ef98a43b270b441ba206e48e7b002b231a 100644 --- a/diva_evaluation_cli/bin/commands/actev_status.py +++ b/diva_evaluation_cli/bin/commands/actev_status.py @@ -1,13 +1,12 @@ -""" -USAGE +"""Actev module: status -ActEV status -Description ------------ -Executable at any time. Get the status of the experiment. +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ + import logging from diva_evaluation_cli.bin.commands.actev_command import ActevCommand @@ -15,21 +14,24 @@ from diva_evaluation_cli.bin.private_src.entry_points.actev_status import entry_ from diva_evaluation_cli.bin.private_src.implementation.status.query_types_definition import query_types class ActevStatus(ActevCommand): - + """Executable at any time. Get the status of the experiment. + """ def __init__(self): super(ActevStatus, self).__init__('status', entry_point) def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description= "Executable at any time. Get the status of the experiment" - + sub_parser_query_types = arg_parser.add_subparsers(title='subsubcommands', dest='query_type') - + for query_type_name in query_types.keys(): - sub_parser_query_type = sub_parser_query_types.add_parser(query_type_name) + sub_parser_query_type = sub_parser_query_types.add_parser(query_type_name) required_named = sub_parser_query_type.add_argument_group('required named arguments') command = query_types[query_type_name]().cli_parser(sub_parser_query_type) diff --git a/diva_evaluation_cli/bin/commands/actev_status_subcommands/chunk_query_command.py b/diva_evaluation_cli/bin/commands/actev_status_subcommands/chunk_query_command.py index 913c4df01af53233211d017e4b63655ecc8c3fb7..49e345053407bc1f5b2fb59a87b8baf29e1b1898 100644 --- a/diva_evaluation_cli/bin/commands/actev_status_subcommands/chunk_query_command.py +++ b/diva_evaluation_cli/bin/commands/actev_status_subcommands/chunk_query_command.py @@ -1,29 +1,29 @@ -""" -USAGE +"""Actev module: status chunk-query -ActEV status chunk-query -Description ------------ -Get the status of a chunk id +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. -Args ----- -chunk-id or i: chunk id +Warning: this file should not be modified: see src/entry_points to add your source code. -Warning: this file should not be modified. """ - from diva_evaluation_cli.bin.commands.actev_command import ActevCommand class ActevStatusChunkQuery(ActevCommand): + """Get the status of a chunk id + Command args: + * chunk-id or i: chunk id + + """ def __init__(self): super(ActevStatusChunkQuery, self).__init__('chunk-query', '') def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description= "Get the status of a chunk id" required_named = arg_parser.add_argument_group('required named arguments') diff --git a/diva_evaluation_cli/bin/commands/actev_status_subcommands/experiment_query_command.py b/diva_evaluation_cli/bin/commands/actev_status_subcommands/experiment_query_command.py index 9f9f8849bef851929286ef491fad987a66babf50..96172b0a838ce706522d29208a2f34250d6f7226 100644 --- a/diva_evaluation_cli/bin/commands/actev_status_subcommands/experiment_query_command.py +++ b/diva_evaluation_cli/bin/commands/actev_status_subcommands/experiment_query_command.py @@ -1,25 +1,27 @@ -""" -USAGE +"""Actev module: status experiment-query + +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. -ActEV status experiment-query -Description ------------ -Get the status of the experiment +Warning: this file should not be modified: see src/entry_points to add your source code. -Warning: this file should not be modified. """ + from diva_evaluation_cli.bin.commands.actev_command import ActevCommand class ActevStatusExperimentQuery(ActevCommand): - + """Get the status of the experiment + """ def __init__(self): super(ActevStatusExperimentQuery, self).__init__('experiment-query', '') def cli_parser(self, arg_parser): """ Configure the description and the arguments (positional and optional) to parse. - @param arg_parser: python arg parser to describe how to parse the command + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command + """ arg_parser.description= "Get the status of the experiment" required_named = arg_parser.add_argument_group('required named arguments') diff --git a/diva_evaluation_cli/bin/commands/actev_status_subcommands/system_query_command.py b/diva_evaluation_cli/bin/commands/actev_status_subcommands/system_query_command.py index 6d3b4f4c08e33a71334678664d68a21c91e67790..aa31b1faaa1ed04e9ccf04b3644969dfc5abec46 100644 --- a/diva_evaluation_cli/bin/commands/actev_status_subcommands/system_query_command.py +++ b/diva_evaluation_cli/bin/commands/actev_status_subcommands/system_query_command.py @@ -1,25 +1,27 @@ -""" -USAGE +"""Actev module: system-query + +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. -ActEV status system-query -Description ------------ -Get the status of the system +Warning: this file should not be modified: see src/entry_points to add your source code. -Warning: this file should not be modified. """ + from diva_evaluation_cli.bin.commands.actev_command import ActevCommand class ActevStatusSystemQuery(ActevCommand): - + """Get the status of the system + """ def __init__(self): super(ActevStatusSystemQuery, self).__init__('system-query', '') def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description= "Get the status of the system" required_named = arg_parser.add_argument_group('required named arguments') diff --git a/diva_evaluation_cli/bin/commands/actev_system_setup.py b/diva_evaluation_cli/bin/commands/actev_system_setup.py index a0187504c977af295a7e01cb2f5e6d5fe50f033b..cbb8b2c9d917559d199a3044446f50065f2ad5c4 100644 --- a/diva_evaluation_cli/bin/commands/actev_system_setup.py +++ b/diva_evaluation_cli/bin/commands/actev_system_setup.py @@ -1,13 +1,12 @@ -""" -USAGE +"""Actev module: system-setup -ActEV system-setup -Description ------------ -Run any compilation/preparation steps for the system. +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ + import logging from diva_evaluation_cli.bin.commands.actev_command import ActevCommand @@ -15,14 +14,17 @@ from diva_evaluation_cli.src.entry_points.actev_system_setup import entry_point class ActevSystemSetup(ActevCommand): - + """Run any compilation/preparation steps for the system. + """ def __init__(self): super(ActevSystemSetup, self).__init__('system-setup', entry_point) def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description = "Run any compilation/preparation steps for the system" arg_parser.set_defaults(func=ActevSystemSetup.command, object=self) diff --git a/diva_evaluation_cli/bin/commands/actev_validate_execution.py b/diva_evaluation_cli/bin/commands/actev_validate_execution.py index b5594375b15da857ceb04a8dbe281bfa82006fec..829f59382af95005374ae3abc9fae845aa51ebd3 100644 --- a/diva_evaluation_cli/bin/commands/actev_validate_execution.py +++ b/diva_evaluation_cli/bin/commands/actev_validate_execution.py @@ -1,21 +1,10 @@ -""" -USAGE - -ActEV validation-execution -Description ------------ -Test the execution of the system on each validation data set provided in container_output directory. -Compare the newly generated to the expected output and the reference. - -Args ----- -output of o: path to experiment output json file -reference or r: path to reference json file -file-index or f: path to file index json file for test set -activity-index or a: path to activity index json file for test set -result or -R: path to result of the ActEV scorer +"""Actev module: validate-execution + +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ import logging @@ -24,14 +13,27 @@ from diva_evaluation_cli.bin.private_src.entry_points.actev_validate_execution i class ActevValidateExecution(ActevCommand): + """Test the execution of the system on each validation data set provided in container_output directory. + Compare the newly generated to the expected output and the reference. + + Command args: + * output of o: path to experiment output json file + * reference or r: path to reference json file + * file-index or f: path to file index json file for test set + * activity-index or a: path to activity index json file for test set + * result or -R: path to result of the ActEV scorer + + """ def __init__(self): super(ActevValidateExecution, self).__init__('validate-execution', entry_point) def cli_parser(self, arg_parser): - """ Configure the description and the arguments (positional and optional) to parse. + """Configure the description and the arguments (positional and optional) to parse. + + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command - @param arg_parser: python arg parser to describe how to parse the command """ arg_parser.description = "Test the execution of the system on each validation data set provided" required_named = arg_parser.add_argument_group('required named arguments') diff --git a/diva_evaluation_cli/bin/commands/actev_validate_system.py b/diva_evaluation_cli/bin/commands/actev_validate_system.py index 0f403a63a896275eec8cdebc5796096fedf8a3f2..e70875128d08983a3c3dce73e58b1790a84090ca 100644 --- a/diva_evaluation_cli/bin/commands/actev_validate_system.py +++ b/diva_evaluation_cli/bin/commands/actev_validate_system.py @@ -1,13 +1,12 @@ -""" -USAGE +"""Actev module: validate-system -ActEV validate-system -Description ------------ -Checks the structure of the directory after ActEV-system-setup is run. Checks for expected API contents, etc. +Actev modules are used to parse actev commands in order to get arguments +before calling associated entry point methods to execute systems. Warning: this file should not be modified: see src/entry_points to add your source code. + """ + import logging from diva_evaluation_cli.bin.commands.actev_command import ActevCommand @@ -15,14 +14,17 @@ from diva_evaluation_cli.bin.private_src.entry_points.actev_validate_system impo class ActevValidateSystem(ActevCommand): - + """Checks the structure of the directory after ActEV-system-setup is run. Checks for expected API contents, etc. + """ def __init__(self): super(ActevValidateSystem, self).__init__('validate-system', entry_point) def cli_parser(self, arg_parser): """ Configure the description and the arguments (positional and optional) to parse. - @param arg_parser: python arg parser to describe how to parse the command + Args: + arg_parser(:obj:`ArgParser`): Python arg parser to describe how to parse the command + """ arg_parser.description = "Checks the structure of the directory after ActEV-system-setup is run" arg_parser.set_defaults(func=ActevValidateSystem.command, object=self) diff --git a/diva_evaluation_cli/bin/private_src/entry_points/actev_exec.py b/diva_evaluation_cli/bin/private_src/entry_points/actev_exec.py index 8fc97e6234d837a8c54028b2553ffa23bd0dec27..df93997abf53e8be4a898d9a9d49f58d12c19ea2 100644 --- a/diva_evaluation_cli/bin/private_src/entry_points/actev_exec.py +++ b/diva_evaluation_cli/bin/private_src/entry_points/actev_exec.py @@ -1,13 +1,26 @@ -""" -ENTRY POINT +"""Entry point module: exec This file should not be modified. """ import os -def entry_point(file_index, activity_index, chunks, nb_videos_per_chunk, +def entry_point(file_index, activity_index, chunks, nb_videos_per_chunk, video_location, system_cache_dir, output_file, chunks_result, config_file=None): - """ Private entry points. + """Private entry point. + + Calls a team-implemented API. Captures time stamps, resource usage, etc. + + Args: + file_index (str): Path to file index json file for test set + activity_index (str): Path to activity index json file for test set + chunks (str): Path to chunks json file + nb-video-per-chunk (int): Number of videos in the chunk + video-location (str): Path to videos content + system-cache-dir (str): Path to system cache directory + output-file (str): Path to merge chunks command result + chunk_result (str): Path to chunks json file after merge chunks execution + config_file (str, optional): Path to config file + """ if not nb_videos_per_chunk: nb_videos_per_chunk = "96" diff --git a/diva_evaluation_cli/bin/private_src/entry_points/actev_experiment_init.py b/diva_evaluation_cli/bin/private_src/entry_points/actev_experiment_init.py index 42bf5dc136f4f2fde6dc8cba0791b5ebb2ee61ac..0d0e514fb3fdb7caaf54717fa6d13b26d0f502d9 100644 --- a/diva_evaluation_cli/bin/private_src/entry_points/actev_experiment_init.py +++ b/diva_evaluation_cli/bin/private_src/entry_points/actev_experiment_init.py @@ -1,5 +1,4 @@ -""" -ENTRY POINT +"""Entry point module: experiment-init This file should not be modified. """ @@ -9,7 +8,18 @@ from diva_evaluation_cli.bin.private_src.implementation.experiment_init.experime def before_entry_point(file_index, activity_index, chunks, video_location, system_cache_dir, config_file=None): - """ Private entry points. + """Private entry point. + + Start servers, starts cluster, etc. + + Args: + file_index(str): Path to file index json file for test set + activity_index(str): Path to activity index json file for test set + chunks (str): Path to chunks json file + video_location (str): Path to videos content + system_cache_dir (str): Path to system cache directory + config_file (str, optional): Path to config file + """ experiment_validation(file_index, video_location) diff --git a/diva_evaluation_cli/bin/private_src/entry_points/actev_get_system.py b/diva_evaluation_cli/bin/private_src/entry_points/actev_get_system.py index 46182953563a63a242c25a6aa10be9e228eaa1d4..0b41219b407b356d3caff3953232641892b432b0 100644 --- a/diva_evaluation_cli/bin/private_src/entry_points/actev_get_system.py +++ b/diva_evaluation_cli/bin/private_src/entry_points/actev_get_system.py @@ -1,5 +1,4 @@ -""" -ENTRY POINT +"""Entry point module: get-system This file should not be modified. """ @@ -7,13 +6,24 @@ import os from diva_evaluation_cli.bin.private_src.implementation.get_system.system_types_definition import system_types def entry_point(url, system_type, location=None, user=None, password=None, token=None, install_cli=False): - """ Private entry points. + """Private entry point. + + Downloads a credentialed, web-accessible content into src + + Args: + url (str): Url to get the system + location (str, optional): Path to store the system + user (str, optional): Username to access the url + password (str, optional): Password to access the url + token (str, optional): Token to access the url + install_cli (bool, optional): Information to know wether CLI has to be installed + """ try: command = system_types[system_type]() script = command.entry_point except: - raise Exception("Unknown system type") + raise Exception("Unknown system type") if not location: location = "None" diff --git a/diva_evaluation_cli/bin/private_src/entry_points/actev_status.py b/diva_evaluation_cli/bin/private_src/entry_points/actev_status.py index 6dd10933de19e57cef53caa43d898b1989a2537d..6ad7873468e56631a51aed4c5c48c845f8d10923 100644 --- a/diva_evaluation_cli/bin/private_src/entry_points/actev_status.py +++ b/diva_evaluation_cli/bin/private_src/entry_points/actev_status.py @@ -1,5 +1,4 @@ -""" -ENTRY POINT +"""Entry point module: status This file should not be modified. """ @@ -8,7 +7,13 @@ import os from diva_evaluation_cli.bin.private_src.implementation.status.check_status import check_status def entry_point(query_type, chunk_id=None): - """ Private entry points. + """Private entry point. + + Get the status of a chunk id + + Args: + query_type (str): status type desired + chunk_id (str, optional): chunk id """ check_status(query_type, chunk_id=chunk_id) diff --git a/diva_evaluation_cli/bin/private_src/entry_points/actev_validate_execution.py b/diva_evaluation_cli/bin/private_src/entry_points/actev_validate_execution.py index f2f5ff25cec1c606975fb2b125d41d12d8257b61..451bfd8d6cb95639ee1dce5ca4e3d262c69ba66e 100644 --- a/diva_evaluation_cli/bin/private_src/entry_points/actev_validate_execution.py +++ b/diva_evaluation_cli/bin/private_src/entry_points/actev_validate_execution.py @@ -1,12 +1,21 @@ -""" -ENTRY POINT +"""Entry point module: validate-execution This file should not be modified. """ import os def entry_point(output, reference, activity_index, file_index, result): - """ Private entry points. + """Private entry point. + + Test the execution of the system on each validation data set provided in container_output directory + + Args: + output (str): Path to experiment output json file + reference (str): Path to reference json file + file_index (str): Path to file index json file for test set + activity_index (str): Path to activity index json file for test set + result (str): Path to result of the ActEV scorer + """ # go into the right directory to execute the script path = os.path.dirname(__file__) diff --git a/diva_evaluation_cli/bin/private_src/entry_points/actev_validate_system.py b/diva_evaluation_cli/bin/private_src/entry_points/actev_validate_system.py index 94f9f54d31fc95899f9831d15c806192f5b4790e..5a4594fce4a661a38aac793ad350042fa038311a 100644 --- a/diva_evaluation_cli/bin/private_src/entry_points/actev_validate_system.py +++ b/diva_evaluation_cli/bin/private_src/entry_points/actev_validate_system.py @@ -1,5 +1,4 @@ -""" -ENTRY POINT +"""Entry point module: validate-system This file should not be modified. """ @@ -7,7 +6,10 @@ import os from diva_evaluation_cli.bin.private_src.implementation.validate_system.validate_system import validate_system def entry_point(): - """ Private entry points. + """Private entry point. + + Checks the structure of the directory after ActEV-system-setup is run. Checks for expected API contents, etc. + """ validate_system() diff --git a/diva_evaluation_cli/bin/private_src/implementation/exec/get_chunks_ids.py b/diva_evaluation_cli/bin/private_src/implementation/exec/get_chunks_ids.py index 84d37865e6e39d2386f5edc01f1180fcb1e35066..f3d7d5e0c1db3df7deb3e86f1e8649d43d2acd00 100644 --- a/diva_evaluation_cli/bin/private_src/implementation/exec/get_chunks_ids.py +++ b/diva_evaluation_cli/bin/private_src/implementation/exec/get_chunks_ids.py @@ -1,13 +1,16 @@ -""" -SOURCE - +"""Exec module: utils """ import json import sys def get_chunks_ids(chunk_file, output): - """ Get chunk ids from a chunk json file + """ Get chunk ids from a chunk json file. + + Args: + chunk_file (str): Path to a json chunk file + output (str): Path to the output file containing chunk ids + """ chunk_ids = [] chunks = json.load(open(chunk_file, 'r')) @@ -21,4 +24,4 @@ if __name__ == '__main__': get_chunks_ids(sys.argv[1], sys.argv[2]) - + diff --git a/diva_evaluation_cli/bin/private_src/implementation/experiment_init/experiment_validation.py b/diva_evaluation_cli/bin/private_src/implementation/experiment_init/experiment_validation.py index 1970c4af90eab986a5c7f0dd46ce18957adc79db..5bea13e5ff270435ad8b50d948292c60c9318a14 100644 --- a/diva_evaluation_cli/bin/private_src/implementation/experiment_init/experiment_validation.py +++ b/diva_evaluation_cli/bin/private_src/implementation/experiment_init/experiment_validation.py @@ -1,6 +1,4 @@ -""" -SOURCE - +"""Experiment init module """ import os @@ -8,6 +6,11 @@ import json def experiment_validation(file_index, video_location): """ Check that every video files enumerated in file_index exists, is readable and has content. + + Args: + file_index (str): Path to file index in json + video_location (str): Path to directory containing videos + """ with open(file_index) as f: file_dict = json.load(f) @@ -17,7 +20,7 @@ def experiment_validation(file_index, video_location): for video_filename in file_dict: file_index_exists = False - + for dirpath, dirnames, filenames in os.walk(video_location): for filename in filenames: if filename == video_filename: diff --git a/diva_evaluation_cli/bin/private_src/implementation/get_system/system_types_definition.py b/diva_evaluation_cli/bin/private_src/implementation/get_system/system_types_definition.py index 17c27f5e050d32857930d87b1073550f520b1885..558fe51e37a2b58b6e6be7c4c6aaea8b5ef3c130 100644 --- a/diva_evaluation_cli/bin/private_src/implementation/get_system/system_types_definition.py +++ b/diva_evaluation_cli/bin/private_src/implementation/get_system/system_types_definition.py @@ -1,9 +1,9 @@ -""" -SOURCE +"""Get system module: system types definition Dictionary of system types: -key: name of the system type -value: command to download the system + * key: name of the system type + * value: command to download the system + """ from diva_evaluation_cli.bin.commands.actev_get_system_subcommands.docker_command import ActevGetSystemDocker diff --git a/diva_evaluation_cli/bin/private_src/implementation/resources_monitoring/monitor.py b/diva_evaluation_cli/bin/private_src/implementation/resources_monitoring/monitor.py new file mode 100644 index 0000000000000000000000000000000000000000..52ca6fa49c61d24aac32569ebba3a6b9756f692a --- /dev/null +++ b/diva_evaluation_cli/bin/private_src/implementation/resources_monitoring/monitor.py @@ -0,0 +1,134 @@ +# -*- coding: utf-8 -*- +"""Monitor module + +This module implements the Module class, which monitors the execution +of a running process + +Attributes: + logger (:obj:`logging.logger`): Logger of the current module + +""" + +import json +import os +import psutil +import datetime, time +import logging + +from multiprocessing import * + +from diva_evaluation_cli.bin.private_src.implementation.resources_monitoring.nvml_handler import NvmlHandler +from diva_evaluation_cli.bin.private_src.implementation.resources_monitoring import utils + + +logger = logging.getLogger('MONITOR') + + +class Monitor(): + """Class that implements a monitor + + A Monitor object contains a python function + that will be run in parallel with a monitor process. + Once the `main_function` terminates, the monitoring thread terminates. + + Attributes: + main_function (function): Python function that will be run as a subprocess and monitored + args (Namespace): Arguments given when executing the `main_function` + command_name (str): Name of the command that will be monitored + interval (int): Interval (in *s*) to poll the system resources + log_file (str): File path to the logs file + + """ + + def __init__(self, main_function, args, command_name='default_command', interval=5): + """ + Args: + main_function (function): Python function that will be run as a subprocess and monitored + args (Namespace): Arguments given when executing the `main_function` + command_name (str, optional): Name of the command that will be monitored + interval (int, optional): Interval (in *s*) to poll the system resources + + """ + self.command_name = command_name + self.main_function = main_function + self.args = args + self.interval = interval + + log_file_path = os.path.dirname(__file__) + self.log_file = os.path.join(log_file_path, './resources_monitoring.json') + + + + def run_monitor(self): + """Runs the monitoring process + + The `main_function` in a process and the + `monitoring_process()` function in another. + + """ + + self.main_process = Process(target=self.main_function, kwargs=self.args.__dict__) + self.main_process.start() + + self.monitor = Process(target=self.monitor_resources) + self.monitor.start() + + while self.main_process.exitcode is None: + pass + + if self.main_process.exitcode != 0: + raise Exception + + + def increment_log_file(self, log_dict): + """Increment the file pointed by the `log_file` attribute with a new dict + + Note: + The existing `log_file` will be overwritten it it fails to load using JSON.load() + + Args: + log_dict (:obj:`dict`) A new dictionary to increment the existing log_file + + """ + + with open(self.log_file, 'a') as f: + f.write(json.dumps(log_dict) + ',\n') + + def monitor_resources(self): + """Fuction that runs every `interval` seconds to get the status of the + `main_process` + + Note: + The tried/catched block prevents the case where + the process supposed to be monitored is already gone + + """ + + # Try to retrieve the main_process + try: + process = psutil.Process(self.main_process.pid) + + # Load the NVIDIA handler + with NvmlHandler() as nvml_h: + while process.is_running() and process.status() != psutil.STATUS_ZOMBIE: + + # Gather resources use from psutil + resources_use = utils.psutil_snapshot() + + # Get status from the GPUs + resources_use.update({'gpus':nvml_h.get_devices_status()}) + + # Get the command that's currently run + resources_use.update({'command_line':self.command_name}) + + # Update the timestamp + resources_use.update({'timestamp':datetime.datetime.now().isoformat()}) + + # Increment the logs file + self.increment_log_file(resources_use) + + time.sleep(self.interval) + + except Exception as e: + logger.debug(e) + logger.debug('PID {} not available for monitoring'.format(self.main_process.pid)) diff --git a/diva_evaluation_cli/bin/private_src/implementation/resources_monitoring/nvml_handler.py b/diva_evaluation_cli/bin/private_src/implementation/resources_monitoring/nvml_handler.py new file mode 100644 index 0000000000000000000000000000000000000000..11b9db6ecfba2ce2be46e7ae751df03c456f4662 --- /dev/null +++ b/diva_evaluation_cli/bin/private_src/implementation/resources_monitoring/nvml_handler.py @@ -0,0 +1,138 @@ +# -*- coding: utf-8 -*- +"""NVML Handler module + +This module implements the NvmlHandler class, which interacts with the NVML +module to monitor the status of the NVIDIA GPU hardware + +Attributes: + logger (:obj: `logging.logger`): Logger of the current module + +""" + +from pynvml import * +import logging + +from diva_evaluation_cli.bin.private_src.implementation.resources_monitoring import utils + + +logger = logging.getLogger('MONITOR') + +class NvmlHandler(): + """Class to wrap the function to monitor NVIDIA GPUs using the pynvml package. + + This class is instanciated using a context manager to ensure that the NVML + pointers are destroyed. + + Attributes: + devices (:obj:`dict` of :obj:`NvmlObjects`): references pointers to the NVIDIA devices + + Example: + with NvmlHandler() as nvml_handler: + nvml_handler.get_devices_status() + + """ + + def __init__(self): + """Init the connection with NVML, + And stores the device handlers in a dictionary + + """ + nvmlInit() + n_devices = nvmlDeviceGetCount() + devices_handlers_list = [nvmlDeviceGetHandleByIndex(i) for i in range(n_devices)] + + self.devices = { + '{}-{}'.format(NvmlHandler.exec_nvml_function(nvmlDeviceGetName, device).decode('ascii'), i): device + for i, device in enumerate(devices_handlers_list) + } + + def __enter__(self): + """Called when instanciating the Object using a with: block + + """ + return self + + + def __exit__(self, exc_type, exc_value, traceback): + """Called to destroy the pointer to NVML + + """ + nvmlShutdown() + + + def get_devices_status(self): + """Get the status of the devices referenced in `devices` + + Returns: + {"device_name": {"key":"value", ...}, ...} with some relevant information from NVML + + """ + return { + + dev_name:{ + 'running_processes': self.get_running_processes(dev_handler), + 'gpu_memory_free': utils.psutil_parse_readable_bytes( + NvmlHandler.exec_nvml_function(nvmlDeviceGetMemoryInfo, dev_handler, 'free') + ), + 'gpu_memory_used': utils.psutil_parse_readable_bytes( + NvmlHandler.exec_nvml_function(nvmlDeviceGetMemoryInfo, dev_handler, 'used') + ) + } for dev_name, dev_handler in self.devices.items() + } + + def get_running_processes(self, dev_handler): + """Use the NVML's nvmlDeviceGetComputeRunningProcesses to get processes using the GPU, + And get some information about these processes using the psutil module + + """ + # Get the list of running processes on each device + running_processes = NvmlHandler.exec_nvml_function(nvmlDeviceGetComputeRunningProcesses,dev_handler) + + # Turns these process objects into dicts + running_processes_dicts = [obj.__dict__ for obj in running_processes if obj] + + # Enhance these dicts with information from psutil + new_dicts = [] + for running_processes_dict in running_processes_dicts: + + # Init the new dict with the current information + more_ps_infos = {} + more_ps_infos.update(running_processes_dict) + + # Rename the usedGpuMemory key, if any + if 'usedGpuMemory' in more_ps_infos: + more_ps_infos['gpu_memory_used'] = utils.psutil_parse_readable_bytes( + more_ps_infos.get('usedGpuMemory') + ) + del more_ps_infos['usedGpuMemory'] + + # Try to retreive info about the process using psutil + try: + pid = running_processes_dict.get('pid') + more_ps_infos.update(utils.psutil_snapshot_process(pid)) + except Exception as e: + logger.warning('Cannot gather info from process {}'.format(pid)) + + new_dicts.append(more_ps_infos) + + return new_dicts + + @staticmethod + def exec_nvml_function(nvml_func, dev_handler, attr=None): + """Wrapper arount the NVML functions: they will send exceptions + if an attribute is unavailable + + Args: + nvml_func (:`function`): NVML function to execute + dev_handler (:obj:`NvmlObjects`): Pointer to a device + attr (str, optional): Attribute to get from the object returned from `nvml_func` + + """ + try: + obj = nvml_func(dev_handler) + if attr: + return getattr(obj, attr) + return obj + + except Exception as e: + return None diff --git a/diva_evaluation_cli/bin/private_src/implementation/resources_monitoring/utils.py b/diva_evaluation_cli/bin/private_src/implementation/resources_monitoring/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..a607435b111fca8c74101bf736d3c78cfda80578 --- /dev/null +++ b/diva_evaluation_cli/bin/private_src/implementation/resources_monitoring/utils.py @@ -0,0 +1,105 @@ +"""Monitor module: utils module for resource monitoring + +""" +import psutil + + +def psutil_snapshot(): + """ Take a snapshot of cpu and memory usage + """ + snapshot_dict = {} + + snapshot_dict = { + 'total_cpus_usage': psutil.cpu_percent(interval=1, percpu=True), + 'total_memory_used': psutil_parse_readable_bytes( + psutil.virtual_memory().used + ), + 'total_memory': psutil_parse_readable_bytes( + psutil.virtual_memory().total + ), + 'total_disk_io_read': psutil_parse_readable_bytes( + psutil.disk_io_counters(perdisk=False, nowrap=True).read_bytes + ), + 'total_disk_io_write': psutil_parse_readable_bytes( + psutil.disk_io_counters(perdisk=False, nowrap=True).write_bytes + ) + } + + return snapshot_dict + + +def psutil_snapshot_process(pid, snap_children=True): + """ + + Return the psutil.Process attribute in a dictionnary + Monitor the children too if desc_children + + Args: + pid (int): Pid to monitor + snap_children (boolean): Whether to recurse the function on the process' children + + Returns: + dict: resources usage for a given pid and its children:: + + if snap_children + {'command':'some_command', ...} + else: + {'command':'some_command', ... {'children': [ + {'command':'some_command', ... {'children': {} }}}, + ... ] + }} + + """ + proc = psutil.Process(pid) + pic = {} + + with proc.oneshot(): + + if proc.is_running() and proc.status()!=psutil.STATUS_ZOMBIE: + + all_info = proc.as_dict() + + pic['command'] = ' '.join(all_info.get('cmdline')) + pic['num_threads'] = all_info.get('num_threads') + + mem_info = all_info.get('memory_info') + pic['memory_used'] = psutil_parse_readable_bytes(mem_info.rss) if mem_info else None + + + if snap_children: + # Collect descendant prcesses' info + children = proc.children() + if len(children) > 0: + pic["children"] = [] + for c in children: + cPic = shot(c.pid, snap_children) + pic["children"].append(cPic) + return pic + + +def psutil_parse_readable_bytes(n_bytes): + """Parse a number of byte in a human readable format + + Args: + n_bytes (:obj:) Number of bytes, castable to an int + + Returns: + Human readable abount of bytes in the best memory unit possible + + Examples: + >>> psutil_parse_readable_bytes(10000) + '9.8K' + >>> psutil_parse_readable_bytes(100001221) + '95.4M' + + """ + n = int(n_bytes) + symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y') + prefix = {} + for i, s in enumerate(symbols): + prefix[s] = 1 << (i + 1) * 10 + for s in reversed(symbols): + if n >= prefix[s]: + value = float(n) / prefix[s] + return '%.1f%s' % (value, s) + return "%sB" % n diff --git a/diva_evaluation_cli/bin/private_src/implementation/status/check_status.py b/diva_evaluation_cli/bin/private_src/implementation/status/check_status.py index 5a3d4a393305b83b2c167be05017540e4a76250e..325edcd204289bafb23554f958bf4d43f9ec742d 100644 --- a/diva_evaluation_cli/bin/private_src/implementation/status/check_status.py +++ b/diva_evaluation_cli/bin/private_src/implementation/status/check_status.py @@ -1,6 +1,6 @@ -""" -SOURCE +"""Status module: check status +Contains methods to check status of each type of queries: system, experiment and chunks """ import json @@ -9,7 +9,22 @@ import os ###### Check chunk ############################################################ def check_status_chunk(query_type, command_history_dict, status_dict, **kwargs): - """ Check status of a specific chunk id during experiment processing + """Check status of a specific chunk id during experiment processing. + + Use the process-chunk state to get the status of a given chunk id. + + Args: + query_type (str): Type of status query, chunk in this case + command_history_dict (:obj: `dict`): Dictionary of this form:: + + {'command name': [{'status': 'start', id: '98', args: {...}} ...], ...} + + status_dict (:obj: `dict`): Dictionary of status according to a query type, a command name and a state + **kwargs: Arbitrary keyword arguments + + Return: + str: status of the chunk id + """ chunk_id = kwargs.get('chunk_id', None) status = 'Not processed' @@ -21,18 +36,35 @@ def check_status_chunk(query_type, command_history_dict, status_dict, **kwargs): while process_chunk['status'] != 'not defined': if chunk_id == process_chunk['args']['chunk_id']: if process_chunk['id'] > experiment_init_id: - status = get_status(query_type, process_chunk_command, process_chunk_status, status_dict) + status = get_status(query_type, process_chunk_command, process_chunk_status, status_dict) break process_chunk = command_history_dict['process-chunk'].pop() + process_chunk_status = process_chunk['status'] return status ###### Check experiment ####################################################### def check_status_experiment(query_type, command_history_dict, status_dict, **kwargs): - """ Check status of the experiment during the process + """Check status of the experiment during the process. + + Use the experiment-init and cleanup and commands between (except pre/post/reset/process-chunk) to + get status of the experiment. + + Args: + query_type (str): Type of status query, chunk in this case + command_history_dict (:obj: `dict`): Dictionary of this form:: + + {'command name': [{'status': 'start', id: '98', args: {...}} ...], ...} + + status_dict (:obj: `dict`): Dictionary of status according to a query type, a command name and a state + **kwargs: Arbitrary keyword arguments + + Return: + str: status of the experiment + """ - experiment_init_command = 'experiment-init' + experiment_init_command = 'experiment-init' experiment_cleanup_command = 'experiment-cleanup' # Determine status of experiment-init first @@ -45,7 +77,7 @@ def check_status_experiment(query_type, command_history_dict, status_dict, **kwa experiment_cleanup_status = experiment_cleanup['status'] experiment_cleanup_id = experiment_cleanup['id'] - status = get_status(query_type, experiment_init_command, experiment_init_status, status_dict) + status = get_status(query_type, experiment_init_command, experiment_init_status, status_dict) max_id = experiment_init_id # Determine status of all the commands between experiment-init and cleanup @@ -84,31 +116,47 @@ def check_status_experiment(query_type, command_history_dict, status_dict, **kwa def check_status_system(query_type, command_history_dict, status_dict, **kwargs): """ Check status of the system. + + Use the system-setup state to get the status of the system. + + Args: + query_type (str): Type of status query, chunk in this case + command_history_dict (:obj: `dict`): Dictionary of this form:: + + {'command name': [{'status': 'start', id: '98', args: {...}} ...], ...} + + status_dict (:obj: `dict`): Dictionary of status according to a query type, a command name and a state + **kwargs: Arbitrary keyword arguments + + Return: + str: status of the system + """ command = 'system-setup' - system_status = command_history_dict[command].pop()['status'] + system_status = command_history_dict[command].pop()['status'] status = get_status(query_type, command, system_status, status_dict) return status ###### Main check function #################################################### def check_status(query_type, **kwargs): - """ Check status of a component of the system to know wether it is running properly + """ Check status of a component of the system to know wether it is running properly. - @param query_type: string representing the type of the component to check_status + Args: + query_type (str): Type of the component whose status has to be checked """ status_methods = {'chunk-query': check_status_chunk, 'experiment-query': check_status_experiment, 'system-query': check_status_system} path = os.path.dirname(__file__) - command_history_json = os.path.join(path, './command_history.json') + command_history_json = os.path.join(path, './command_state_monitoring.json') status_json = os.path.join(path, './status.json') with open(command_history_json) as f: command_history_dict = json.load(f) - with open(status_json) as f: + with open(status_json) as f: status_dict = json.load(f) status = status_methods[query_type](query_type, command_history_dict, status_dict, **kwargs) @@ -116,6 +164,15 @@ def check_status(query_type, **kwargs): def get_status(query_type, command, execution_status, status_dict): """ Get the status code of a command according to a query + + Args: + query_type (str): Type of status query, chunk in this case + command (str): Command name + execution_status: State of the last given command execution + status_dict (:obj: `dict`): Dictionary of status according to a query type, a command name and a state + + Return: + str: status according to query type, command and execution status """ return status_dict[query_type][command][execution_status] diff --git a/diva_evaluation_cli/bin/private_src/implementation/status/query_types_definition.py b/diva_evaluation_cli/bin/private_src/implementation/status/query_types_definition.py index 1103beb0a24b2abf0c7c4a7b776d44de3c949e07..b7b16edac6c68cf1f9a42038533bc320fb6da6b1 100644 --- a/diva_evaluation_cli/bin/private_src/implementation/status/query_types_definition.py +++ b/diva_evaluation_cli/bin/private_src/implementation/status/query_types_definition.py @@ -1,9 +1,8 @@ -""" -SOURCE +"""Status module: query types definition Dictionary of system types: -key: name of the query type -value: command to get status + * key: name of the query type + * value: command to get status """ from diva_evaluation_cli.bin.commands.actev_status_subcommands.chunk_query_command import ActevStatusChunkQuery diff --git a/diva_evaluation_cli/bin/private_src/implementation/status/status_factory.py b/diva_evaluation_cli/bin/private_src/implementation/status/status_factory.py index 08786d33b6b9d4e35a0603fe5872449cfd611bc5..800583598bd77c4460cd6ad07e8d14a8d52277fa 100644 --- a/diva_evaluation_cli/bin/private_src/implementation/status/status_factory.py +++ b/diva_evaluation_cli/bin/private_src/implementation/status/status_factory.py @@ -1,21 +1,27 @@ -""" -SOURCE +"""Status module """ import json import os class StatusFactory(): + """Generate state of a given command each time it is called. + """ @staticmethod def generateStatus(command, status, args): - """ Generate a dictionary inside a json file containing status of the commands + """Generate a dictionary inside a json file containing status of the commands + + Args: + command (str): command name + status (str): state of the command ('Starting', 'Done', 'Not defined', 'Issue') + """ from diva_evaluation_cli.bin.cli import public_subcommands - + status_id = 0 path = os.path.dirname(__file__) - status_log = os.path.join(path, './command_history.json') + status_log = os.path.join(path, './command_state_monitoring.json') json_status = {} if not os.path.isfile(status_log) or os.stat(status_log).st_size == 0: @@ -23,13 +29,13 @@ class StatusFactory(): json_status[subcommand.command] = [{'status': 'not defined', 'id': status_id, 'args': None}] status_id += 1 json_status['id'] = status_id - else: + else: with open(status_log, 'r') as f: json_status = json.load(f) if command in public_subcommands: json_status['id'] += 1 json_status[command.command].append({'status': status, 'id': json_status['id'], 'args': args}) - + with open(status_log, 'w+') as f: json.dump(json_status, f) diff --git a/diva_evaluation_cli/bin/private_src/implementation/utils/is_virtual_env.py b/diva_evaluation_cli/bin/private_src/implementation/utils/is_virtual_env.py index 09d96dcf0ddde0cc832a4a98d765526388c66d45..939b7a3a96fa2be7d96e6d92fdc781c480751cdb 100644 --- a/diva_evaluation_cli/bin/private_src/implementation/utils/is_virtual_env.py +++ b/diva_evaluation_cli/bin/private_src/implementation/utils/is_virtual_env.py @@ -1,7 +1,6 @@ -""" -UTILS - +"""Utils module +Can be used by any other module of the CLI Determine if python is running in a virtual environment """ import sys diff --git a/diva_evaluation_cli/bin/private_src/implementation/validate_system/validate_system.py b/diva_evaluation_cli/bin/private_src/implementation/validate_system/validate_system.py index 312ad33c9d2b316d0508ee6b40563ab06685a37c..e4da1b785e099e33c6d74468823ef4a541b8955c 100644 --- a/diva_evaluation_cli/bin/private_src/implementation/validate_system/validate_system.py +++ b/diva_evaluation_cli/bin/private_src/implementation/validate_system/validate_system.py @@ -1,5 +1,4 @@ -""" -SOURCE +"""Validate system module Used by the command validate-system """ @@ -12,6 +11,8 @@ import sys root_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../../') def validate_system(): + """Main validation method + """ validate_structure() validate_cli() validate_container_output() @@ -20,6 +21,8 @@ def validate_system(): ############################### structure ##################################### def validate_structure(): + """Validate structure of the CLI: should contain required directories. + """ directories = os.listdir(root_path) content = import_expected_result('expected_structure.txt') logging.info("Structure validation") @@ -63,6 +66,10 @@ def validate_cli(): def import_expected_result(file_name): """ Import expected validation result + + Args: + file_name (str): Path to file to open in order to extract lines inside a list + """ content = [] path = os.path.dirname(__file__) @@ -87,7 +94,8 @@ def validate_container_output(): files = os.listdir(dataset_id_path) content = import_expected_result('expected_container_output.txt') for file_name in content: - if not file_name in files: - raise Exception("System validation failed, {} not present in {}".format(file_name, dataset_id)) + dataset_filename = dataset_id + '_' + file_name + if not dataset_filename in files: + raise Exception("System validation failed, {} not present in {}".format(dataset_filename, dataset_id)) logging.info(" .. {} is valid".format(dataset_id)) diff --git a/diva_evaluation_cli/container_output/cli_validation_mini/activity.json b/diva_evaluation_cli/container_output/cli_validation_mini/cli_validation_mini_activity.json similarity index 100% rename from diva_evaluation_cli/container_output/cli_validation_mini/activity.json rename to diva_evaluation_cli/container_output/cli_validation_mini/cli_validation_mini_activity.json diff --git a/diva_evaluation_cli/container_output/cli_validation_mini/cli_validation_mini_chunk.json b/diva_evaluation_cli/container_output/cli_validation_mini/cli_validation_mini_chunk.json new file mode 100644 index 0000000000000000000000000000000000000000..1b8238dadb2ff1a41474e71b215daa609c14d8a6 --- /dev/null +++ b/diva_evaluation_cli/container_output/cli_validation_mini/cli_validation_mini_chunk.json @@ -0,0 +1,26 @@ +{ + "Chunk1": { + "activities": [ + "Loading", + "Closing_Trunk", + "Exiting", + "Entering", + "Closing" + ], + "files": [ + "VIRAT_S_000000.mp4" + ] + }, + "Chunk2": { + "activities": [ + "Loading", + "Closing_Trunk", + "Exiting", + "Entering", + "Closing" + ], + "files": [ + "VIRAT_S_000001.mp4" + ] + } +} \ No newline at end of file diff --git a/diva_evaluation_cli/container_output/cli_validation_mini/file.json b/diva_evaluation_cli/container_output/cli_validation_mini/cli_validation_mini_file.json similarity index 100% rename from diva_evaluation_cli/container_output/cli_validation_mini/file.json rename to diva_evaluation_cli/container_output/cli_validation_mini/cli_validation_mini_file.json diff --git a/diva_evaluation_cli/container_output/cli_validation_mini/output.json b/diva_evaluation_cli/container_output/cli_validation_mini/cli_validation_mini_output.json similarity index 100% rename from diva_evaluation_cli/container_output/cli_validation_mini/output.json rename to diva_evaluation_cli/container_output/cli_validation_mini/cli_validation_mini_output.json diff --git a/diva_evaluation_cli/src/entry_points/actev_design_chunks.py b/diva_evaluation_cli/src/entry_points/actev_design_chunks.py index 42f3a8869c9a371fb0377637170432909cac983c..f8e0620dfc11d0c03761f7fb826a35bf4d07e031 100644 --- a/diva_evaluation_cli/src/entry_points/actev_design_chunks.py +++ b/diva_evaluation_cli/src/entry_points/actev_design_chunks.py @@ -1,13 +1,22 @@ -""" -ENTRY POINT +"""Entry point module: design-chunks Implements the entry-point by using Python or any other languages. + """ import argparse import json def entry_point(file_index, activity_index, output, nb_videos_per_chunk): - """ Method to complete: you have to raise an exception if an error occured in the program. + """Method to complete: you have to raise an exception if an error occured in the program. + + Given a file index and an activity index, produce a chunks file that is suitable for the system. + + Args: + file_index (str): Path to file index json file for test set + activity_index (str): Path to activity index json file for test set + output (str): Path to save chunks file + nb_video_per_chunk (int): Number of videos in the chunk + """ raise NotImplementedError("You should implement the entry_point method.") diff --git a/diva_evaluation_cli/src/entry_points/actev_experiment_cleanup.py b/diva_evaluation_cli/src/entry_points/actev_experiment_cleanup.py index 8a16f5272763092cdc9adf516e120891d68b55dc..bcb4047adbb31c2bc0294f497ef32467d29fafd7 100644 --- a/diva_evaluation_cli/src/entry_points/actev_experiment_cleanup.py +++ b/diva_evaluation_cli/src/entry_points/actev_experiment_cleanup.py @@ -1,11 +1,14 @@ -""" -ENTRY POINT +"""Entry point module: experiment-cleanup Implements the entry-point by using Python or any other languages. + """ import os def entry_point(): - """ Method to complete: you have to raise an exception if an error occured in the program. + """Method to complete: you have to raise an exception if an error occured in the program. + + Close any servers, terminates cluster (future functionality), etc. + """ raise NotImplementedError("You should implement the entry_point method.") diff --git a/diva_evaluation_cli/src/entry_points/actev_experiment_init.py b/diva_evaluation_cli/src/entry_points/actev_experiment_init.py index 6838e53583de5b04fd44a45b8e5a5420569b09e0..9b945562b30f02383f15740ef5341a878d61e0fa 100644 --- a/diva_evaluation_cli/src/entry_points/actev_experiment_init.py +++ b/diva_evaluation_cli/src/entry_points/actev_experiment_init.py @@ -1,12 +1,23 @@ -""" -ENTRY POINT +"""Entry point module: experiment-init Implements the entry-point by using Python or any other languages. + """ import os -def entry_point(file_index, activity_index, chunks, +def entry_point(file_index, activity_index, chunks, video_location, system_cache_dir, config_file=None): - """ Method to complete: you have to raise an exception if an error occured in the program. + """Method to complete: you have to raise an exception if an error occured in the program. + + Start servers, starts cluster, etc. + + Args: + file_index(str): Path to file index json file for test set + activity_index(str): Path to activity index json file for test set + chunks (str): Path to chunks json file + video_location (str): Path to videos content + system_cache_dir (str): Path to system cache directory + config_file (str, optional): Path to config file + """ raise NotImplementedError("You should implement the entry_point method.") diff --git a/diva_evaluation_cli/src/entry_points/actev_merge_chunks.py b/diva_evaluation_cli/src/entry_points/actev_merge_chunks.py index 542b79d8513eca21af287740c0bc07be4c23f965..1efbe2f66815cea08d534cfbaeaba3de29744561 100644 --- a/diva_evaluation_cli/src/entry_points/actev_merge_chunks.py +++ b/diva_evaluation_cli/src/entry_points/actev_merge_chunks.py @@ -1,13 +1,22 @@ -""" -ENTRY POINT +"""Entry point module: merge-chunks Implements the entry-point by using Python or any other languages. + """ import argparse import json def entry_point(result_location, output_file, chunks_file, chunk_ids): - """ Method to complete: you have to raise an exception if an error occured in the program. + """Method to complete: you have to raise an exception if an error occured in the program. + + Given a list of chunk ids, merges all the chunks system output present in the list. + + Args: + result_location (str): Path to get the result of the chunks processing + chunk_file (str): Path to directory where intermediate system output is stored + output_file (str): Path to the output file generated + chunk_ids (:obj:`list`): List of chunk ids + """ raise NotImplementedError("You should implement the entry_point method.") diff --git a/diva_evaluation_cli/src/entry_points/actev_post_process_chunk.py b/diva_evaluation_cli/src/entry_points/actev_post_process_chunk.py index 5e056f4abe0894b1f1814922a5283e73ceeb8f44..907807c1ac15dac7a005c34d6e170318f9c740cb 100644 --- a/diva_evaluation_cli/src/entry_points/actev_post_process_chunk.py +++ b/diva_evaluation_cli/src/entry_points/actev_post_process_chunk.py @@ -1,11 +1,18 @@ -""" -ENTRY POINT +"""Entry point module: post-process-chunk Implements the entry-point by using Python or any other languages. + """ import os def entry_point(chunk_id, system_cache_dir): - """ Method to complete: you have to raise an exception if an error occured in the program. + """Method to complete: you have to raise an exception if an error occured in the program. + + Post-process a chunk. + + Args: + chunk_id (str): Chunk id + system_cache_dir (str): Path to system cache directory + """ raise NotImplementedError("You should implement the entry_point method.") diff --git a/diva_evaluation_cli/src/entry_points/actev_pre_process_chunk.py b/diva_evaluation_cli/src/entry_points/actev_pre_process_chunk.py index 5e056f4abe0894b1f1814922a5283e73ceeb8f44..79b78ff355ba3b264c1582ae67d5305286777f06 100644 --- a/diva_evaluation_cli/src/entry_points/actev_pre_process_chunk.py +++ b/diva_evaluation_cli/src/entry_points/actev_pre_process_chunk.py @@ -1,11 +1,18 @@ -""" -ENTRY POINT +"""Entry point module: pre-process-chunk Implements the entry-point by using Python or any other languages. + """ import os def entry_point(chunk_id, system_cache_dir): - """ Method to complete: you have to raise an exception if an error occured in the program. + """Method to complete: you have to raise an exception if an error occured in the program. + + Pre-process a chunk. + + Args: + chunk_id (str): Chunk id + system_cache_dir (str): Path to system cache directory + """ raise NotImplementedError("You should implement the entry_point method.") diff --git a/diva_evaluation_cli/src/entry_points/actev_process_chunk.py b/diva_evaluation_cli/src/entry_points/actev_process_chunk.py index 2bb0c5993816da6ccd9d8f41afa8acd4e42e6ec0..8e701adfadc7d3f036b7a935d03bc9cff91339c4 100644 --- a/diva_evaluation_cli/src/entry_points/actev_process_chunk.py +++ b/diva_evaluation_cli/src/entry_points/actev_process_chunk.py @@ -1,12 +1,19 @@ -""" -ENTRY POINT +"""Entry point module: process-chunk Implements the entry-point by using Python or any other languages. + """ import os import re def entry_point(chunk_id, system_cache_dir): - """ Method to complete: you have to raise an exception if an error occured in the program. + """Method to complete: you have to raise an exception if an error occured in the program. + + Process a chunk. + + Args: + chunk_id (str): Chunk id + system_cache_dir (str): Path to system cache directory + """ raise NotImplementedError("You should implement the entry_point method.") diff --git a/diva_evaluation_cli/src/entry_points/actev_reset_chunk.py b/diva_evaluation_cli/src/entry_points/actev_reset_chunk.py index 5e056f4abe0894b1f1814922a5283e73ceeb8f44..7f3708ad156d9c805dd3697eae66a31d80427569 100644 --- a/diva_evaluation_cli/src/entry_points/actev_reset_chunk.py +++ b/diva_evaluation_cli/src/entry_points/actev_reset_chunk.py @@ -1,11 +1,17 @@ -""" -ENTRY POINT +"""Entry point module: reset-chunk Implements the entry-point by using Python or any other languages. + """ import os def entry_point(chunk_id, system_cache_dir): - """ Method to complete: you have to raise an exception if an error occured in the program. + """Method to complete: you have to raise an exception if an error occured in the program. + + Delete all cached information for ChunkID so that the chunk can be re-run. + + Args: + chunk_id (str): Chunk id + system_cache_dir (str): Path to system cache directory """ raise NotImplementedError("You should implement the entry_point method.") diff --git a/diva_evaluation_cli/src/entry_points/actev_system_setup.py b/diva_evaluation_cli/src/entry_points/actev_system_setup.py index 8a16f5272763092cdc9adf516e120891d68b55dc..bc2eaab7a81b535229e75ee85fa2b746f3d174c0 100644 --- a/diva_evaluation_cli/src/entry_points/actev_system_setup.py +++ b/diva_evaluation_cli/src/entry_points/actev_system_setup.py @@ -1,11 +1,14 @@ -""" -ENTRY POINT +"""Entry point module: system-setup Implements the entry-point by using Python or any other languages. + """ import os def entry_point(): - """ Method to complete: you have to raise an exception if an error occured in the program. + """Method to complete: you have to raise an exception if an error occured in the program. + + Run any compilation/preparation steps for the system. + """ raise NotImplementedError("You should implement the entry_point method.") diff --git a/requirements.txt b/requirements.txt index 66072c764505566d4de11368aeadd3c41318fa8f..fc6cb56945615e2d13e21f363a59eb51ae75feab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ +psutil +nvidia-ml-py3 virtualenv