From 4fda4c410f0e991969ba81fd2a1d4f6959260562 Mon Sep 17 00:00:00 2001 From: nithinmanoj10 Date: Sun, 12 May 2024 22:36:01 +0530 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A7=B9=20Lint=20Checked=20stgraph.ben?= =?UTF-8?q?chmark=5Ftools=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stgraph/benchmark_tools/__init__.py | 3 ++ stgraph/benchmark_tools/table.py | 72 +++++++++++++++++++++++++---- 2 files changed, 67 insertions(+), 8 deletions(-) diff --git a/stgraph/benchmark_tools/__init__.py b/stgraph/benchmark_tools/__init__.py index e69de29b..74de16aa 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 5cc2a98a..96329ac4 100644 --- a/stgraph/benchmark_tools/table.py +++ b/stgraph/benchmark_tools/table.py @@ -1,11 +1,53 @@ +"""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 +56,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) From a40125fe869f37ba1d80a5f110667857488fbc13 Mon Sep 17 00:00:00 2001 From: nithinmanoj10 Date: Tue, 14 May 2024 22:42:24 +0530 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9D=20Added=20benchmark=5Ftools=20?= =?UTF-8?q?to=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ruff.yaml | 3 +++ docs/source/index.rst | 1 + docs/source/package_reference/index.rst | 4 +++- .../package_reference/stgraph.benchmark_tools.rst | 12 ++++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 docs/source/package_reference/stgraph.benchmark_tools.rst diff --git a/.github/workflows/ruff.yaml b/.github/workflows/ruff.yaml index 23e3c7eb..d12b4f50 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 e3b7a6bf..4b9eb52a 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 d4c650e6..a4633d11 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 00000000..24af61e7 --- /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 From b57729e9eb88a5c1ff4a4934b464afb6f7c5079a Mon Sep 17 00:00:00 2001 From: nithinmanoj10 Date: Wed, 15 May 2024 22:05:23 +0530 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=9D=20Fixed=20BenchmarkTable=20Par?= =?UTF-8?q?ameter=20Docstring=20Issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stgraph/benchmark_tools/table.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stgraph/benchmark_tools/table.py b/stgraph/benchmark_tools/table.py index 96329ac4..180449f2 100644 --- a/stgraph/benchmark_tools/table.py +++ b/stgraph/benchmark_tools/table.py @@ -14,8 +14,9 @@ class BenchmarkTable: This class provides functionality to create and display tables for benchmarking data along with other relevant information. - Example: - -------- + Example + ------- + .. code-block:: python from stgraph.benchmark_tools import BenchmarkTable