diff --git a/.github/workflows/ruff.yaml b/.github/workflows/ruff.yaml index 23e3c7e..d12b4f5 100644 --- a/.github/workflows/ruff.yaml +++ b/.github/workflows/ruff.yaml @@ -25,4 +25,7 @@ jobs: cd ../../ cd stgraph/graph ruff check . + cd ../../ + cd stgraph/benchmark_tools + ruff check . cd ../../ \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index e3b7a6b..4b9eb52 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -42,6 +42,7 @@ Explore the STGraph documentation and tutorials to get started with writing and package_reference/stgraph.dataset package_reference/stgraph.compiler package_reference/stgraph.graph + package_reference/stgraph.benchmark_tools .. toctree:: :maxdepth: 1 diff --git a/docs/source/package_reference/index.rst b/docs/source/package_reference/index.rst index d4c650e..a4633d1 100644 --- a/docs/source/package_reference/index.rst +++ b/docs/source/package_reference/index.rst @@ -5,4 +5,6 @@ Package Reference :maxdepth: 2 stgraph.dataset - stgraph.compiler \ No newline at end of file + stgraph.compiler + stgraph.graph + stgraph.benchmark_tools \ No newline at end of file diff --git a/docs/source/package_reference/stgraph.benchmark_tools.rst b/docs/source/package_reference/stgraph.benchmark_tools.rst new file mode 100644 index 0000000..24af61e --- /dev/null +++ b/docs/source/package_reference/stgraph.benchmark_tools.rst @@ -0,0 +1,12 @@ +stgraph.benchmark_tools +####################### + +.. currentmodule:: stgraph.benchmark_tools +.. automodule:: stgraph.benchmark_tools + +.. autosummary:: + :toctree: ../generated/ + :nosignatures: + :template: class.rst + + BenchmarkTable \ No newline at end of file diff --git a/stgraph/benchmark_tools/__init__.py b/stgraph/benchmark_tools/__init__.py index e69de29..74de16a 100644 --- a/stgraph/benchmark_tools/__init__.py +++ b/stgraph/benchmark_tools/__init__.py @@ -0,0 +1,3 @@ +"""Benchmarking Tools provided by STGraph.""" + +from stgraph.benchmark_tools.table import BenchmarkTable diff --git a/stgraph/benchmark_tools/table.py b/stgraph/benchmark_tools/table.py index 5cc2a98..180449f 100644 --- a/stgraph/benchmark_tools/table.py +++ b/stgraph/benchmark_tools/table.py @@ -1,11 +1,54 @@ +"""Table that can display benchmarking data and other info.""" + from __future__ import annotations +from typing import IO + from rich.console import Console from rich.table import Table class BenchmarkTable: - def __init__(self, title: str, col_name_list: list[str]): + r"""Table that can display benchmarking data and other info. + + This class provides functionality to create and display tables for + benchmarking data along with other relevant information. + + Example + ------- + + .. code-block:: python + + from stgraph.benchmark_tools import BenchmarkTable + + table = BenchmarkTable( + title = "GCN Benchmark Data", + col_name_list = ["Model", "Time", "MSE"] + ) + + table.add_row("GCN", 12.56, 45.89) + table.add_row("GCN", 23.34, 44.32) + + table.display() + + Parameters + ---------- + title : str + The title of the table + col_name_list : list[str] + A list of the table column names + + Attributes + ---------- + title : str + The title of the table + col_name_list : list[str] + A list of the table column names + + """ + + def __init__(self: BenchmarkTable, title: str, col_name_list: list[str]) -> None: + r"""Table that can display benchmarking data and other info.""" self.title = "\n" + title + "\n" self.col_name_list = col_name_list self._table = Table(title=self.title, show_edge=False, style="black bold") @@ -14,17 +57,31 @@ def __init__(self, title: str, col_name_list: list[str]): self._table_add_columns() - def _table_add_columns(self): + def _table_add_columns(self: BenchmarkTable) -> None: + r"""Prepare the table by adding all the columns.""" for col_name in self.col_name_list: self._table.add_column(col_name, justify="left") - def add_row(self, values: list): + def add_row(self: BenchmarkTable, values: list) -> None: + r"""Add a row of data to the table. + + Parameters + ---------- + values : list + A list of values for each column in the row. + + """ values_str = tuple([str(val) for val in values]) self._table.add_row(*values_str) - def display(self, output_file=None): - if not output_file: - console = Console() - else: - console = Console(file=output_file) + def display(self: BenchmarkTable, output_file: IO[str] | None = None) -> None: + r"""Display entire table with data. + + Parameters + ---------- + output_file : Optional[IO[str]], optional + File object to write the table to. + + """ + console = Console() if not output_file else Console(file=output_file) console.print(self._table)