Coverage for sparkle/CLI/status.py: 96%

28 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-05 14:48 +0000

1#!/usr/bin/env python3 

2"""Command to display the status of the platform.""" 

3import sys 

4import argparse 

5 

6from sparkle.CLI.initialise import check_for_initialise 

7from sparkle.CLI.help import global_variables as gv 

8from sparkle.CLI.help import system_status as sssh 

9from sparkle.CLI.help import logging as sl 

10from sparkle.CLI.help import argparse_custom as ac 

11 

12 

13def parser_function() -> argparse.ArgumentParser: 

14 """Define the command line arguments.""" 

15 parser = argparse.ArgumentParser(description="Display the status of the platform.") 

16 parser.add_argument(*ac.VerboseArgument.names, 

17 **ac.VerboseArgument.kwargs) 

18 return parser 

19 

20 

21def main(argv: list[str]) -> None: 

22 """Main function of the status command.""" 

23 # Log command call 

24 sl.log_command(sys.argv) 

25 

26 # Define command line arguments 

27 parser = parser_function() 

28 

29 # Process command line arguments 

30 args = parser.parse_args(argv) 

31 

32 check_for_initialise() 

33 

34 print("Reporting current system status of Sparkle ...") 

35 sssh.print_sparkle_list([s for s in gv.settings().DEFAULT_solver_dir.iterdir()], 

36 "Solver", args.verbose) 

37 sssh.print_sparkle_list([e for e in gv.settings().DEFAULT_extractor_dir.iterdir()], 

38 "Extractor", args.verbose) 

39 sssh.print_sparkle_list([i for i in gv.settings().DEFAULT_instance_dir.iterdir()], 

40 "Instance Set", args.verbose) 

41 

42 sssh.print_feature_computation_jobs( 

43 gv.settings().DEFAULT_feature_data_path, args.verbose 

44 ) 

45 sssh.print_performance_computation_jobs( 

46 gv.settings().DEFAULT_performance_data_path, args.verbose 

47 ) 

48 

49 # scan configurator log files for warnings 

50 configurator = gv.settings().get_general_sparkle_configurator() 

51 configurator.get_status_from_logs() 

52 

53 print("\nCurrent system status of Sparkle reported!") 

54 sys.exit(0) 

55 

56 

57if __name__ == "__main__": 

58 main(sys.argv[1:])