Skip to content

Commit

Permalink
Add log links into output reports
Browse files Browse the repository at this point in the history
Closes #117
  • Loading branch information
WarmCyan committed Dec 6, 2023
1 parent 1015a40 commit 6d59483
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions curifactory/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,12 @@ def generate_report(self):
)
self.live_report_path_generated = True

# copy the log into the report folder if it exists
log_path = os.path.join(self.logs_path, f"{self.get_reference_name()}.log")
if os.path.exists(log_path):
target_log_path = os.path.join(self.live_report_paths[0], "log.txt")
shutil.copy(log_path, target_log_path)

# link it into the "_latest" report
report_path = os.path.join(self.reports_path, self.get_reference_name())
latest_path = os.path.join(self.reports_path, "_latest")
Expand Down
2 changes: 2 additions & 0 deletions curifactory/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@ def render_report_info_block( # noqa: C901 -- TODO: yeaaaaah break it up at som
notes = notes.replace("\n", "</br>")
html_lines.append(f"<p>{notes}</p>")

html_lines.append("<a href='log.txt'>View log</a>")

return html_lines


Expand Down
22 changes: 22 additions & 0 deletions test/test_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,25 @@ def test_all_relevant_reports_generated(configured_test_manager):
assert os.path.exists(
f"{configured_test_manager.get_run_output_path()}/report/index.html"
)


def test_log_copied_to_report(configured_test_manager):
"""A copy of the log should be included in the report folder."""
configured_test_manager.store_full = True
run_experiment(
"simple_cache",
["simple_cache"],
param_set_names=["thing1", "thing2"],
mngr=configured_test_manager,
store_full=True,
)

assert os.path.exists(
f"{configured_test_manager.reports_path}/{configured_test_manager.get_reference_name()}/log.txt"
)

assert os.path.exists(f"{configured_test_manager.reports_path}/_latest/log.txt")

assert os.path.exists(
f"{configured_test_manager.get_run_output_path()}/report/log.txt"
)

0 comments on commit 6d59483

Please sign in to comment.