COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
check.py
1 #!/usr/bin/env python
2 """script test to simulate a closed loop
3 
4 Usage:
5  check.py <parameters_filename> [options]
6 
7 where parameters_filename is the path to the parameters file
8 
9 Options:
10  -h --help Show this help message and exit
11  -d, --devices devices Specify the devices
12  --displayResult Just print the results of the check process
13  --repportResult=<repport.md> Save the results of the check process into a md_file
14 """
15 
16 from docopt import docopt
17 
18 if __name__ == "__main__":
19  import pandas
20  from shesha.supervisor.compassSupervisor import CompassSupervisor
21 
22  arguments = docopt(__doc__)
23 
24  if arguments["--displayResult"]:
25  from os import remove
26  from tabulate import tabulate
27  from datetime import datetime
28  df = pandas.read_hdf("check.h5")
29  print(tabulate(df, tablefmt="pipe", headers="keys"))
30  if arguments["--repportResult"]:
31  with open(arguments["--repportResult"], 'w') as the_file:
32  the_file.write('# E2E Test Report\n')
33  the_file.write('\n')
34  the_file.write(datetime.now().strftime(
35  '*Report generated on %d-%b-%Y %H:%M:%S by checkCompass.sh*\n'))
36  the_file.write('\n')
37  the_file.write('[Unit Tests report](report_unit_test.html)\n')
38  the_file.write('\n')
39  the_file.write('## Summary\n')
40  the_file.write('\n')
41  the_file.write(str(tabulate(df, tablefmt="pipe", headers="keys")))
42  remove("check.h5")
43  else:
44  # Get parameters from file
45  param_file = arguments["<parameters_filename>"]
46  supervisor = CompassSupervisor(param_file)
47 
48  if arguments["--devices"]:
49  supervisor.config.p_loop.set_devices([
50  int(device) for device in arguments["--devices"].split(",")
51  ])
52  try:
53  supervisor.init()
54  is_init = supervisor.is_init
55  except:
56  is_init = False
57  SR = "N/A"
58  try:
59  supervisor.loop(supervisor.config.p_loop.niter)
60  SR = supervisor.target.get_strehl(0)[1]
61  except:
62  SR = "N/A"
63 
64  try:
65  df = pandas.read_hdf("check.h5")
66  except FileNotFoundError:
67  columns = ["Test name", "Init", "SR@100iter"]
68  df = pandas.DataFrame(columns=columns)
69 
70  idx = len(df.index)
71  df.loc[idx, "Test name"] = param_file.split('/')[-1]
72  df.loc[idx, "Init"] = is_init
73  df.loc[idx, "SR@100iter"] = SR
74 
75  df.to_hdf("check.h5", "check")
shesha.supervisor.compassSupervisor
Initialization and execution of a COMPASS supervisor.
Definition: compassSupervisor.py:1
carma_utils::split
void split(std::vector< std::string > &tokens, const std::string &text, char sep)
Definition: carma_utils.h:94
shesha.supervisor.compassSupervisor.CompassSupervisor
This class implements generic supervisor to handle compass simulation.
Definition: compassSupervisor.py:57