Skip to content

glossary

Components to assist with user information, including about the app,

lookup = dict() module-attribute #

Lookup of help text.

Help #

Help message settings

Attributes:

Name Type Description
open Reactive[bool]

whether menu is open or not

tab Reactive[int]

which tab is open

lookup dict[int, str]

the lookup instance

Source code in src/sdss_explorer/dashboard/components/sidebar/glossary.py
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class Help:
    """
    Help message settings

    Attributes:
        open (solara.Reactive[bool]): whether menu is open or not
        tab (solara.Reactive[int]): which tab is open
        lookup (dict[int,str]): the lookup instance
    """

    open = sl.reactive(False)
    tab = sl.reactive("")
    lookup = lookup

    @staticmethod
    def update(tab):
        Help.tab.set(Help.lookup[tab])
        Help.open.set(True)

    @staticmethod
    def close():
        Help.tab.set(1)
        Help.open.set(False)

ColumnGlossary() #

Complete list of all columns and what they do

Source code in src/sdss_explorer/dashboard/components/sidebar/glossary.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
@sl.component()
def ColumnGlossary():
    """Complete list of all columns and what they do"""
    # TODO: fetch via valis instead of via precompiled json
    # TODO: make datamodel/airflow render for data file
    dm = State.datamodel.value
    query, set_query = sl.use_state("")
    filter, set_filter = sl.use_state(None)
    dmf = dm
    if filter is not None:
        dmf = dm[filter]

    def update_columns():
        # always need to cut
        if query:
            # union of regex across name and desc
            alpha = filter_regex(dm, query=query, col="name")
            beta = filter_regex(dm, query=query, col="description")
            set_filter(np.logical_or(alpha, beta))

        elif query == "":
            set_filter(None)

    result = sl.lab.use_task(update_columns, dependencies=[query])

    with rv.ExpansionPanel() as main:
        rv.ExpansionPanelHeader(children=["Column Glossary"])
        with rv.ExpansionPanelContent():
            with sl.Div():
                if dm is None:
                    sl.Error("Error in datamodel load.")
                else:
                    InputTextExposed(
                        label="Filter columns by name",
                        value=query,
                        on_value=set_query,
                        continuous_update=True,
                    )
                    with sl.GridFixed(columns=1,
                                      align_items="end",
                                      justify_items="stretch"):
                        if result.finished:
                            if len(dmf) == 0:
                                sl.Warning(
                                    "No columns found, try a different filter")
                            else:
                                # summary text logic
                                if len(dmf) > 20:
                                    summary = (
                                        f"{len(dmf):,}/{len(dm):,} columns (showing 20)"
                                    )
                                elif len(dmf) == len(dm):
                                    summary = f"{len(dm):,} total columns (showing 20)"
                                else:
                                    summary = f"{len(dmf):,}/{len(dm):,} columns"

                                sl.Info(summary)
                                # TODO: change from showing just first 20 to more via lazy-loading
                                for n, d in enumerate(dmf.iloc):
                                    if n > 19:
                                        break
                                    with sl.Columns([1, 1]):
                                        sl.Text(d["name"])
                                        sl.Text(d["description"])

                        else:
                            with sl.Div():
                                sl.Text("Loading...")
                                rv.ProgressCircular(indeterminate=True,
                                                    class_="solara-progress")
    return main

HelpBlurb() #

Dialog popup to provide short help blurbs for the application. Expected to read markdown files.

Source code in src/sdss_explorer/dashboard/components/sidebar/glossary.py
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
@sl.component()
def HelpBlurb():
    """Dialog popup to provide short help blurbs for the application. Expected to read markdown files."""
    with rv.AppBarNavIcon() as main:
        with sl.Tooltip("About the app + Help"):
            sl.Button(
                icon_name="mdi-information-outline",
                icon=True,
                text=True,
                on_click=lambda: Help.update("about"),
            )
        with Dialog(
                Help.open.value,
                ok=None,
                title="About",
                cancel="close",
                max_width="960",  # 1920/2
                on_cancel=lambda: Help.close(),
        ):
            with rv.Card(flat=True, style_="width: 100%; height: 100%"):
                with Tabs(value=Help.tab.value, on_value=Help.tab.set):
                    for label, (icon, text) in sorted(help_text.items()):
                        with Tab(label=label, icon_name=icon):
                            sl.Markdown(text)

    return main