Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs update code sql_code #895

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 23 additions & 25 deletions solara/website/pages/documentation/components/output/sql_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
vaex = None

import solara
from solara.alias import rv
from solara.website.utils import apidoc

if vaex is not None:
Expand Down Expand Up @@ -56,30 +55,29 @@ def run_query(cancel: threading.Event) -> pd.DataFrame:
return df

result: solara.Result[pd.DataFrame] = solara.use_thread(run_query, dependencies=[query_executed]) # noqa: SH101
with solara.VBox() as main:
solara.SqlCode(query=query, tables=table_hints, on_query=set_query)
enable_execute = (query != query_executed) or result.error is not None

def execute():
set_query_executed(query)
if query == query_executed and result.error:
result.retry() # type: ignore

solara.Button("Execute", on_click=execute, disabled=not enable_execute)
if result.error:
solara.Error(f"Ooops {result.error}")
elif not query:
solara.Info("No query")

elif result.value is not None:
solara.Markdown(f"Result for query: `{query_executed}`")
df = result.value
solara.DataFrame(df)
elif query_executed is not None:
with solara.Div():
solara.Text("Loading data...")
rv.ProgressCircular(indeterminate=True, class_="solara-progress")
return main

solara.SqlCode(query=query, tables=table_hints, on_query=set_query)
enable_execute = (query != query_executed) or result.error is not None

def execute():
set_query_executed(query)
if query == query_executed and result.error:
result.retry() # type: ignore

solara.Button("Execute", on_click=execute, disabled=not enable_execute)
if result.error:
solara.Error(f"Ooops {result.error}")
elif not query:
solara.Info("No query")

elif result.value is not None:
solara.Markdown(f"Result for query: `{query_executed}`")
df = result.value
solara.DataFrame(df)
elif query_executed is not None:
with solara.Div():
solara.Text("Loading data...")
solara.v.ProgressCircular(indeterminate=True, class_="solara-progress")


__doc__ += apidoc(solara.SqlCode.f) # type: ignore
Loading