Skip to content

Commit 71a845b

Browse files
committed
Added db sub command
1 parent cfd304e commit 71a845b

21 files changed

+254
-83
lines changed

smoosense-py/smoosense/cli/__init__.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def main(ctx: click.Context, version: bool) -> None:
2727
sense # Browse current directory
2828
sense folder /path/to/folder # Browse specific folder
2929
sense table /path/to/file.csv # Open table viewer
30+
sense db /path/to/db # Open database browser
3031
sense --port 8080 # Use custom port
3132
sense --version # Show version information
3233
"""
@@ -75,4 +76,41 @@ def table(path: str, port: Optional[int], url_prefix: str) -> None:
7576
run_app(page_path=page_path, port=port, url_prefix=url_prefix)
7677

7778

79+
@main.command()
80+
@click.argument("path", type=click.Path(exists=True), default=".")
81+
@server_options
82+
def db(path: str, port: Optional[int], url_prefix: str) -> None:
83+
"""Open database browser for the specified directory.
84+
85+
Scans the directory for Lance database folders (*.lance) and opens the DB viewer.
86+
87+
\b
88+
Examples:
89+
sense db . # Browse current directory
90+
sense db /path/to/db # Browse specific database directory
91+
sense db ~/data/lance_dbs # Browse Lance databases
92+
"""
93+
# Convert to absolute path
94+
abs_path = os.path.abspath(path)
95+
96+
# Check if this directory contains any .lance folders (only 1 layer deep)
97+
db_type = "lance"
98+
try:
99+
entries = os.listdir(abs_path)
100+
has_lance = any(
101+
entry.endswith(".lance") and os.path.isdir(os.path.join(abs_path, entry))
102+
for entry in entries
103+
)
104+
105+
if has_lance:
106+
db_type = "lance"
107+
# Future: Could add detection for other DB types here
108+
except (OSError, PermissionError):
109+
# If we can't read the directory, just use default lance type
110+
pass
111+
112+
page_path = f"/DB?dbPath={abs_path}&dbType={db_type}"
113+
run_app(page_path=page_path, port=port, url_prefix=url_prefix)
114+
115+
78116
__all__ = ["main"]

smoosense-py/smoosense/statics/404.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

smoosense-py/smoosense/statics/DB.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

smoosense-py/smoosense/statics/DB.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
1:"$Sreact.fragment"
2-
2:I[33537,["265","static/chunks/6dc81886-0d3828b166e5e246.js","933","static/chunks/933-3fa934a1373c1443.js","769","static/chunks/769-38a429028a9a1959.js","496","static/chunks/496-167b672ad715b8e4.js","785","static/chunks/785-6f7a59e8bb062840.js","177","static/chunks/app/layout-d6f40cc585abf459.js"],"ThemeProvider"]
3-
3:I[68145,["265","static/chunks/6dc81886-0d3828b166e5e246.js","933","static/chunks/933-3fa934a1373c1443.js","769","static/chunks/769-38a429028a9a1959.js","496","static/chunks/496-167b672ad715b8e4.js","785","static/chunks/785-6f7a59e8bb062840.js","177","static/chunks/app/layout-d6f40cc585abf459.js"],"default"]
2+
2:I[33537,["265","static/chunks/6dc81886-0d3828b166e5e246.js","933","static/chunks/933-3fa934a1373c1443.js","769","static/chunks/769-38a429028a9a1959.js","496","static/chunks/496-167b672ad715b8e4.js","785","static/chunks/785-6f7a59e8bb062840.js","177","static/chunks/app/layout-e6ee0efb85fa7de1.js"],"ThemeProvider"]
3+
3:I[68145,["265","static/chunks/6dc81886-0d3828b166e5e246.js","933","static/chunks/933-3fa934a1373c1443.js","769","static/chunks/769-38a429028a9a1959.js","496","static/chunks/496-167b672ad715b8e4.js","785","static/chunks/785-6f7a59e8bb062840.js","177","static/chunks/app/layout-e6ee0efb85fa7de1.js"],"default"]
44
4:I[84468,[],""]
55
5:I[29906,[],""]
6-
6:I[84526,["265","static/chunks/6dc81886-0d3828b166e5e246.js","933","static/chunks/933-3fa934a1373c1443.js","769","static/chunks/769-38a429028a9a1959.js","496","static/chunks/496-167b672ad715b8e4.js","785","static/chunks/785-6f7a59e8bb062840.js","177","static/chunks/app/layout-d6f40cc585abf459.js"],"ToasterProvider"]
6+
6:I[84526,["265","static/chunks/6dc81886-0d3828b166e5e246.js","933","static/chunks/933-3fa934a1373c1443.js","769","static/chunks/769-38a429028a9a1959.js","496","static/chunks/496-167b672ad715b8e4.js","785","static/chunks/785-6f7a59e8bb062840.js","177","static/chunks/app/layout-e6ee0efb85fa7de1.js"],"ToasterProvider"]
77
7:I[1377,[],"ClientPageRoot"]
8-
8:I[4751,["265","static/chunks/6dc81886-0d3828b166e5e246.js","652","static/chunks/4ec49466-f80a37a142905954.js","346","static/chunks/191d07e0-76e9a3be7a7ac399.js","933","static/chunks/933-3fa934a1373c1443.js","916","static/chunks/916-01ab46af81553d20.js","53","static/chunks/53-c1ea9e1118520cc0.js","990","static/chunks/990-4de2b100275dbb74.js","496","static/chunks/496-167b672ad715b8e4.js","213","static/chunks/213-929cdf2f2ab1ba92.js","73","static/chunks/app/DB/page-aa7000bdd78d40f7.js"],"default"]
8+
8:I[30185,["265","static/chunks/6dc81886-0d3828b166e5e246.js","652","static/chunks/4ec49466-f80a37a142905954.js","346","static/chunks/191d07e0-76e9a3be7a7ac399.js","933","static/chunks/933-3fa934a1373c1443.js","916","static/chunks/916-01ab46af81553d20.js","53","static/chunks/53-c1ea9e1118520cc0.js","990","static/chunks/990-4de2b100275dbb74.js","496","static/chunks/496-167b672ad715b8e4.js","213","static/chunks/213-929cdf2f2ab1ba92.js","73","static/chunks/app/DB/page-7beaf102c4ad1850.js"],"default"]
99
b:I[94484,[],"OutletBoundary"]
1010
d:I[78892,[],"AsyncMetadataOutlet"]
1111
f:I[94484,[],"ViewportBoundary"]
1212
11:I[94484,[],"MetadataBoundary"]
1313
12:"$Sreact.suspense"
1414
14:I[29872,[],""]
15-
:HL["https://cdn.smoosense.ai/_next/static/media/4cf2300e9c8272f7-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
16-
:HL["https://cdn.smoosense.ai/_next/static/media/93f479601ee12b01-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
17-
:HL["https://cdn.smoosense.ai/_next/static/css/4c99ec665fc98ab2.css","style"]
18-
0:{"P":null,"b":"Nw8PPXXNrI8fWtDB0HVFP","p":"https://cdn.smoosense.ai","c":["","DB"],"i":false,"f":[[["",{"children":["DB",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"https://cdn.smoosense.ai/_next/static/css/4c99ec665fc98ab2.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]],["$","html",null,{"lang":"en","suppressHydrationWarning":true,"children":[["$","head",null,{}],["$","body",null,{"className":"__variable_0d22f4 __variable_a7838a antialiased","children":["$","$L2",null,{"attribute":"class","defaultTheme":"dark","enableSystem":true,"disableTransitionOnChange":true,"children":[["$","$L3",null,{"children":["$","$L4",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}],["$","$L6",null,{}]]}]}]]}]]}],{"children":["DB",["$","$1","c",{"children":[null,["$","$L4",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}],{"children":["__PAGE__",["$","$1","c",{"children":[["$","$L7",null,{"Component":"$8","searchParams":{},"params":{},"promises":["$@9","$@a"]}],null,["$","$Lb",null,{"children":["$Lc",["$","$Ld",null,{"promise":"$@e"}]]}]]}],{},null,false]},null,false]},null,false],["$","$1","h",{"children":[null,[["$","$Lf",null,{"children":"$L10"}],["$","meta",null,{"name":"next-size-adjust","content":""}]],["$","$L11",null,{"children":["$","div",null,{"hidden":true,"children":["$","$12",null,{"fallback":null,"children":"$L13"}]}]}]]}],false]],"m":"$undefined","G":["$14",[]],"s":false,"S":true}
15+
:HL["/_next/static/media/4cf2300e9c8272f7-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
16+
:HL["/_next/static/media/93f479601ee12b01-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
17+
:HL["/_next/static/css/9e919189cc5795ba.css","style"]
18+
0:{"P":null,"b":"tNnp1sR4GeqFzz7nvbr-o","p":"","c":["","DB"],"i":false,"f":[[["",{"children":["DB",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/9e919189cc5795ba.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]],["$","html",null,{"lang":"en","suppressHydrationWarning":true,"children":[["$","head",null,{}],["$","body",null,{"className":"__variable_188709 __variable_9a8899 antialiased","children":["$","$L2",null,{"attribute":"class","defaultTheme":"dark","enableSystem":true,"disableTransitionOnChange":true,"children":[["$","$L3",null,{"children":["$","$L4",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}],["$","$L6",null,{}]]}]}]]}]]}],{"children":["DB",["$","$1","c",{"children":[null,["$","$L4",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}],{"children":["__PAGE__",["$","$1","c",{"children":[["$","$L7",null,{"Component":"$8","searchParams":{},"params":{},"promises":["$@9","$@a"]}],null,["$","$Lb",null,{"children":["$Lc",["$","$Ld",null,{"promise":"$@e"}]]}]]}],{},null,false]},null,false]},null,false],["$","$1","h",{"children":[null,[["$","$Lf",null,{"children":"$L10"}],["$","meta",null,{"name":"next-size-adjust","content":""}]],["$","$L11",null,{"children":["$","div",null,{"hidden":true,"children":["$","$12",null,{"fallback":null,"children":"$L13"}]}]}]]}],false]],"m":"$undefined","G":["$14",[]],"s":false,"S":true}
1919
9:{}
2020
a:"$0:f:0:1:2:children:2:children:1:props:children:0:props:params"
2121
10:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]]

0 commit comments

Comments
 (0)