Attention une mise à jour du service Gitlab va être effectuée le mardi 18 janvier (et non lundi 17 comme annoncé précédemment) entre 18h00 et 18h30. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

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

[cmd] add json, graphs, csv options to queries_2_common_graph; add checking...

[cmd] add json, graphs, csv options to queries_2_common_graph; add checking routines to force at least 1 flag
parent 7d9f163c
...@@ -34,6 +34,7 @@ from functools import wraps ...@@ -34,6 +34,7 @@ from functools import wraps
import cadbiom.commons as cm import cadbiom.commons as cm
LOGGER = cm.logger() LOGGER = cm.logger()
parser = None
def check_output_dir(function): def check_output_dir(function):
...@@ -146,11 +147,9 @@ def queries_2_common_graph(args): ...@@ -146,11 +147,9 @@ def queries_2_common_graph(args):
# Module import # Module import
import solution_sort import solution_sort
solution_sort.queries_2_common_graph( if not any((args["graphs"], args["csv"], args["json"])):
args['output'], parser.error("at least one flag is required")
args['model_file'], solution_sort.queries_2_common_graph(**args)
args['path']
)
@check_output_dir @check_output_dir
...@@ -337,6 +336,7 @@ def main(): ...@@ -337,6 +336,7 @@ def main():
"""Argument parser""" """Argument parser"""
# parser configuration # parser configuration
global parser
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
# Default log level: debug # Default log level: debug
parser.add_argument('-vv', '--verbose', nargs='?', default='info') parser.add_argument('-vv', '--verbose', nargs='?', default='info')
...@@ -477,6 +477,15 @@ def main(): ...@@ -477,6 +477,15 @@ def main():
parser_trajectories.add_argument('path', parser_trajectories.add_argument('path',
help="Complete solution file or directory with MAC solutions files " help="Complete solution file or directory with MAC solutions files "
"(*mac_complete.txt files) generated with the 'compute_macs' command.") "(*mac_complete.txt files) generated with the 'compute_macs' command.")
# Outputs
parser_trajectories.add_argument('--graphs', action='store_true',
help="Create a GraphML file for each MAC file.")
parser_trajectories.add_argument('--csv', action='store_true',
help="Create a CSV file containing a summary about places/entities "
"of the solutions.")
parser_trajectories.add_argument('--json', action='store_true',
help="Create a JSON formated file containing a summary about "
"places/entities of the solutions.")
parser_trajectories.add_argument('--output', action=ReadableDir, parser_trajectories.add_argument('--output', action=ReadableDir,
nargs='?', default='graphs/', nargs='?', default='graphs/',
help="Output directory for GraphML files.") help="Output directory for GraphML files.")
......
...@@ -346,7 +346,8 @@ def get_solution_graphs(sol_steps, transitions): ...@@ -346,7 +346,8 @@ def get_solution_graphs(sol_steps, transitions):
def queries_2_common_graph(output_dir, model_file, path, def queries_2_common_graph(output_dir, model_file, path,
make_graphs=True, make_csv=False, make_json=False): make_graphs=True, make_csv=False, make_json=False,
*args, **kwargs):
"""Entry point for solutions_2_common_graph """Entry point for solutions_2_common_graph
Create a GraphML formated file containing a unique representation of **all** Create a GraphML formated file containing a unique representation of **all**
...@@ -483,6 +484,11 @@ def queries_2_common_graph(output_dir, model_file, path, ...@@ -483,6 +484,11 @@ def queries_2_common_graph(output_dir, model_file, path,
# Check valid input file/directory # Check valid input file/directory
assert os.path.isfile(path) or os.path.isdir(path) assert os.path.isfile(path) or os.path.isdir(path)
# Bind arguments to avoid overwriting previous imports
make_graphs = kwargs['graphs']
make_json = kwargs['json']
make_csv = kwargs['csv']
# Get transitions from the model # Get transitions from the model
model_transitions, parser = get_transitions_from_model_file(model_file) model_transitions, parser = get_transitions_from_model_file(model_file)
......
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