dara-components 1.21.9__py3-none-any.whl → 1.21.23__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dara/components/__init__.py +2 -1
- dara/components/common/accordion.py +11 -17
- dara/components/common/anchor.py +6 -5
- dara/components/common/base_component.py +5 -5
- dara/components/common/bullet_list.py +1 -3
- dara/components/common/button.py +11 -6
- dara/components/common/button_bar.py +6 -6
- dara/components/common/card.py +3 -5
- dara/components/common/carousel.py +5 -5
- dara/components/common/checkbox_group.py +8 -8
- dara/components/common/code.py +3 -3
- dara/components/common/component_select_list.py +6 -8
- dara/components/common/datepicker.py +6 -6
- dara/components/common/dropdown_menu.py +9 -9
- dara/components/common/dropzone.py +11 -14
- dara/components/common/form.py +3 -5
- dara/components/common/form_page.py +2 -4
- dara/components/common/grid.py +13 -13
- dara/components/common/heading.py +2 -3
- dara/components/common/icon.py +1 -3
- dara/components/common/if_cmp.py +8 -8
- dara/components/common/input.py +5 -7
- dara/components/common/label.py +3 -5
- dara/components/common/markdown.py +2 -4
- dara/components/common/overlay.py +1 -3
- dara/components/common/progress_bar.py +2 -4
- dara/components/common/radio_group.py +8 -8
- dara/components/common/select.py +10 -10
- dara/components/common/slider.py +11 -11
- dara/components/common/spacer.py +2 -4
- dara/components/common/stack.py +3 -4
- dara/components/common/switch.py +3 -5
- dara/components/common/tabbed_card.py +2 -4
- dara/components/common/table.py +38 -34
- dara/components/common/text.py +3 -5
- dara/components/common/textarea.py +5 -5
- dara/components/common/time_utils.py +1 -2
- dara/components/common/tooltip.py +3 -5
- dara/components/common/utils.py +22 -22
- dara/components/graphs/components/base_graph_component.py +19 -19
- dara/components/graphs/components/causal_graph_viewer.py +2 -4
- dara/components/graphs/components/edge_encoder.py +13 -13
- dara/components/graphs/components/node_hierarchy_builder.py +12 -12
- dara/components/graphs/definitions.py +21 -16
- dara/components/graphs/graph_layout.py +36 -37
- dara/components/plotting/bokeh/bokeh.py +5 -5
- dara/components/plotting/bokeh/utils.py +1 -3
- dara/components/plotting/plotly/plotly.py +8 -8
- dara/components/plotting/plotly/themes.py +3 -3
- dara/components/smart/chat/config.py +1 -1
- dara/components/smart/chat/types.py +3 -5
- dara/components/smart/code_editor/code_editor.py +2 -2
- dara/components/smart/code_editor/util.py +4 -4
- dara/components/smart/data_slicer/data_slicer.py +4 -6
- dara/components/smart/data_slicer/data_slicer_modal.py +1 -3
- dara/components/smart/data_slicer/extension/data_slicer_filter.py +2 -3
- dara/components/smart/data_slicer/extension/filter_status_button.py +1 -3
- dara/components/smart/data_slicer/utils/core.py +14 -14
- dara/components/smart/data_slicer/utils/data_preview.py +1 -3
- dara/components/smart/hierarchy.py +5 -5
- dara/components/umd/dara.components.umd.js +116 -38
- {dara_components-1.21.9.dist-info → dara_components-1.21.23.dist-info}/METADATA +4 -5
- dara_components-1.21.23.dist-info/RECORD +87 -0
- dara_components-1.21.9.dist-info/RECORD +0 -87
- {dara_components-1.21.9.dist-info → dara_components-1.21.23.dist-info}/LICENSE +0 -0
- {dara_components-1.21.9.dist-info → dara_components-1.21.23.dist-info}/WHEEL +0 -0
|
@@ -16,7 +16,7 @@ limitations under the License.
|
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
import ast
|
|
19
|
-
from typing import Any
|
|
19
|
+
from typing import Any
|
|
20
20
|
|
|
21
21
|
DEFAULT_WHITELIST = [
|
|
22
22
|
# Inbuilts
|
|
@@ -41,7 +41,7 @@ class ScriptVisitor(ast.NodeVisitor):
|
|
|
41
41
|
|
|
42
42
|
_function_blacklist = ['read_pickle', 'read_csv', 'read_fwf']
|
|
43
43
|
|
|
44
|
-
def __init__(self, undeclared_whitelist:
|
|
44
|
+
def __init__(self, undeclared_whitelist: list[str]):
|
|
45
45
|
self.undeclared_whitelist = undeclared_whitelist
|
|
46
46
|
self.declared_vars: list = []
|
|
47
47
|
super().__init__()
|
|
@@ -89,7 +89,7 @@ class ScriptVisitor(ast.NodeVisitor):
|
|
|
89
89
|
self.generic_visit(node)
|
|
90
90
|
|
|
91
91
|
def visit_Call(self, node):
|
|
92
|
-
func_name:
|
|
92
|
+
func_name: str | None = None
|
|
93
93
|
if isinstance(node.func, ast.Name):
|
|
94
94
|
func_name = node.func.id
|
|
95
95
|
elif isinstance(node.func, ast.Attribute):
|
|
@@ -106,7 +106,7 @@ class ScriptVisitor(ast.NodeVisitor):
|
|
|
106
106
|
raise SyntaxError(f'Imports are not allowed: {node.names}')
|
|
107
107
|
|
|
108
108
|
|
|
109
|
-
def run_script(script: str, injections:
|
|
109
|
+
def run_script(script: str, injections: dict | None = None, whitelist: list[str] = DEFAULT_WHITELIST) -> Any:
|
|
110
110
|
"""
|
|
111
111
|
Run a given script in a "sandbox".
|
|
112
112
|
Disallows imports, most globals except whitelisted ones.
|
|
@@ -15,8 +15,6 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import List, Union
|
|
19
|
-
|
|
20
18
|
from pandas import DataFrame
|
|
21
19
|
|
|
22
20
|
from dara.components import (
|
|
@@ -63,7 +61,7 @@ def increment(ctx: UpdateVariable.Ctx): # type: ignore
|
|
|
63
61
|
|
|
64
62
|
@discover
|
|
65
63
|
class DataSlicer:
|
|
66
|
-
def __init__(self, data:
|
|
64
|
+
def __init__(self, data: DataFrame | AnyVariable, rows_to_show: int = 10):
|
|
67
65
|
"""
|
|
68
66
|
DataSlicer component allows the user to select a subset of a dataset by variable ranges or individual rows.
|
|
69
67
|
Once instantiated, the `DerivedVariable` returned by `get_output()` will contain the filtered data.
|
|
@@ -110,7 +108,7 @@ class DataSlicer:
|
|
|
110
108
|
return self.final_output
|
|
111
109
|
|
|
112
110
|
@py_component
|
|
113
|
-
def describe_table(self, columns:
|
|
111
|
+
def describe_table(self, columns: list[Column]):
|
|
114
112
|
"""
|
|
115
113
|
Display data.describe() as a Table
|
|
116
114
|
"""
|
|
@@ -120,14 +118,14 @@ class DataSlicer:
|
|
|
120
118
|
return Table(data=self.describe_data, columns=cols, max_rows=TABLE_ROWS)
|
|
121
119
|
|
|
122
120
|
@py_component
|
|
123
|
-
def table_head(self, columns:
|
|
121
|
+
def table_head(self, columns: list[Column]):
|
|
124
122
|
"""
|
|
125
123
|
Display data.head() as a Table
|
|
126
124
|
"""
|
|
127
125
|
return Table(data=self.head_data, columns=columns, max_rows=TABLE_ROWS)
|
|
128
126
|
|
|
129
127
|
@py_component
|
|
130
|
-
def table_tail(self, columns:
|
|
128
|
+
def table_tail(self, columns: list[Column]):
|
|
131
129
|
"""
|
|
132
130
|
Display data.tail() as a Table
|
|
133
131
|
"""
|
|
@@ -15,8 +15,6 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import Union
|
|
19
|
-
|
|
20
18
|
from pandas import DataFrame
|
|
21
19
|
|
|
22
20
|
from dara.components.common import Button, Heading, Modal, Stack
|
|
@@ -42,7 +40,7 @@ def increment(ctx: UpdateVariable.Ctx): # type: ignore
|
|
|
42
40
|
class DataSlicerModal(DataSlicer):
|
|
43
41
|
def __init__(
|
|
44
42
|
self,
|
|
45
|
-
data:
|
|
43
|
+
data: DataFrame | AnyDataVariable,
|
|
46
44
|
rows_to_show: int = 10,
|
|
47
45
|
button_top_position: str = '5%',
|
|
48
46
|
):
|
|
@@ -16,7 +16,6 @@ limitations under the License.
|
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
from enum import Enum
|
|
19
|
-
from typing import List, Optional
|
|
20
19
|
|
|
21
20
|
from typing_extensions import TypedDict
|
|
22
21
|
|
|
@@ -61,6 +60,6 @@ class DataSlicerFilter(ComponentInstance):
|
|
|
61
60
|
|
|
62
61
|
js_module = '@darajs/components'
|
|
63
62
|
|
|
64
|
-
filters: Variable[
|
|
63
|
+
filters: Variable[list[FilterInstance]]
|
|
65
64
|
columns: AnyVariable
|
|
66
|
-
height:
|
|
65
|
+
height: str | None = None
|
|
@@ -15,8 +15,6 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import Optional
|
|
19
|
-
|
|
20
18
|
from typing_extensions import TypedDict
|
|
21
19
|
|
|
22
20
|
from dara.core.base_definitions import Action
|
|
@@ -45,4 +43,4 @@ class FilterStatusButton(ComponentInstance):
|
|
|
45
43
|
|
|
46
44
|
filter_stats: AnyVariable
|
|
47
45
|
on_click: Action
|
|
48
|
-
top_position:
|
|
46
|
+
top_position: str | None = '5%'
|
|
@@ -17,7 +17,7 @@ limitations under the License.
|
|
|
17
17
|
|
|
18
18
|
import re
|
|
19
19
|
from datetime import datetime, timezone
|
|
20
|
-
from typing import Any,
|
|
20
|
+
from typing import Any, Optional, cast
|
|
21
21
|
|
|
22
22
|
import numpy
|
|
23
23
|
from pandas import DataFrame, Series
|
|
@@ -60,17 +60,17 @@ def infer_column_type(data: DataFrame, col: str) -> ColumnType:
|
|
|
60
60
|
return ColumnType.CATEGORICAL
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
def get_column_definitions(data: DataFrame) ->
|
|
64
|
-
symbols:
|
|
63
|
+
def get_column_definitions(data: DataFrame) -> list[ColumnDefinition]:
|
|
64
|
+
symbols: list[str] = data.columns.values.tolist()
|
|
65
65
|
|
|
66
66
|
return [ColumnDefinition(name=s, type=infer_column_type(data, s)) for s in symbols if s != '__index__']
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
def get_column_items(column_defs:
|
|
69
|
+
def get_column_items(column_defs: list[ColumnDefinition]) -> list:
|
|
70
70
|
return [{'label': c['name'], 'value': c['name']} for c in column_defs]
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
def isnumber(*values:
|
|
73
|
+
def isnumber(*values: str | float):
|
|
74
74
|
"""
|
|
75
75
|
Check if all values are numeric strings (ints, floats etc)
|
|
76
76
|
"""
|
|
@@ -93,7 +93,7 @@ def apply_range_filter(range_filter: str, column: Series) -> Optional['Series']:
|
|
|
93
93
|
final_range_filter = None
|
|
94
94
|
|
|
95
95
|
# Look for groups of [<something>]
|
|
96
|
-
ranges:
|
|
96
|
+
ranges: list[str] = re.findall(r'\[[^\[\]]+\]', range_filter)
|
|
97
97
|
|
|
98
98
|
for rang in ranges:
|
|
99
99
|
if ',' not in rang:
|
|
@@ -107,8 +107,8 @@ def apply_range_filter(range_filter: str, column: Series) -> Optional['Series']:
|
|
|
107
107
|
upper_raw = upper_raw.strip()
|
|
108
108
|
|
|
109
109
|
# Replace ':' symbols with (-)infinity
|
|
110
|
-
lower:
|
|
111
|
-
upper:
|
|
110
|
+
lower: str | float = float('-inf') if lower_raw == ':' else lower_raw
|
|
111
|
+
upper: str | float = float('inf') if upper_raw == ':' else upper_raw
|
|
112
112
|
|
|
113
113
|
# Only consider the range valid if the limits are numbers and lower < upper
|
|
114
114
|
if lower != '' and upper != '' and isnumber(lower, upper):
|
|
@@ -135,7 +135,7 @@ def apply_values_filter(values_filter: str, column: Series, col_type: ColumnType
|
|
|
135
135
|
"""
|
|
136
136
|
final_values_filter = None
|
|
137
137
|
|
|
138
|
-
values:
|
|
138
|
+
values: list[Any] = (
|
|
139
139
|
[v.strip() for v in values_filter.split(',') if v != ''] if ',' in values_filter else [values_filter.strip()]
|
|
140
140
|
)
|
|
141
141
|
|
|
@@ -200,7 +200,7 @@ def apply_date_filter(from_date: str, to_date: str, column: 'Series') -> Optiona
|
|
|
200
200
|
return final_date_filter
|
|
201
201
|
|
|
202
202
|
|
|
203
|
-
def apply_filters(variable_filters:
|
|
203
|
+
def apply_filters(variable_filters: list[FilterInstance], data: DataFrame) -> DataFrame:
|
|
204
204
|
"""
|
|
205
205
|
Apply filters on data
|
|
206
206
|
|
|
@@ -212,9 +212,9 @@ def apply_filters(variable_filters: List[FilterInstance], data: DataFrame) -> Da
|
|
|
212
212
|
for fil in variable_filters:
|
|
213
213
|
var = fil['column']
|
|
214
214
|
|
|
215
|
-
values_filter:
|
|
216
|
-
range_filter:
|
|
217
|
-
date_filter:
|
|
215
|
+
values_filter: Series | None = None
|
|
216
|
+
range_filter: Series | None = None
|
|
217
|
+
date_filter: Series | None = None
|
|
218
218
|
|
|
219
219
|
if var is None or var.strip() == '':
|
|
220
220
|
continue
|
|
@@ -245,7 +245,7 @@ def apply_filters(variable_filters: List[FilterInstance], data: DataFrame) -> Da
|
|
|
245
245
|
return cast(DataFrame, output)
|
|
246
246
|
|
|
247
247
|
|
|
248
|
-
def get_filter_stats(input_data: DataFrame, output_data: DataFrame, filters:
|
|
248
|
+
def get_filter_stats(input_data: DataFrame, output_data: DataFrame, filters: list[FilterInstance]) -> FilterStats:
|
|
249
249
|
"""
|
|
250
250
|
Get filter statistics
|
|
251
251
|
|
|
@@ -15,8 +15,6 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import List
|
|
19
|
-
|
|
20
18
|
from pandas import DataFrame
|
|
21
19
|
|
|
22
20
|
from dara.components.common.table import Column, TableFormatterType
|
|
@@ -39,7 +37,7 @@ def get_tail_data(df: DataFrame, rows_to_show: int) -> DataFrame:
|
|
|
39
37
|
return df.tail(rows_to_show).fillna('NaN')
|
|
40
38
|
|
|
41
39
|
|
|
42
|
-
def get_columns(col_defs:
|
|
40
|
+
def get_columns(col_defs: list[ColumnDefinition]) -> list[Column]:
|
|
43
41
|
cols = []
|
|
44
42
|
|
|
45
43
|
for col_def in col_defs:
|
|
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import
|
|
18
|
+
from typing import Optional
|
|
19
19
|
|
|
20
20
|
from dara.core.base_definitions import Action
|
|
21
21
|
from dara.core.base_definitions import DaraBaseModel as BaseModel
|
|
@@ -29,13 +29,13 @@ class Node(BaseModel):
|
|
|
29
29
|
are represented by stacking further Node components as children of a Node.
|
|
30
30
|
"""
|
|
31
31
|
|
|
32
|
-
children:
|
|
32
|
+
children: list['Node'] | None
|
|
33
33
|
id: str
|
|
34
34
|
label: str
|
|
35
35
|
weight: float
|
|
36
36
|
|
|
37
37
|
@staticmethod
|
|
38
|
-
def from_string(name: str, weight:
|
|
38
|
+
def from_string(name: str, weight: float | None = None, children: list['Node'] | None = None):
|
|
39
39
|
return Node(id=name, label=name, children=children, weight=weight if weight is not None else 0.0)
|
|
40
40
|
|
|
41
41
|
def find_node(self, target: str) -> Optional['Node']:
|
|
@@ -86,5 +86,5 @@ class HierarchyViewer(StyledComponentInstance):
|
|
|
86
86
|
|
|
87
87
|
allow_leaf_click: bool = True
|
|
88
88
|
allow_parent_click: bool = True
|
|
89
|
-
hierarchy:
|
|
90
|
-
on_click_node:
|
|
89
|
+
hierarchy: Node | ClientVariable
|
|
90
|
+
on_click_node: Action | None = None
|