single_run.py 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. ##################################################################
  4. #
  5. # Copyright (c) 2023 CICV, Inc. All Rights Reserved
  6. #
  7. ##################################################################
  8. """
  9. @Authors: yangzihao(yangzihao@china-icv.cn)
  10. @Data: 2024/01/30
  11. @Last Modified: 2024/01/30
  12. @Summary: Evaluateion functions
  13. """
  14. import os
  15. import sys
  16. import time
  17. import json
  18. import traceback
  19. import pandas as pd
  20. from single_case_eval import single_case_eval
  21. import log
  22. if __name__ == "__main__":
  23. # import warnings
  24. # warnings.filterwarnings("ignore")
  25. from warnings import simplefilter
  26. # simplefilter(action="ignore", category=FutureWarning)
  27. simplefilter(action="ignore")
  28. if len(sys.argv) >= 8:
  29. configPath = sys.argv[1]
  30. dataPath = sys.argv[2]
  31. reportPath = sys.argv[3]
  32. csvPath = sys.argv[4]
  33. logPath = sys.argv[5]
  34. customMetricPath = sys.argv[6]
  35. customScorePath = sys.argv[7]
  36. if len(sys.argv) >= 9:
  37. playbackPath = sys.argv[8]
  38. else:
  39. playbackPath = sys.argv[4] + "_playback.csv"
  40. if len(sys.argv) > 9:
  41. case_name = sys.argv[9]
  42. else:
  43. case_name = os.path.basename(os.path.dirname(dataPath))
  44. log.setup_logger(logPath)
  45. logger = log.get_logger()
  46. if not os.path.exists(configPath):
  47. print('Invalid configPath!')
  48. logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid configPath!")
  49. sys.exit(-1)
  50. elif not os.path.exists(dataPath):
  51. print('Invalid dataPath!')
  52. logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid dataPath!")
  53. sys.exit(-1)
  54. elif not os.path.exists(customMetricPath):
  55. print('Invalid customMetricPath!')
  56. logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid customMetricPath!")
  57. sys.exit(-1)
  58. elif not os.path.exists(customScorePath):
  59. print('Invalid customScorePath!')
  60. logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid customScorePath!")
  61. sys.exit(-1)
  62. else:
  63. try:
  64. logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: Start evaluating:")
  65. print("SINGLE_CASE_EVAL程序开始运行:")
  66. print(f" configPath: {configPath},\n dataPath: {dataPath},\n reportPath: {reportPath},\n "
  67. f"csvPath: {csvPath},\n logPath: {logPath},\n customMetricPath: {customMetricPath}\n "
  68. f"customScorePath: {customScorePath},\n caseName: {case_name}")
  69. t1 = time.time()
  70. single_case_eval(configPath, dataPath, reportPath, csvPath, playbackPath, customMetricPath,
  71. customScorePath, case_name)
  72. t2 = time.time()
  73. print(f"程序结束,执行时间:{int(t2 - t1)} s")
  74. logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: End.")
  75. sys.exit(0)
  76. except Exception as e:
  77. print("异常如下:")
  78. traceback.print_exc()
  79. else:
  80. logPath = sys.argv[5]
  81. log.setup_logger(logPath)
  82. logger = log.get_logger()
  83. print('SINGLE_CASE_EVAL: No enough arguments!')
  84. logger.error(f"SINGLE_CASE_EVAL: No enough arguments!")
  85. sys.exit(-1)