Skip to content

Commit

Permalink
Update usage from os.path to pathlib.Path (cont'd)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-caron committed Dec 9, 2024
1 parent 3da9b6a commit 8957201
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions qpbenchmark/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


def parse_command_line_arguments(
test_set_path: Optional[Union[str, Path]] = None,
test_set_path: Optional[Union[Path, str]] = None,
) -> argparse.Namespace:
"""Extracts and interprets command line arguments passed to the script.
Expand Down Expand Up @@ -196,7 +196,7 @@ def load_test_set(path: str) -> TestSet:
return TestClass()


def report(args, results: Results, test_set_path: str):
def report(args, results: Results, test_set_path: Union[Path, str]):
"""Write report to file.
Args:
Expand All @@ -213,15 +213,15 @@ def report(args, results: Results, test_set_path: str):
report = Report(author, results)
if results.csv_path is None:
raise BenchmarkError("not sure where to save report: no results file")
results_dir = os.path.dirname(results.csv_path)
test_set_name = os.path.basename(test_set_path).replace(".py", "")
results_dir = results.csv_path.parent
test_set_name = Path(test_set_path).name.replace(".py", "")
md_path = f"{results_dir}/{test_set_name}.md"
report.write(md_path)


def main(
test_set_path: Optional[Union[str, Path]] = None,
results_path: Optional[Union[str, Path]] = None,
test_set_path: Optional[Union[Path, str]] = None,
results_path: Optional[Union[Path, str]] = None,
):
"""Main function of the script.
Expand Down
2 changes: 1 addition & 1 deletion qpbenchmark/parquet_test_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class ParquetTestSet(TestSet):
"""Test set read from a Parquet file."""

def __init__(self, path: Union[str, Path]):
def __init__(self, path: Union[Path, str]):
"""Initialize test set.
Args:
Expand Down
4 changes: 2 additions & 2 deletions qpbenchmark/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def check_df(df) -> None:
raise ResultsError('"found" column has some non-boolean values')

def __init__(
self, csv_path: Optional[Union[str, Path]], test_set: TestSet
self, csv_path: Optional[Union[Path, str]], test_set: TestSet
):
"""Initialize results.
Expand Down Expand Up @@ -96,7 +96,7 @@ def nb_rows(self) -> int:
"""Number of rows in the dataframe."""
return self.df.shape[0]

def write(self, path: Optional[Union[str, Path]] = None) -> None:
def write(self, path: Optional[Union[Path, str]] = None) -> None:
"""Write results to their CSV file for persistence.
Args:
Expand Down

0 comments on commit 8957201

Please sign in to comment.