15folder_name_results =
"results"
16folder_name_html_static =
"html_static"
17folder_name_html =
"html"
18folder_name_html_plots =
"plots"
21folder_name_plots =
"plots"
22folder_name_general =
"__general__"
23file_name_results_json =
"revision.json"
24file_name_comparison_json =
"comparison.json"
25file_name_runtimes_dat =
"runtimes.dat"
30 "local": os.environ.get(
"BELLE2_LOCAL_DIR",
None),
31 "central": os.environ.get(
"BELLE2_RELEASE_DIR",
None),
36 """ Because of issues of too long filenames if the number of revision
37 is growing, the simple recipe of creating folder names by concatenating
38 the names of the revisions does
not work.
39 Therefore, we use a hashing algorithm. At the same time we want to be
40 able to look up the folder content easily, so we create a rainbow table,
41 that
is a simple text file that contains hash <> revisions.
45 """ Read a json file which was produced by the ``to_json`` method and
46 update this dictionary. If the path does not exist, do nothing.
"""
47 if os.path.exists(path):
48 with open(path)
as infile:
49 self.update(json.load(infile))
52 """ Write out this dictionary as a json file. """
53 os.makedirs(os.path.dirname(path), exist_ok=
True)
54 with open(path,
"w")
as outfile:
55 json.dump(self, outfile, indent=4, sort_keys=
True)
58 """ Read json file (if exists) for anything the dictionary
59 doesn't contain yet and write everything back. """
70def get_results_runtime_file(output_base_dir):
72 Return the absolute path to the runtimes.dat file
73 As there is only the runtimes file of the last iteration stored, this
is
74 located
in the topmost work folder
76 return os.path.join(output_base_dir, file_name_runtimes_dat)
79def get_results_folder(output_base_dir):
81 Return the absolute path to the results folder
83 return os.path.join(output_base_dir, folder_name_results)
86def get_html_folder(output_base_dir):
88 Return the absolute path to the results folder
90 return os.path.join(output_base_dir, folder_name_html)
93def get_html_plots_folder(output_base_dir):
95 Return the absolute path to generated plots in the html folder
97 return os.path.join(get_html_folder(output_base_dir), folder_name_plots)
100def get_html_plots_tag_comparison_folder(output_base_dir, tags):
102 Return the absolute path to the results folder
104 string = ",".join(sorted(tags))
105 tag_folder = hashlib.sha1(string.encode(
"utf8")).hexdigest()[:10]
106 if tag_folder
not in RAINBOW_TABLE:
107 RAINBOW_TABLE[tag_folder] = sorted(tags)
108 RAINBOW_TABLE.update_to_json(
109 os.path.join(get_html_plots_folder(output_base_dir),
"rainbow.json")
111 return os.path.join(get_html_plots_folder(output_base_dir), tag_folder)
114def get_html_plots_tag_comparison_json(output_base_dir, tags):
116 Return the absolute path json file with the comparison file
119 get_html_plots_tag_comparison_folder(output_base_dir, tags),
120 file_name_comparison_json,
124def get_results_tag_folder(output_base_dir, tag):
126 Return the absolute path to the results folder for one specific tag
128 return os.path.join(get_results_folder(output_base_dir), tag)
131def get_results_tag_general_folder(output_base_dir, tag):
133 Return the absolute path to the results folder for one specific
134 tag. In this general folder, the common log files will be placed
137 get_results_tag_folder(output_base_dir, tag), folder_name_general
141def get_results_tag_revision_file(output_base_dir, tag):
143 Return the absolute path to the revision.json file for one tag folder
146 get_results_tag_folder(output_base_dir, tag), file_name_results_json
150def get_results_tag_package_folder(output_base_dir, tag, package):
152 Returns the absolute path for a tag
and package. This folder will contain
153 the ROOT files plots which will be displayed on the validation website
155 return os.path.join(get_results_tag_folder(output_base_dir, tag), package)
None to_json(self, str path)
None update_from_json(self, str path)
None update_to_json(self, str path)