-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
94 lines (71 loc) · 1.86 KB
/
demo.py
File metadata and controls
94 lines (71 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import marimo
__generated_with = "0.23.5"
app = marimo.App()
@app.cell
def _():
import os
import marimo as mo
import hotdata_marimo as hm
hm.register_hotdata_sql_engine()
return hm, mo, os
@app.cell
def _(hm, mo, os):
mo.stop(
not os.environ.get("HOTDATA_API_KEY"),
mo.callout(
mo.md(
"Add **HOTDATA_API_KEY** to your environment "
"to run this example."
),
kind="warn",
),
)
workspace = hm.workspace_selector_from_env()
return (workspace,)
@app.cell
def _(hm, workspace):
client = workspace.client
status = hm.connections_panel(client)
db_writer = hm.managed_database_writer(client)
recent = hm.recent_results(client, limit=20)
history = hm.run_history(client, limit=10)
return client, db_writer, history, recent, status
@app.cell
def _(mo):
mo.md(r"""
## HotData explorer
Use the tabs below to switch between workspaces, connections, managed databases,
recent results, and run history.
On a shared or networked host, run Marimo **without** `--no-token` and open the printed URL
with its access token so only you can use this notebook.
""")
return
@app.cell
def _(db_writer):
databases_tab = db_writer.tab_ui
return (databases_tab,)
@app.cell
def _(recent):
recent_tab = recent.tab_ui
return (recent_tab,)
@app.cell
def _(databases_tab, history, mo, recent_tab, status, workspace):
mo.ui.tabs({
"Workspaces": workspace.ui,
"Connections": status,
"Databases": databases_tab,
"Recent results": recent_tab,
"Run history": history,
})
return
@app.cell
def _(client, mo):
_df = mo.sql(
"""
SELECT 1 AS example_value
""",
engine=client
)
return
if __name__ == "__main__":
app.run()