Commit a20c82d5 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

Add proper doc to command line parser

parent bbeba75f
......@@ -36,14 +36,6 @@ LOGGER = cm.logger()
def launch_researchs(args):
"""Parse arguments and launch Cadbiom search of MACs
(Minimal Activation Conditions).
- If there is no input file, there will be only one process.
- If an input file is given, there will be 1 process per line (per logical
formula on each line).
- all_macs: Solver will try to search all macs with 0 to
the maximum of steps allowed.
- continue: If there is a mac file from a previous work, last frontier
places will be reloaded.
"""
# Module import
......@@ -64,10 +56,6 @@ def launch_sort(args):
def parse_trajectories(args):
"""Parse a complete solution file and make a representation of trajectories.
The output is in graphml file format and is exported in 'graphs' directory.
.. note:: Requires the model file.
"""
# Module import
......@@ -87,8 +75,6 @@ def model_comp(args):
Check if the 2 given models have the same topology,
nodes & edges attributes/roles.
.. note:: You can export a graphml file for the 2 models.
"""
# Module import
......@@ -109,8 +95,6 @@ def model_infos(args):
"""Model informations.
Get number of nodes, edges, centralities (degree, closeness, betweenness).
.. note:: You can export a graphml file for model.
"""
# Module import
......@@ -128,10 +112,7 @@ def model_infos(args):
def merge_cams(args):
"""Merge solutions to a csv file.
.. note:: CSV file: <Final property formula>;<cam>
"""
"""Merge solutions to a csv file."""
# Module import
import solution_merge
......@@ -192,6 +173,7 @@ class ReadableDir(argparse.Action):
def main():
"""Argument parser"""
# parser configuration
parser = argparse.ArgumentParser(description=__doc__)
......@@ -206,27 +188,40 @@ def main():
# final_prop = "P"
# start_prop = None
# inv_prop = None
parser_input_file = subparsers.add_parser('compute_macs',
help=launch_researchs.__doc__)
parser_input_file = subparsers.add_parser(
'compute_macs',
help=launch_researchs.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser_input_file.add_argument('chart_file')
# parser_input_file.add_argument('final_prop')
# Get final_property alone OR an input_file containing multiple properties
group = parser_input_file.add_mutually_exclusive_group()
group.add_argument('final_prop', nargs='?')
group.add_argument('--input_file', action=ReadableFile, nargs='?')
# If input_file is set, we can compute all combinations of given elements
group.add_argument('--input_file', action=ReadableFile, nargs='?',
help="Without input file, there will be only one process. " + \
"While there will be 1 process per line (per logical formula " + \
"on each line)")
parser_input_file.add_argument('--output', action=ReadableDir, nargs='?',
default='result/', help="Output directory.")
# default: False
parser_input_file.add_argument('--combinations', action='store_true')
parser_input_file.add_argument('--steps', type=int, nargs='?', default=10)
parser_input_file.add_argument('--combinations', action='store_true',
help="If input_file is set, we can compute all combinations of " + \
"given elements on each line")
parser_input_file.add_argument('--steps', type=int, nargs='?', default=10,
help="Maximum of allowed steps to find macs")
# https://docs.python.org/dev/library/argparse.html#action
# all_macs to False by default
parser_input_file.add_argument('--all_macs', action='store_true')
parser_input_file.add_argument('--all_macs', action='store_true',
help="Solver will try to search all macs with 0 to the maximum of " + \
"allowed steps.")
# continue to False by default
parser_input_file.add_argument('--continue', action='store_true')
parser_input_file.add_argument('--continue', action='store_true',
help="Resume previous computations; if there is a mac file from " + \
"a previous work, last frontier places will be reloaded.")
parser_input_file.add_argument('--start_prop', nargs='?', default=None)
parser_input_file.add_argument('--inv_prop', nargs='?', default=None)
parser_input_file.add_argument('--output', action=ReadableDir, nargs='?',
default='result/')
parser_input_file.set_defaults(func=launch_researchs)
......@@ -234,59 +229,84 @@ def main():
# Solution file (complete or not)
parser_solutions_sort = subparsers.add_parser('sort_solutions',
help=launch_sort.__doc__)
parser_solutions_sort.add_argument('sol_file')
parser_solutions_sort.add_argument('sol_file',
help="Solution file (output of 'compute_macs' command).")
parser_solutions_sort.set_defaults(func=launch_sort)
# subparser: Representation of the trajectories of MACs in a complete file.
# Model file (xml : cadbiom language)
# Solution file (cam_complete)
parser_trajectories = subparsers.add_parser('parse_trajectories',
help=parse_trajectories.__doc__)
parser_trajectories.add_argument('chart_file')
parser_trajectories.add_argument('sol_file')
parser_trajectories = subparsers.add_parser(
'parse_trajectories',
help=parse_trajectories.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser_trajectories.add_argument('chart_file',
help="bcx model file.")
parser_trajectories.add_argument('sol_file',
help="Solution file (output of 'compute_macs' command).")
parser_trajectories.add_argument('--output', action=ReadableDir,
nargs='?', default='graphs/')
nargs='?', default='graphs/',
help="Output directory for graphml files.")
parser_trajectories.set_defaults(func=parse_trajectories)
# subparser: Merge solutions to a csv file
# Solution file (cam)
# Output (csv)
parser_merge_cams = subparsers.add_parser('merge_cams',
help=merge_cams.__doc__)
parser_merge_cams = subparsers.add_parser(
'merge_cams',
help=merge_cams.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser_merge_cams.add_argument('solutions_directory', nargs='?',
default='result/')
default='result/')
parser_merge_cams.add_argument('--output', nargs='?',
default='result/merged_cams.csv')
default='result/merged_cams.csv',
help="CSV file: <Final property formula>;<cam>")
parser_merge_cams.set_defaults(func=merge_cams)
# subparser: Model comparison
# 2 models
parser_model_comparison = subparsers.add_parser('model_comp',
help=model_comp.__doc__)
parser_model_comparison.add_argument('model_file_1')
parser_model_comparison.add_argument('model_file_2')
parser_model_comparison = subparsers.add_parser(
'model_comp',
help=model_comp.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser_model_comparison.add_argument('model_file_1',
help="bcx model file.")
parser_model_comparison.add_argument('model_file_2',
help="bcx model file.")
# Export graphs for the 2 models; default: false
parser_model_comparison.add_argument('--graphs', action='store_true')
parser_model_comparison.add_argument('--json', action='store_true')
parser_model_comparison.add_argument('--graphs', action='store_true',
help="Create 2 graphml files from the given models.")
parser_model_comparison.add_argument('--json', action='store_true',
help="Create a summary dumped into a json file.")
parser_model_comparison.add_argument('--output', action=ReadableDir,
nargs='?', default='graphs/')
nargs='?', default='graphs/',
help="Directory for created graphs files.")
parser_model_comparison.set_defaults(func=model_comp)
# subparser: Model infos
# 1 model
parser_model_infos = subparsers.add_parser('model_infos',
help=model_infos.__doc__)
parser_model_infos = subparsers.add_parser(
'model_infos',
help=model_infos.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser_model_infos.add_argument('model_file')
# Export graphs for the 2 models; default: false
parser_model_infos.add_argument('--graph', action='store_true')
parser_model_infos.add_argument('--json', action='store_true')
parser_model_infos.add_argument('--advanced', action='store_true')
parser_model_infos.add_argument('--graph', action='store_true',
help="Create a graphml file from the model.")
parser_model_infos.add_argument('--json', action='store_true',
help="Create a summary dumped into a json file.")
parser_model_infos.add_argument('--advanced', action='store_true',
help="Get centralities (degree, closeness, betweenness).")
parser_model_infos.add_argument('--output', action=ReadableDir,
nargs='?', default='graphs/')
nargs='?', default='graphs/',
help="Directory for created graphs files.")
parser_model_infos.set_defaults(func=model_infos)
......
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