utils.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import json
  2. def fetch_param_file_path() -> str:
  3. return '/home/jovyan/WORKFLOW/FLOW/param_files/params.json'
  4. def fetch_monitoring_param_file_path() -> str:
  5. return '/home/jovyan/WORKFLOW/FLOW/param_files/monitoring_params.json'
  6. def reflect_monitoring_results(monitoring_item, isOK: bool) -> None:
  7. # モニタリング観点名とnotebookへのパスとを取得
  8. path_params = fetch_param_file_path()
  9. params = {}
  10. with open(path_params, 'r') as f:
  11. params = json.load(f)
  12. nb = params['monitoring'][monitoring_item]
  13. # nb['name']: モニタリング観点名(str)
  14. # nb['path']: Notebookへのパス(str)
  15. # READMEの内容を取得する
  16. with open("/home/jovyan/README.md", "r") as f:
  17. readme = f.read()
  18. point1 = readme.find("| " + nb['name'] + " |")
  19. output = readme[:point1]
  20. # 該当する行を書き換え
  21. output += "| " + nb['name'] + " | [" + ("OK" if isOK else "NG") + "](" + nb['path'] + ") |"
  22. point2 = readme[point1:].find("\n")
  23. output += readme[point1 + point2:]
  24. with open("/home/jovyan/README.md", "w") as f:
  25. f.write(output)