Skip to content

Commit

Permalink
report: fix presubmit warnings (#444)
Browse files Browse the repository at this point in the history
There's a handful of warnings when changing things in report/common.py
and this fixes them all.

---------

Signed-off-by: David Korczynski <[email protected]>
  • Loading branch information
DavidKorczynski authored Jul 7, 2024
1 parent fe9f3bb commit 6e93ece
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions report/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ def getsize(self) -> int:


class Results:
"""Results provides functions to explore the experiment results in a particular directory."""
"""Results provides functions to explore the experiment results in a
particular directory."""

def __init__(self, results_dir='results', benchmark_set='all'):
self._results_dir = results_dir
Expand Down Expand Up @@ -274,7 +275,8 @@ def get_run_logs(self, benchmark: str, sample: str) -> str:
if name.startswith(sample + '.'):
iteration = WorkDirs.get_run_log_iteration(name)
if iteration is None:
# Be compatible with older results where no '-Fxx' in run log file name
# Be compatible with older results where there is no '-Fxx' in run
# log file name.
last_log_file = name
break

Expand Down Expand Up @@ -349,6 +351,7 @@ def get_samples(self, results: list[evaluator.Result],
return samples

def get_prompt(self, benchmark: str) -> Optional[str]:
"""Gets the prompt for a given benchmark."""
root_dir = os.path.join(self._results_dir, benchmark)
for name in FileSystem(root_dir).listdir():
if re.match(r'^prompt.*txt$', name):
Expand Down Expand Up @@ -412,14 +415,14 @@ def _prepare_prompt_for_html_text(self, raw_prompt_content: str) -> str:
return html_presentable_content
except json.decoder.JSONDecodeError:
logging.debug('Using raw prompt text.')
pass

# If execution goes here it the input was not a structured prompt but just
# raw text, which is then returned.
return raw_prompt_content

def _is_valid_benchmark_dir(self, cur_dir: str) -> bool:
"""Checks if |cur_dir| is a valid benchmark directory (e.g., no lost+found)."""
"""Checks if |cur_dir| is a valid benchmark directory (e.g., no lost+found).
"""
# Check prefix.
if not cur_dir.startswith('output-'):
return False
Expand Down

0 comments on commit 6e93ece

Please sign in to comment.