Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError raised #58

Merged
merged 3 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
FileNotFoundError raised
  • Loading branch information
venaturum committed Aug 1, 2024
commit f96c7591de96c22fd255be6e5239ba8b56d1cb19
10 changes: 8 additions & 2 deletions src/gurobi_logtools/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,12 @@ def parse(patterns: Union[str, List[str]], write_to_dir=None) -> ParseResult:
result = ParseResult(write_to_dir=write_to_dir)
if type(patterns) is str:
patterns = [patterns]
logfiles = itertools.chain(*(glob.glob(pattern) for pattern in patterns))
for logfile in sorted(set(logfiles)):
logfiles = sorted(
set(itertools.chain(*(glob.glob(pattern) for pattern in patterns)))
)
if not len(logfiles):
raise FileNotFoundError(f"No logfiles found in patterns: {patterns}")
for logfile in logfiles:
result.parse(logfile)
return result

Expand All @@ -190,8 +194,10 @@ def get_dataframe(logfiles: List[str], timelines=False, prettyparams=False):
"""
result = parse(logfiles)
summary = result.summary(prettyparams=prettyparams)

if not timelines:
return summary

return summary, dict(
norel=result.progress("norel"),
rootlp=result.progress("rootlp"),
Expand Down
5 changes: 5 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,8 @@ def test_rewrite_filenames():
assert log_file.stem == expected_name
assert len(start_lines) == 1
assert len(end_lines) == 1


def test_no_logfile_error():
with pytest.raises(FileNotFoundError):
glt.parse("/file/with/a/tyop")