squirrels 0.4.1__py3-none-any.whl → 0.5.0rc0__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.
Potentially problematic release.
This version of squirrels might be problematic. Click here for more details.
- squirrels/__init__.py +10 -6
- squirrels/_api_response_models.py +93 -44
- squirrels/_api_server.py +571 -219
- squirrels/_auth.py +451 -0
- squirrels/_command_line.py +61 -20
- squirrels/_connection_set.py +38 -25
- squirrels/_constants.py +44 -34
- squirrels/_dashboards_io.py +34 -16
- squirrels/_exceptions.py +57 -0
- squirrels/_initializer.py +117 -44
- squirrels/_manifest.py +124 -62
- squirrels/_model_builder.py +111 -0
- squirrels/_model_configs.py +74 -0
- squirrels/_model_queries.py +52 -0
- squirrels/_models.py +860 -354
- squirrels/_package_loader.py +8 -4
- squirrels/_parameter_configs.py +45 -65
- squirrels/_parameter_sets.py +15 -13
- squirrels/_project.py +561 -0
- squirrels/_py_module.py +4 -3
- squirrels/_seeds.py +35 -16
- squirrels/_sources.py +106 -0
- squirrels/_utils.py +166 -63
- squirrels/_version.py +1 -1
- squirrels/arguments/init_time_args.py +78 -15
- squirrels/arguments/run_time_args.py +62 -101
- squirrels/dashboards.py +4 -4
- squirrels/data_sources.py +94 -162
- squirrels/dataset_result.py +86 -0
- squirrels/dateutils.py +4 -4
- squirrels/package_data/base_project/.env +30 -0
- squirrels/package_data/base_project/.env.example +30 -0
- squirrels/package_data/base_project/.gitignore +3 -2
- squirrels/package_data/base_project/assets/expenses.db +0 -0
- squirrels/package_data/base_project/connections.yml +11 -3
- squirrels/package_data/base_project/dashboards/dashboard_example.py +15 -13
- squirrels/package_data/base_project/dashboards/dashboard_example.yml +22 -0
- squirrels/package_data/base_project/docker/.dockerignore +5 -2
- squirrels/package_data/base_project/docker/Dockerfile +3 -3
- squirrels/package_data/base_project/docker/compose.yml +1 -1
- squirrels/package_data/base_project/duckdb_init.sql +9 -0
- squirrels/package_data/base_project/macros/macros_example.sql +15 -0
- squirrels/package_data/base_project/models/builds/build_example.py +26 -0
- squirrels/package_data/base_project/models/builds/build_example.sql +16 -0
- squirrels/package_data/base_project/models/builds/build_example.yml +55 -0
- squirrels/package_data/base_project/models/dbviews/dbview_example.sql +12 -22
- squirrels/package_data/base_project/models/dbviews/dbview_example.yml +26 -0
- squirrels/package_data/base_project/models/federates/federate_example.py +38 -15
- squirrels/package_data/base_project/models/federates/federate_example.sql +16 -2
- squirrels/package_data/base_project/models/federates/federate_example.yml +65 -0
- squirrels/package_data/base_project/models/sources.yml +39 -0
- squirrels/package_data/base_project/parameters.yml +36 -21
- squirrels/package_data/base_project/pyconfigs/connections.py +6 -11
- squirrels/package_data/base_project/pyconfigs/context.py +20 -33
- squirrels/package_data/base_project/pyconfigs/parameters.py +19 -21
- squirrels/package_data/base_project/pyconfigs/user.py +23 -0
- squirrels/package_data/base_project/seeds/seed_categories.yml +15 -0
- squirrels/package_data/base_project/seeds/seed_subcategories.csv +15 -15
- squirrels/package_data/base_project/seeds/seed_subcategories.yml +21 -0
- squirrels/package_data/base_project/squirrels.yml.j2 +17 -40
- squirrels/parameters.py +20 -20
- {squirrels-0.4.1.dist-info → squirrels-0.5.0rc0.dist-info}/METADATA +31 -32
- squirrels-0.5.0rc0.dist-info/RECORD +70 -0
- {squirrels-0.4.1.dist-info → squirrels-0.5.0rc0.dist-info}/WHEEL +1 -1
- squirrels-0.5.0rc0.dist-info/entry_points.txt +3 -0
- {squirrels-0.4.1.dist-info → squirrels-0.5.0rc0.dist-info/licenses}/LICENSE +1 -1
- squirrels/_authenticator.py +0 -85
- squirrels/_environcfg.py +0 -84
- squirrels/package_data/assets/favicon.ico +0 -0
- squirrels/package_data/assets/index.css +0 -1
- squirrels/package_data/assets/index.js +0 -58
- squirrels/package_data/base_project/dashboards.yml +0 -10
- squirrels/package_data/base_project/env.yml +0 -29
- squirrels/package_data/base_project/models/dbviews/dbview_example.py +0 -47
- squirrels/package_data/base_project/pyconfigs/auth.py +0 -45
- squirrels/package_data/templates/index.html +0 -18
- squirrels/project.py +0 -378
- squirrels/user_base.py +0 -55
- squirrels-0.4.1.dist-info/RECORD +0 -60
- squirrels-0.4.1.dist-info/entry_points.txt +0 -4
|
@@ -4,36 +4,47 @@ parameters:
|
|
|
4
4
|
arguments: ## arguments to specify depend on values for 'type' and 'factory'
|
|
5
5
|
name: group_by
|
|
6
6
|
label: Group By
|
|
7
|
-
description: Dimension to aggregate by
|
|
7
|
+
description: Dimension(s) to aggregate by ## optional, default is empty string
|
|
8
|
+
user_attribute: role ## optional, default is null
|
|
8
9
|
all_options:
|
|
9
10
|
- id: g0
|
|
10
11
|
label: Transaction
|
|
11
|
-
columns: ["
|
|
12
|
-
aliases: ["id", "date", "description"] ## custom field
|
|
12
|
+
columns: ["date", "category", "subcategory", "description"] ## custom field
|
|
13
13
|
is_default: false ## optional, default, exists for SingleSelect or MultiSelect options only
|
|
14
|
-
user_groups: []
|
|
14
|
+
user_groups: ["manager"] ## optional, default is empty list
|
|
15
15
|
parent_option_ids: [] ## optional, default, exists for all parameter options
|
|
16
16
|
- id: g1
|
|
17
|
-
label:
|
|
17
|
+
label: Day
|
|
18
18
|
columns: [date]
|
|
19
|
+
aliases: [day] ## custom field
|
|
20
|
+
user_groups: ["manager", "employee"]
|
|
21
|
+
- id: g4
|
|
22
|
+
label: Month
|
|
23
|
+
columns: [month]
|
|
24
|
+
user_groups: ["manager", "employee"]
|
|
19
25
|
- id: g2
|
|
20
26
|
label: Category
|
|
21
27
|
columns: [category]
|
|
28
|
+
user_groups: ["manager", "employee"]
|
|
22
29
|
- id: g3
|
|
23
30
|
label: Subcategory
|
|
24
31
|
columns: [category, subcategory]
|
|
25
|
-
|
|
32
|
+
user_groups: ["manager", "employee"]
|
|
26
33
|
parent_name: null ## optional, default, exists for all parameter types
|
|
27
34
|
|
|
28
|
-
- type:
|
|
35
|
+
- type: NumberParameter
|
|
29
36
|
factory: CreateWithOptions
|
|
30
37
|
arguments:
|
|
31
|
-
name:
|
|
32
|
-
label:
|
|
33
|
-
description:
|
|
38
|
+
name: limit
|
|
39
|
+
label: Max Number of Rows
|
|
40
|
+
description: Maximum number of rows to return
|
|
34
41
|
parent_name: group_by
|
|
35
42
|
all_options:
|
|
36
|
-
-
|
|
43
|
+
- min_value: 0
|
|
44
|
+
max_value: 1000
|
|
45
|
+
increment: 10
|
|
46
|
+
default_value: 1000
|
|
47
|
+
parent_option_ids: g0
|
|
37
48
|
|
|
38
49
|
- type: DateParameter
|
|
39
50
|
factory: CreateFromSource
|
|
@@ -42,7 +53,7 @@ parameters:
|
|
|
42
53
|
label: Start Date
|
|
43
54
|
description: Start date to filter transactions by
|
|
44
55
|
data_source:
|
|
45
|
-
table_or_query: SELECT min(date) AS min_date, max(date) AS max_date FROM
|
|
56
|
+
table_or_query: SELECT min(date) AS min_date, max(date) AS max_date FROM expenses
|
|
46
57
|
default_date_col: min_date
|
|
47
58
|
min_date_col: min_date
|
|
48
59
|
max_date_col: max_date
|
|
@@ -54,7 +65,9 @@ parameters:
|
|
|
54
65
|
label: End Date
|
|
55
66
|
description: End date to filter transactions by
|
|
56
67
|
all_options:
|
|
57
|
-
- default_date:
|
|
68
|
+
- default_date: 2024-12-31
|
|
69
|
+
min_date: 2024-01-01
|
|
70
|
+
max_date: 2024-12-31
|
|
58
71
|
|
|
59
72
|
- type: DateRangeParameter
|
|
60
73
|
factory: CreateWithOptions
|
|
@@ -63,8 +76,10 @@ parameters:
|
|
|
63
76
|
label: Date Range
|
|
64
77
|
description: Date range to filter transactions by
|
|
65
78
|
all_options:
|
|
66
|
-
- default_start_date:
|
|
67
|
-
default_end_date:
|
|
79
|
+
- default_start_date: 2024-01-01
|
|
80
|
+
default_end_date: 2024-12-31
|
|
81
|
+
min_date: 2024-01-01
|
|
82
|
+
max_date: 2024-12-31
|
|
68
83
|
|
|
69
84
|
- type: MultiSelectParameter
|
|
70
85
|
factory: CreateFromSource
|
|
@@ -107,7 +122,7 @@ parameters:
|
|
|
107
122
|
description: Number to filter on transactions with an amount greater than this value
|
|
108
123
|
all_options:
|
|
109
124
|
- min_value: 0
|
|
110
|
-
max_value:
|
|
125
|
+
max_value: 300
|
|
111
126
|
increment: 10 ## optional, default is 1, exists for Number and NumberRange options
|
|
112
127
|
default_value: null ## optional, default, exists for Number options only
|
|
113
128
|
|
|
@@ -118,12 +133,12 @@ parameters:
|
|
|
118
133
|
label: Amounts Less Than
|
|
119
134
|
description: Number to filter on transactions with an amount less than this value
|
|
120
135
|
data_source:
|
|
121
|
-
table_or_query: "SELECT 0 as min_value,
|
|
136
|
+
table_or_query: "SELECT 0 as min_value, 300 as max_value, 10 as increment"
|
|
122
137
|
min_value_col: min_value
|
|
123
138
|
max_value_col: max_value
|
|
124
139
|
increment_col: increment ## optional, default is null
|
|
125
140
|
default_value_col: max_value ## optional, default is null
|
|
126
|
-
id_col: null ## optional, default, required for SingleSelect and MultiSelect, optional for
|
|
141
|
+
id_col: null ## optional, default, required for SingleSelect and MultiSelect, optional for others
|
|
127
142
|
|
|
128
143
|
- type: NumberRangeParameter
|
|
129
144
|
factory: CreateWithOptions
|
|
@@ -133,8 +148,8 @@ parameters:
|
|
|
133
148
|
description: Number range to filter on transactions with an amount within this range
|
|
134
149
|
all_options:
|
|
135
150
|
- min_value: 0
|
|
136
|
-
max_value:
|
|
137
|
-
default_lower_value:
|
|
138
|
-
default_upper_value:
|
|
151
|
+
max_value: 300
|
|
152
|
+
default_lower_value: 0 ## optional, default is null (or min_value), exists for NumRange options only
|
|
153
|
+
default_upper_value: 300 ## optional, default is null (or max_value), exists for NumRange options only
|
|
139
154
|
|
|
140
155
|
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
from
|
|
2
|
-
from squirrels import ConnectionsArgs
|
|
1
|
+
from typing import Any
|
|
2
|
+
from squirrels import ConnectionsArgs, ConnectionProperties, ConnectionType
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
def main(connections: dict[str,
|
|
5
|
+
def main(connections: dict[str, ConnectionProperties | Any], sqrl: ConnectionsArgs) -> None:
|
|
6
6
|
"""
|
|
7
7
|
Define sqlalchemy engines by adding them to the "connections" dictionary
|
|
8
8
|
"""
|
|
9
|
-
|
|
10
9
|
## SQLAlchemy URL for a connection engine
|
|
11
|
-
conn_str =
|
|
10
|
+
conn_str: str = sqrl.env_vars["SQLITE_URI"].format(project_path=sqrl.project_path)
|
|
12
11
|
|
|
13
|
-
## Can also leverage environment variables and credentials in the env.yml file for connection details
|
|
14
|
-
# conn_str_raw: str = sqrl.env_vars["sqlite_conn_str"]
|
|
15
|
-
# username, password = sqrl.get_credential('my_key')
|
|
16
|
-
# conn_str = conn_str_raw.format(username=username, password=password)
|
|
17
|
-
|
|
18
12
|
## Assigning names to connection engines
|
|
19
|
-
connections["default"] =
|
|
13
|
+
connections["default"] = ConnectionProperties(label="SQLite Expenses Database", type=ConnectionType.SQLALCHEMY, uri=conn_str)
|
|
14
|
+
|
|
@@ -16,84 +16,71 @@ def main(ctx: dict[str, Any], sqrl: ContextArgs) -> None:
|
|
|
16
16
|
|
|
17
17
|
columns = group_by_param.get_selected("columns")
|
|
18
18
|
aliases = group_by_param.get_selected("aliases", default_field="columns")
|
|
19
|
-
assert isinstance(columns, list) and isinstance(aliases, list)
|
|
19
|
+
assert isinstance(columns, list) and isinstance(aliases, list) and len(columns) == len(aliases)
|
|
20
20
|
|
|
21
21
|
ctx["select_dim_cols"] = ", ".join(x+" as "+y for x, y in zip(columns, aliases))
|
|
22
22
|
ctx["group_by_cols"] = ", ".join(columns)
|
|
23
23
|
ctx["order_by_cols"] = ", ".join((x+" DESC") for x in aliases)
|
|
24
|
-
ctx["
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
desc_pattern = descript_param.get_entered_text().apply_percent_wrap()
|
|
24
|
+
ctx["group_by_cols_list"] = columns
|
|
25
|
+
ctx["rename_dict"] = {old: new for old, new in zip(columns, aliases)}
|
|
26
|
+
|
|
27
|
+
if sqrl.param_exists("limit"):
|
|
28
|
+
limit_param = sqrl.prms["limit"]
|
|
29
|
+
assert isinstance(limit_param, p.NumberParameter)
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
ctx["limit_clause"] = f"LIMIT {limit_param.get_selected_value()}"
|
|
32
|
+
else:
|
|
33
|
+
ctx["limit_clause"] = ""
|
|
33
34
|
|
|
34
35
|
if sqrl.param_exists("start_date"):
|
|
35
36
|
start_date_param = sqrl.prms["start_date"]
|
|
36
37
|
assert isinstance(start_date_param, p.DateParameter)
|
|
37
38
|
|
|
38
|
-
start_date = start_date_param.
|
|
39
|
-
|
|
40
|
-
sqrl.set_placeholder("start_date", start_date)
|
|
39
|
+
ctx["start_date"] = start_date_param.get_selected_date_quoted()
|
|
41
40
|
|
|
42
41
|
if sqrl.param_exists("end_date"):
|
|
43
42
|
end_date_param = sqrl.prms["end_date"]
|
|
44
43
|
assert isinstance(end_date_param, p.DateParameter)
|
|
45
44
|
|
|
46
|
-
end_date = end_date_param.
|
|
47
|
-
|
|
48
|
-
sqrl.set_placeholder("end_date", end_date)
|
|
45
|
+
ctx["end_date"] = end_date_param.get_selected_date_quoted()
|
|
49
46
|
|
|
50
47
|
if sqrl.param_exists("date_range"):
|
|
51
48
|
date_range_param = sqrl.prms["date_range"]
|
|
52
49
|
assert isinstance(date_range_param, p.DateRangeParameter)
|
|
53
50
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
sqrl.set_placeholder("start_date", start_date)
|
|
58
|
-
sqrl.set_placeholder("end_date", end_date)
|
|
51
|
+
ctx["start_date_from_range"] = date_range_param.get_selected_start_date_quoted()
|
|
52
|
+
ctx["end_date_from_range"] = date_range_param.get_selected_end_date_quoted()
|
|
59
53
|
|
|
60
54
|
if sqrl.param_exists("category"):
|
|
61
55
|
category_param = sqrl.prms["category"]
|
|
62
56
|
assert isinstance(category_param, p.MultiSelectParameter)
|
|
63
57
|
|
|
64
58
|
ctx["has_categories"] = category_param.has_non_empty_selection()
|
|
65
|
-
ctx["categories"] = category_param.
|
|
59
|
+
ctx["categories"] = category_param.get_selected_ids_quoted_joined()
|
|
66
60
|
|
|
67
61
|
if sqrl.param_exists("subcategory"):
|
|
68
62
|
subcategory_param = sqrl.prms["subcategory"]
|
|
69
63
|
assert isinstance(subcategory_param, p.MultiSelectParameter)
|
|
70
64
|
|
|
71
65
|
ctx["has_subcategories"] = subcategory_param.has_non_empty_selection()
|
|
72
|
-
ctx["subcategories"] = subcategory_param.
|
|
66
|
+
ctx["subcategories"] = subcategory_param.get_selected_ids_quoted_joined()
|
|
73
67
|
|
|
74
68
|
if sqrl.param_exists("min_filter"):
|
|
75
69
|
min_amount_filter = sqrl.prms["min_filter"]
|
|
76
70
|
assert isinstance(min_amount_filter, p.NumberParameter)
|
|
77
71
|
|
|
78
|
-
min_amount = min_amount_filter.get_selected_value()
|
|
79
|
-
|
|
80
|
-
sqrl.set_placeholder("min_amount", min_amount)
|
|
72
|
+
ctx["min_amount"] = min_amount_filter.get_selected_value()
|
|
81
73
|
|
|
82
74
|
if sqrl.param_exists("max_filter"):
|
|
83
75
|
max_amount_filter = sqrl.prms["max_filter"]
|
|
84
76
|
assert isinstance(max_amount_filter, p.NumberParameter)
|
|
85
77
|
|
|
86
|
-
max_amount = max_amount_filter.get_selected_value()
|
|
87
|
-
|
|
88
|
-
sqrl.set_placeholder("max_amount", max_amount)
|
|
78
|
+
ctx["max_amount"] = max_amount_filter.get_selected_value()
|
|
89
79
|
|
|
90
80
|
if sqrl.param_exists("between_filter"):
|
|
91
81
|
between_filter = sqrl.prms["between_filter"]
|
|
92
82
|
assert isinstance(between_filter, p.NumberRangeParameter)
|
|
93
83
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
sqrl.set_placeholder("min_amount", min_amount)
|
|
98
|
-
sqrl.set_placeholder("max_amount", max_amount)
|
|
84
|
+
ctx["min_amount_from_range"] = between_filter.get_selected_lower_value()
|
|
85
|
+
ctx["max_amount_from_range"] = between_filter.get_selected_upper_value()
|
|
99
86
|
|
|
@@ -17,30 +17,28 @@ def main(sqrl: ParametersArgs) -> None:
|
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
## Example of creating SingleSelectParameter and specifying each option by code
|
|
20
|
+
user_attribute = "role"
|
|
20
21
|
group_by_options = [
|
|
21
|
-
po.SelectParameterOption("g0", "Transaction", columns=["
|
|
22
|
-
po.SelectParameterOption("g1", "
|
|
23
|
-
po.SelectParameterOption("g4", "Month", columns=["month"]),
|
|
24
|
-
po.SelectParameterOption("g2", "Category", columns=["category"]),
|
|
25
|
-
po.SelectParameterOption("g3", "Subcategory", columns=["category", "subcategory"]),
|
|
22
|
+
po.SelectParameterOption("g0", "Transaction", columns=["date", "category", "subcategory", "description"], user_groups=["manager"]),
|
|
23
|
+
po.SelectParameterOption("g1", "Day", columns=["date"], aliases=["day"], user_groups=["manager", "employee"]),
|
|
24
|
+
po.SelectParameterOption("g4", "Month", columns=["month"], user_groups=["manager", "employee"]),
|
|
25
|
+
po.SelectParameterOption("g2", "Category", columns=["category"], user_groups=["manager", "employee"]),
|
|
26
|
+
po.SelectParameterOption("g3", "Subcategory", columns=["category", "subcategory"], user_groups=["manager", "employee"]),
|
|
26
27
|
]
|
|
27
28
|
p.SingleSelectParameter.CreateWithOptions(
|
|
28
|
-
"group_by", "Group By", group_by_options, description="Dimension(s) to aggregate by"
|
|
29
|
+
"group_by", "Group By", group_by_options, description="Dimension(s) to aggregate by", user_attribute=user_attribute
|
|
29
30
|
)
|
|
30
31
|
|
|
31
|
-
## Example of creating
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
p.TextParameter.CreateWithOptions(
|
|
37
|
-
"description_filter", "Description Contains", description_text_options, parent_name=parent_name,
|
|
38
|
-
description="Substring of description to filter transactions by"
|
|
32
|
+
## Example of creating NumberParameter with options
|
|
33
|
+
parent = "group_by"
|
|
34
|
+
limit_options = [po.NumberParameterOption(0, 1000, increment=10, default_value=1000, parent_option_ids="g0")]
|
|
35
|
+
p.NumberParameter.CreateWithOptions(
|
|
36
|
+
"limit", "Max Number of Rows", limit_options, parent_name=parent, description="Maximum number of rows to return"
|
|
39
37
|
)
|
|
40
38
|
|
|
41
|
-
## Example of creating DateParameter
|
|
39
|
+
## Example of creating DateParameter
|
|
42
40
|
start_date_source = ds.DateDataSource(
|
|
43
|
-
"SELECT min(date) AS min_date, max(date) AS max_date FROM
|
|
41
|
+
"SELECT min(date) AS min_date, max(date) AS max_date FROM expenses",
|
|
44
42
|
default_date_col="min_date", min_date_col="min_date", max_date_col="max_date"
|
|
45
43
|
)
|
|
46
44
|
p.DateParameter.CreateFromSource(
|
|
@@ -48,14 +46,14 @@ def main(sqrl: ParametersArgs) -> None:
|
|
|
48
46
|
)
|
|
49
47
|
|
|
50
48
|
## Example of creating DateParameter from list of DateParameterOption's
|
|
51
|
-
end_date_option = [po.DateParameterOption("
|
|
49
|
+
end_date_option = [po.DateParameterOption("2024-12-31", min_date="2024-01-01", max_date="2024-12-31")]
|
|
52
50
|
p.DateParameter.CreateWithOptions(
|
|
53
51
|
"end_date", "End Date", end_date_option, description="End date to filter transactions by"
|
|
54
52
|
)
|
|
55
53
|
|
|
56
54
|
## Example of creating DateRangeParameter
|
|
57
55
|
p.DateRangeParameter.CreateSimple(
|
|
58
|
-
"date_range", "Date Range", "
|
|
56
|
+
"date_range", "Date Range", "2024-01-01", "2024-12-31", min_date="2024-01-01", max_date="2024-12-31",
|
|
59
57
|
description="Date range to filter transactions by"
|
|
60
58
|
)
|
|
61
59
|
|
|
@@ -77,12 +75,12 @@ def main(sqrl: ParametersArgs) -> None:
|
|
|
77
75
|
|
|
78
76
|
## Example of creating NumberParameter
|
|
79
77
|
p.NumberParameter.CreateSimple(
|
|
80
|
-
"min_filter", "Amounts Greater Than", min_value=0, max_value=
|
|
78
|
+
"min_filter", "Amounts Greater Than", min_value=0, max_value=300, increment=10,
|
|
81
79
|
description="Number to filter on transactions with an amount greater than this value"
|
|
82
80
|
)
|
|
83
81
|
|
|
84
82
|
## Example of creating NumberParameter from lookup query/table
|
|
85
|
-
query = "SELECT 0 as min_value,
|
|
83
|
+
query = "SELECT 0 as min_value, 300 as max_value, 10 as increment"
|
|
86
84
|
max_amount_ds = ds.NumberDataSource(query, "min_value", "max_value", increment_col="increment", default_value_col="max_value")
|
|
87
85
|
p.NumberParameter.CreateFromSource(
|
|
88
86
|
"max_filter", "Amounts Less Than", max_amount_ds, description="Number to filter on transactions with an amount less than this value"
|
|
@@ -90,6 +88,6 @@ def main(sqrl: ParametersArgs) -> None:
|
|
|
90
88
|
|
|
91
89
|
## Example of creating NumberRangeParameter
|
|
92
90
|
p.NumberRangeParameter.CreateSimple(
|
|
93
|
-
"between_filter", "Amounts Between", 0,
|
|
91
|
+
"between_filter", "Amounts Between", 0, 300, default_lower_value=0, default_upper_value=300,
|
|
94
92
|
description="Number range to filter on transactions with an amount within this range"
|
|
95
93
|
)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
from squirrels import BaseUser
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class User(BaseUser):
|
|
6
|
+
"""
|
|
7
|
+
Extend the BaseUser class with custom attributes. The attributes defined here will be added as columns to the users table.
|
|
8
|
+
- Only the following types are supported: [str, int, float, bool, typing.Literal]
|
|
9
|
+
- For str, int, and float types, add "| None" after the type to make it nullable.
|
|
10
|
+
- Always set a default value for the column (use None if default is null).
|
|
11
|
+
|
|
12
|
+
Example:
|
|
13
|
+
organization: str | None = None
|
|
14
|
+
"""
|
|
15
|
+
role: Literal["manager", "employee"] = "employee"
|
|
16
|
+
|
|
17
|
+
@classmethod
|
|
18
|
+
def dropped_columns(cls) -> list[str]:
|
|
19
|
+
"""
|
|
20
|
+
The fields defined above cannot be modified once added to the database.
|
|
21
|
+
However, you can choose to drop columns by adding them to this list.
|
|
22
|
+
"""
|
|
23
|
+
return []
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
description: |
|
|
2
|
+
Lookup table for the category IDs and names of transactions.
|
|
3
|
+
|
|
4
|
+
cast_column_types: true # optional, default is false - setting SQRL_SEEDS__INFER_SCHEMA is ignored for this seed if this is set to true
|
|
5
|
+
|
|
6
|
+
columns:
|
|
7
|
+
- name: category_id
|
|
8
|
+
type: string
|
|
9
|
+
description: The category ID
|
|
10
|
+
category: dimension
|
|
11
|
+
|
|
12
|
+
- name: category
|
|
13
|
+
type: string
|
|
14
|
+
description: The human-readable category name
|
|
15
|
+
category: dimension
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"
|
|
2
|
-
"Dining Out","0"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"Ride Sharing","3"
|
|
7
|
-
"
|
|
8
|
-
"Home Decor","2"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"Public Transit","3"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
1
|
+
"subcategory_id","subcategory","category_id"
|
|
2
|
+
"0","Dining Out","0"
|
|
3
|
+
"1","Groceries","0"
|
|
4
|
+
"2","Utilities","1"
|
|
5
|
+
"3","Electronics","2"
|
|
6
|
+
"4","Ride Sharing","3"
|
|
7
|
+
"5","Mobile","1"
|
|
8
|
+
"6","Home Decor","2"
|
|
9
|
+
"7","Internet","1"
|
|
10
|
+
"8","Theater","4"
|
|
11
|
+
"9","Movies","4"
|
|
12
|
+
"10","Sports","2"
|
|
13
|
+
"11","Public Transit","3"
|
|
14
|
+
"12","Clothing","2"
|
|
15
|
+
"13","Concerts","4"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
description: |
|
|
2
|
+
Lookup table for the subcategory IDs and names of transactions.
|
|
3
|
+
|
|
4
|
+
cast_column_types: true # optional, default is false - setting SQRL_SEEDS__INFER_SCHEMA is ignored for this seed if this is set to true
|
|
5
|
+
|
|
6
|
+
columns:
|
|
7
|
+
- name: subcategory_id
|
|
8
|
+
type: string
|
|
9
|
+
description: The subcategory ID
|
|
10
|
+
category: dimension
|
|
11
|
+
|
|
12
|
+
- name: subcategory
|
|
13
|
+
type: string
|
|
14
|
+
description: The human-readable subcategory name
|
|
15
|
+
category: dimension
|
|
16
|
+
|
|
17
|
+
- name: category_id
|
|
18
|
+
type: string
|
|
19
|
+
description: The category ID that the subcategory belongs to
|
|
20
|
+
category: dimension
|
|
21
|
+
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
project_variables:
|
|
2
2
|
name: sample
|
|
3
|
-
label: Sample Project
|
|
3
|
+
label: Sample Project - Expenses
|
|
4
|
+
description: This is a sample squirrels project for analyzing expense transactions
|
|
4
5
|
major_version: 1
|
|
5
6
|
|
|
6
7
|
|
|
@@ -20,28 +21,26 @@ packages: []
|
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
datasets:
|
|
23
|
-
- name:
|
|
24
|
-
label: Dataset
|
|
25
|
-
|
|
24
|
+
- name: dbview_dataset_example ## model name uses same name unless "model" field is specified
|
|
25
|
+
label: Example Dataset from DBView Model
|
|
26
|
+
description: Aggregated expense transactions by month using dbview_example model
|
|
27
|
+
model: dbview_example
|
|
26
28
|
scope: public ## optional - one of 'public' (default), 'protected', or 'private'
|
|
27
29
|
parameters: ## optional - if not specified, then all parameters are used
|
|
28
|
-
- group_by
|
|
29
|
-
- description_filter
|
|
30
30
|
- start_date
|
|
31
31
|
- end_date
|
|
32
|
-
- category
|
|
33
|
-
- subcategory
|
|
34
32
|
- min_filter
|
|
35
33
|
- max_filter
|
|
36
34
|
traits: {} ## optional - defaults to empty object
|
|
37
35
|
|
|
38
|
-
- name:
|
|
39
|
-
label: Dataset
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
- name: federate_dataset_example
|
|
37
|
+
label: Example Dataset from Federate Model
|
|
38
|
+
description: Aggregated expense transactions by custom dimension using federate_example model
|
|
39
|
+
model: federate_example
|
|
40
|
+
scope: protected ## using an auth.py file is suggested for protected or private datasets
|
|
42
41
|
parameters:
|
|
43
42
|
- group_by
|
|
44
|
-
-
|
|
43
|
+
- limit
|
|
45
44
|
- date_range
|
|
46
45
|
- category
|
|
47
46
|
- subcategory
|
|
@@ -49,46 +48,24 @@ datasets:
|
|
|
49
48
|
default_test_set: auth_test1 ## optional - if not specified, uses setting 'selection_test_sets.default_name_used'
|
|
50
49
|
|
|
51
50
|
|
|
52
|
-
{{ dashboards -}}
|
|
53
|
-
|
|
54
|
-
|
|
55
51
|
selection_test_sets:
|
|
56
52
|
- name: no_auth_test1
|
|
57
53
|
datasets: ## optional section - if not provided, then test set is applicable for any dataset
|
|
58
|
-
-
|
|
54
|
+
- dbview_dataset_example
|
|
59
55
|
parameters: ## optional section - if not provided, then assumes no parameters. For unspecified parameters, default value is used
|
|
60
|
-
start_date:
|
|
56
|
+
start_date: 2024-07-01 ## this parameter only exists for dataset 'dataset_example'
|
|
61
57
|
|
|
62
58
|
- name: auth_test1
|
|
63
59
|
datasets:
|
|
64
|
-
-
|
|
60
|
+
- federate_dataset_example
|
|
65
61
|
user_attributes: ## optional section - required if using test set on non-public datasets
|
|
66
|
-
role:
|
|
62
|
+
role: employee
|
|
67
63
|
parameters:
|
|
68
|
-
date_range: [
|
|
64
|
+
date_range: [2024-02-01,2024-12-01] ## this parameter only exists for dataset 'protected_dataset_example'
|
|
69
65
|
|
|
70
66
|
- name: auth_test2
|
|
71
67
|
user_attributes:
|
|
72
|
-
username: alice ## optional - defaults to empty string
|
|
73
68
|
is_internal: True ## optional - defaults to False
|
|
74
69
|
role: manager
|
|
75
70
|
parameters:
|
|
76
71
|
group_by: g3 ## this parameter exists for all datasets. "g3" is the id for option "subcategory"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
settings: {}
|
|
80
|
-
|
|
81
|
-
## Default values for settings:
|
|
82
|
-
# auth.token.expire_minutes: 30
|
|
83
|
-
# parameters.cache.size: 1024
|
|
84
|
-
# parameters.cache.ttl_minutes: 60
|
|
85
|
-
# datasets.cache.size: 128
|
|
86
|
-
# datasets.cache.ttl_minutes: 60
|
|
87
|
-
# dashboards.cache.size: 128
|
|
88
|
-
# dashboards.cache.ttl_minutes: 60
|
|
89
|
-
# selection_test_sets.default_name_used: default
|
|
90
|
-
# connections.default_name_used: default
|
|
91
|
-
# defaults.federates.materialized: table
|
|
92
|
-
# in_memory_database: sqlite
|
|
93
|
-
# seeds.infer_schema: True
|
|
94
|
-
# seeds.na_values: [NA]
|