From ec680c3aed2b305425adb6644f4c15f330128baa Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Sun, 7 Jul 2024 23:21:09 +0200 Subject: [PATCH] clean up a bit on the layout --- pyproject.toml | 1 - src/aiidalab_sssp/data.py | 34 +------- src/aiidalab_sssp/pages/__init__.py | 11 +-- src/aiidalab_sssp/pages/explore/__init__.py | 88 ++++++++++----------- 4 files changed, 48 insertions(+), 86 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a627a2f..a19194e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,6 @@ classifiers = [ dependencies = [ "aiida-sssp-workflow", "solara", - "vaex", "anywidget>=0.9.0", "humanfriendly", ] diff --git a/src/aiidalab_sssp/data.py b/src/aiidalab_sssp/data.py index 174f0f3..2620f26 100644 --- a/src/aiidalab_sssp/data.py +++ b/src/aiidalab_sssp/data.py @@ -1,41 +1,9 @@ import dataclasses from pathlib import Path -from typing import Any, Dict +from typing import Dict -import vaex.datasets import yaml - -@dataclasses.dataclass -class DataFrame: - title: str - df: Any - image_url: str - - -dfs = { - "titanic": DataFrame( - df=vaex.datasets.titanic(), - title="Titanic", - image_url="https://images.unsplash.com/photo-1561625116-df74735458a5?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=3574&q=80", # noqa - ), - "iris": DataFrame( - df=vaex.datasets.iris(), - title="Iris", - image_url="https://images.unsplash.com/photo-1540163502599-a3284e17072d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=3870&q=80", # noqa - ), - # uncomment for a larger dataset to be included - # "taxi": DataFrame( - # df=vaex.datasets.taxi(), - # title="New York Taxi", - # image_url="https://images.unsplash.com/photo-1514749204155-24e484635226?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1587&q=80", # noqa - # ), -} - -names = list(dfs) -# def load(name): -# if name == "titanic" - HERE = Path(__file__) diff --git a/src/aiidalab_sssp/pages/__init__.py b/src/aiidalab_sssp/pages/__init__.py index 7aef79e..013d226 100644 --- a/src/aiidalab_sssp/pages/__init__.py +++ b/src/aiidalab_sssp/pages/__init__.py @@ -1,8 +1,8 @@ import solara from solara.alias import rv -from aiidalab_sssp.pages import explore -from aiidalab_sssp.data import articles, names +from aiidalab_sssp.pages import explore, verify +from aiidalab_sssp.data import articles from aiidalab_sssp.components import banner @@ -30,11 +30,6 @@ def Layout(children=[]): with solara.Link(solara.resolve_path("/")): with solara.ListItem("Home", icon_name="mdi-home", value="/"): pass - with solara.ListItem("tabular data", icon_name="mdi-database"): - for name in names: - pathname = f"/tabular/{name}" - with solara.Link(solara.resolve_path(pathname)): - solara.ListItem(name, value=pathname) with solara.ListItem("Articles", icon_name="mdi-book-open"): for name, article_ in articles.items(): pathname = f"/article/{name}" @@ -52,7 +47,7 @@ def Page(): solara.Title("Standard Solid-State Pseudopotential (SSSP) » Home") with solara.ColumnsResponsive(12): banner.Overview() - with solara.ColumnsResponsive([6, 6]): + with solara.ColumnsResponsive([6, 6], small=[12]): explore.Overview() verify.Overview() diff --git a/src/aiidalab_sssp/pages/explore/__init__.py b/src/aiidalab_sssp/pages/explore/__init__.py index 34a9601..afc8457 100644 --- a/src/aiidalab_sssp/pages/explore/__init__.py +++ b/src/aiidalab_sssp/pages/explore/__init__.py @@ -30,50 +30,50 @@ def Page(type: Optional[str] = None, name: Optional[str] = None, x: Optional[str with solara.ColumnsResponsive(12): viz.PerioicTable() - if type is None: - type = "scatter" - set_type("scatter") - with solara.Sidebar(): - with solara.Card("Viz configuration"): - solara.Select(label="dataset", value=name, values=list(data.dfs), on_value=set_name) - solara.ToggleButtonsSingle(value=type, values=["scatter", "histogram"], on_value=set_type) - if name not in data.dfs: - set_name(list(data.dfs)[0]) - if name in data.dfs: - df = data.dfs[name].df - column_names = df.get_column_names() - df = df.to_pandas_df() - if x not in column_names: - set_x(column_names[0]) - if y not in column_names: - set_y(column_names[1]) - if x not in column_names: - set_x(column_names[0]) - if y not in column_names: - set_y(column_names[1]) - solara.Title(f"Solara demo » viz » {type} » {name}") - fig = None - if type == "scatter": - with solara.Sidebar(): - with solara.Card("Columns"): - solara.Select(label="x", value=x, values=column_names, on_value=set_x) - solara.Select(label="y", value=y, values=column_names, on_value=set_y) - if x and y and x in column_names and y in column_names: - fig = px.scatter(df, x=x, y=y) - else: - solara.Warning("Please provide x and y") - elif type == "histogram": - with solara.Sidebar(): - with solara.Card("Columns"): - solara.Select(label="x", value=x, values=column_names, on_value=set_x) - if x and x in column_names: - fig = px.histogram(df, x=x) - else: - solara.Warning("Please provide x") - else: - solara.Error("Uknonwn ") - if fig: - solara.FigurePlotly(fig, dependencies=[name, type, x, y]) + # if type is None: + # type = "scatter" + # set_type("scatter") + # with solara.Sidebar(): + # with solara.Card("Viz configuration"): + # solara.Select(label="dataset", value=name, values=list(data.dfs), on_value=set_name) + # solara.ToggleButtonsSingle(value=type, values=["scatter", "histogram"], on_value=set_type) + # if name not in data.dfs: + # set_name(list(data.dfs)[0]) + # if name in data.dfs: + # df = data.dfs[name].df + # column_names = df.get_column_names() + # df = df.to_pandas_df() + # if x not in column_names: + # set_x(column_names[0]) + # if y not in column_names: + # set_y(column_names[1]) + # if x not in column_names: + # set_x(column_names[0]) + # if y not in column_names: + # set_y(column_names[1]) + # solara.Title(f"Solara demo » viz » {type} » {name}") + # fig = None + # if type == "scatter": + # with solara.Sidebar(): + # with solara.Card("Columns"): + # solara.Select(label="x", value=x, values=column_names, on_value=set_x) + # solara.Select(label="y", value=y, values=column_names, on_value=set_y) + # if x and y and x in column_names and y in column_names: + # fig = px.scatter(df, x=x, y=y) + # else: + # solara.Warning("Please provide x and y") + # elif type == "histogram": + # with solara.Sidebar(): + # with solara.Card("Columns"): + # solara.Select(label="x", value=x, values=column_names, on_value=set_x) + # if x and x in column_names: + # fig = px.histogram(df, x=x) + # else: + # solara.Warning("Please provide x") + # else: + # solara.Error("Uknonwn ") + # if fig: + # solara.FigurePlotly(fig, dependencies=[name, type, x, y]) return main @solara.component