tool.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import sys
  2. import os
  3. import json
  4. # from lemon_master.mutation_executor import lemon_process
  5. from lemon_master.run.mutation_executor import lemon_process
  6. def mock(exp: str, root_dir: str, output_dir: str, mutate_num: int, config_name: str):
  7. print("running")
  8. print("exp:", exp)
  9. print("root_dir:", root_dir)
  10. print("out_dir:", output_dir)
  11. print("mutate_num:", mutate_num)
  12. print("config_name:", config_name)
  13. data = [
  14. {
  15. "model": "lenet5-fashion-mnist",
  16. "method": "origin0",
  17. "result": {
  18. "Losses": 0.3032414233312011,
  19. "Accuracy": 0.9062593914568424,
  20. "MemoryInfoList": 1.2329671382904053,
  21. },
  22. }
  23. ]
  24. return data
  25. # result_num = 0
  26. def runtool(
  27. exp: str, mutate_num: int,task_id:str
  28. ):
  29. global result_num
  30. config_name = "demo.conf"
  31. base_dir = os.path.dirname(os.path.abspath(__file__))
  32. print(base_dir)
  33. # result_num = ( result_num + 1 ) % 5
  34. output_dir = os.path.join(base_dir, "output", task_id)
  35. if os.path.exists(output_dir):
  36. print("remove output_dir:", output_dir)
  37. # TODO: 正式时需要删除 os.system("rm -rf " + output_dir)
  38. print("running")
  39. print("exp:", exp)
  40. print("out_dir:", output_dir)
  41. print("mutate_num:", mutate_num)
  42. print("config_name:", config_name)
  43. root_dir = os.path.join(base_dir, "lemon_master")
  44. target_dir = os.path.join(base_dir, "lemon_master", "run")
  45. print(target_dir)
  46. sys.path.append(target_dir)
  47. # 执行任务
  48. # TODO: 正式时需要注释lemon_process(exp, root_dir, output_dir, mutate_num, config_name)
  49. lemon_process(exp, root_dir, output_dir, mutate_num, config_name)
  50. # real_output_dir = os.path.join(output_dir, exp)
  51. # mxnet_json = os.path.join(real_output_dir, "mxnet.json")
  52. # with open(
  53. # mxnet_json, "r"
  54. # ) as file1: # tensorflow.json
  55. # data1 = json.load(file1)
  56. # tensorflow_json = os.path.join(real_output_dir, "tensorflow.json")
  57. # with open(tensorflow_json, "r") as file2:
  58. # data2 = json.load(file2)
  59. # combined_data = {
  60. # "mxnet": data1,
  61. # "tensorflow": data2
  62. # }
  63. # return combined_data
  64. return "success"