Skip to content

Commit 1012c3e

Browse files
authored
add dashboard command for debugging ragulate (#587)
1 parent 592ecb5 commit 1012c3e

File tree

6 files changed

+55
-7
lines changed

6 files changed

+55
-7
lines changed

libs/ragulate/ragstack_ragulate/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def main() -> None:
2525
cli_commands.setup_query(subparsers=subparsers)
2626
cli_commands.setup_compare(subparsers=subparsers)
2727
cli_commands.setup_run(subparsers=subparsers)
28+
cli_commands.setup_dashboard(subparsers=subparsers)
2829

2930
# Parse the command-line arguments
3031
args = parser.parse_args()

libs/ragulate/ragstack_ragulate/cli_commands/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from .compare import setup_compare
2+
from .dashboard import setup_dashboard
23
from .download import setup_download
34
from .ingest import setup_ingest
45
from .query import setup_query
56
from .run import setup_run
67

78
__all__ = [
89
"setup_compare",
10+
"setup_dashboard",
911
"setup_download",
1012
"setup_ingest",
1113
"setup_query",

libs/ragulate/ragstack_ragulate/cli_commands/compare.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from ragstack_ragulate.analysis import Analysis
44

5+
from .utils import remove_sqlite_extension
6+
57

68
def setup_compare(subparsers):
79
"""Setup the compare command."""
@@ -26,13 +28,6 @@ def setup_compare(subparsers):
2628
compare_parser.set_defaults(func=lambda args: call_compare(**vars(args)))
2729

2830

29-
def remove_sqlite_extension(s):
30-
"""Remove the .sqlite extension from a string."""
31-
if s.endswith(".sqlite"):
32-
return s[:-7]
33-
return s
34-
35-
3631
def call_compare(
3732
recipe: List[str],
3833
output: Optional[str] = "box-plots",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from ragstack_ragulate.dashboard import run_dashboard
2+
3+
from .utils import remove_sqlite_extension
4+
5+
6+
def setup_dashboard(subparsers):
7+
"""Setup the dashboard command."""
8+
dashboard_parser = subparsers.add_parser(
9+
"dashboard",
10+
help="Show the tru-lens dashboard for a recipe. Can be helpful for debugging.",
11+
)
12+
dashboard_parser.add_argument(
13+
"-r",
14+
"--recipe",
15+
type=str,
16+
help="A recipe to see the dashboard for.",
17+
required=True,
18+
)
19+
dashboard_parser.add_argument(
20+
"-p",
21+
"--port",
22+
type=int,
23+
help="Port to show the dashboard on, default 8501",
24+
default=8501,
25+
)
26+
dashboard_parser.set_defaults(func=lambda args: call_dashboard(**vars(args)))
27+
28+
29+
def call_dashboard(
30+
recipe: str,
31+
port: int,
32+
**_,
33+
):
34+
"""Runs the TruLens dashboard."""
35+
recipe_name = remove_sqlite_extension(recipe)
36+
run_dashboard(recipe_name=recipe_name, port=port)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def remove_sqlite_extension(s):
2+
"""Remove the .sqlite extension from a string."""
3+
if s.endswith(".sqlite"):
4+
return s[:-7]
5+
return s
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from typing import Optional
2+
3+
from .utils import get_tru
4+
5+
6+
def run_dashboard(recipe_name: str, port: Optional[int] = 8501):
7+
"""Runs the TruLens dashboard."""
8+
tru = get_tru(recipe_name=recipe_name)
9+
tru.run_dashboard(port=port)

0 commit comments

Comments
 (0)