-
Notifications
You must be signed in to change notification settings - Fork 0
/
forward_cli.py
executable file
·75 lines (56 loc) · 1.97 KB
/
forward_cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python
# This file is part of forward.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to Creative
# Commons, PO Box 1866, Mountain View, CA 94042, USA.
from __future__ import print_function
"""
Command line interface script to run gene-phenome experiments using the forward
package.
"""
import argparse
from forward.configuration import parse_configuration
from forward import backend
def run_from_configuration(yaml_file):
# Run an experiment.
experiment = parse_configuration(yaml_file)
experiment.run_tasks()
print()
print("To view the interactive report, use the forward-cli script:")
print()
print("forward-cli report {}".format(experiment.name))
print()
def show_report(experiment_name):
backend.initialize_application(experiment_name)
backend.serve()
def parse_args():
description = ("Command line utility to run Forward or to launch the "
"interactive report.")
parser = argparse.ArgumentParser(description=description)
subparser = parser.add_subparsers(dest="command")
run_parser = subparser.add_parser(
"run",
help=("Run a YAML configuration file to file to execute the Forward "
"experiment.")
)
run_parser.add_argument(
"yaml_filename",
help="Path to the YAML configuration file."
)
report_parser = subparser.add_parser(
"report",
help="Serve the report locally (A web browser is needed)."
)
report_parser.add_argument(
"experiment",
help="Name of the experiment for the dynamic report."
)
args = parser.parse_args()
if args.command == "run":
return run_from_configuration(args.yaml_filename)
if args.command == "report":
return show_report(args.experiment)
if __name__ == "__main__":
parse_args()