8 folder_name_results =
"results"
9 folder_name_html_static =
"html_static"
10 folder_name_html =
"html"
11 folder_name_html_plots =
"plots"
14 folder_name_plots =
"plots"
15 folder_name_general =
"__general__"
16 file_name_results_json =
"revision.json"
17 file_name_comparison_json =
"comparison.json"
18 file_name_runtimes_dat =
"runtimes.dat"
22 return {
'local': os.environ.get(
'BELLE2_LOCAL_DIR',
None),
23 'central': os.environ.get(
'BELLE2_RELEASE_DIR',
None)}
27 """ Because of issues of too long filenames if the number of revision
28 is growing, the simple recipe of creating folder names by concatenating
29 the names of the revisions does not work.
30 Therefore, we use a hashing algorithm. At the same time we want to be
31 able to look up the folder content easily, so we create a rainbow table,
32 that is a simple text file that contains hash <> revisions.
36 """ Read a json file which was produced by the ``to_json`` method and
37 update this dictionary. If the path does not exist, do nothing. """
38 if os.path.exists(path):
39 with open(path)
as infile:
40 self.update(json.load(infile))
43 """ Write out this dictionary as a json file. """
44 os.makedirs(os.path.dirname(path), exist_ok=
True)
45 with open(path,
"w")
as outfile:
46 json.dump(self, outfile, indent=4, sort_keys=
True)
49 """ Read json file (if exists) for anything the dictionary
50 doesn't contain yet and write everything back. """
61 def get_results_runtime_file(output_base_dir):
63 Return the absolute path to the runtimes.dat file
64 As there is only the runtimes file of the last iteration stored, this is
65 located in the topmost work folder
67 return os.path.join(output_base_dir, file_name_runtimes_dat)
70 def get_results_folder(output_base_dir):
72 Return the absolute path to the results folder
74 return os.path.join(output_base_dir, folder_name_results)
77 def get_html_folder(output_base_dir):
79 Return the absolute path to the results folder
81 return os.path.join(output_base_dir, folder_name_html)
84 def get_html_plots_folder(output_base_dir):
86 Return the absolute path to generated plots in the html folder
88 return os.path.join(get_html_folder(output_base_dir), folder_name_plots)
91 def get_html_plots_tag_comparison_folder(output_base_dir, tags):
93 Return the absolute path to the results folder
95 string =
",".join(sorted(tags))
96 tag_folder = hashlib.sha1(string.encode(
"utf8")).hexdigest()[:10]
97 if tag_folder
not in RAINBOW_TABLE:
98 RAINBOW_TABLE[tag_folder] = sorted(tags)
99 RAINBOW_TABLE.update_to_json(
100 os.path.join(get_html_plots_folder(output_base_dir),
"rainbow.json")
103 get_html_plots_folder(output_base_dir),
108 def get_html_plots_tag_comparison_json(output_base_dir, tags):
110 Return the absolute path json file with the comparison file
113 get_html_plots_tag_comparison_folder(output_base_dir, tags),
114 file_name_comparison_json
118 def get_results_tag_folder(output_base_dir, tag):
120 Return the absolute path to the results folder for one specific tag
122 return os.path.join(get_results_folder(output_base_dir), tag)
125 def get_results_tag_general_folder(output_base_dir, tag):
127 Return the absolute path to the results folder for one specific
128 tag. In this general folder, the common log files will be placed
131 get_results_tag_folder(output_base_dir, tag),
136 def get_results_tag_revision_file(output_base_dir, tag):
138 Return the absolute path to the revision.json file for one tag folder
141 get_results_tag_folder(output_base_dir, tag),
142 file_name_results_json
146 def get_results_tag_package_folder(output_base_dir, tag, package):
148 Returns the absolute path for a tag and package. This folder will contain
149 the ROOT files plots which will be displayed on the validation website
152 get_results_tag_folder(output_base_dir, tag),