Skip to content

Commit

Permalink
Fix Bug When Reading Directories (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmckinsey1 authored Sep 6, 2024
1 parent 29197ea commit e956f5a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
32 changes: 31 additions & 1 deletion thicket/tests/test_reader_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_empty_iterable():


def test_file_not_found():
with pytest.raises(FileNotFoundError, match="File 'blah' not found"):
with pytest.raises(ValueError, match="Path 'blah' not found"):
Thicket.reader_dispatch(
GraphFrame.from_caliperreader,
False,
Expand Down Expand Up @@ -58,3 +58,33 @@ def test_valid_type():
True,
-1,
)


def test_valid_inputs(rajaperf_cali_1trial, data_dir):

# Works with list
Thicket.reader_dispatch(
GraphFrame.from_caliperreader,
False,
True,
True,
rajaperf_cali_1trial,
)

# Works with single file
Thicket.reader_dispatch(
GraphFrame.from_caliperreader,
False,
True,
True,
rajaperf_cali_1trial[0],
)

# Works with directory
Thicket.reader_dispatch(
GraphFrame.from_caliperreader,
False,
True,
True,
f"{data_dir}/rajaperf/lassen/clang10.0.1_nvcc10.2.89_1048576/1/",
)
4 changes: 2 additions & 2 deletions thicket/thicket.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ def reader_dispatch(
if not os.path.isfile(file):
raise FileNotFoundError("File '" + file + "' not found")
elif isinstance(obj, str):
if not os.path.isfile(obj):
raise FileNotFoundError("File '" + obj + "' not found")
if not os.path.exists(obj):
raise ValueError("Path '" + obj + "' not found")
else:
raise TypeError(
"'" + str(type(obj).__name__) + "' is not a valid type to be read from"
Expand Down

0 comments on commit e956f5a

Please sign in to comment.