squirrels 0.5.0rc0__py3-none-any.whl → 0.5.1__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.
- dateutils/__init__.py +6 -0
- dateutils/_enums.py +25 -0
- squirrels/dateutils.py → dateutils/_implementation.py +58 -111
- dateutils/types.py +6 -0
- squirrels/__init__.py +10 -12
- squirrels/_api_routes/__init__.py +5 -0
- squirrels/_api_routes/auth.py +271 -0
- squirrels/_api_routes/base.py +171 -0
- squirrels/_api_routes/dashboards.py +158 -0
- squirrels/_api_routes/data_management.py +148 -0
- squirrels/_api_routes/datasets.py +265 -0
- squirrels/_api_routes/oauth2.py +298 -0
- squirrels/_api_routes/project.py +252 -0
- squirrels/_api_server.py +245 -781
- squirrels/_arguments/__init__.py +0 -0
- squirrels/{arguments → _arguments}/init_time_args.py +7 -2
- squirrels/{arguments → _arguments}/run_time_args.py +13 -35
- squirrels/_auth.py +720 -212
- squirrels/_command_line.py +81 -41
- squirrels/_compile_prompts.py +147 -0
- squirrels/_connection_set.py +16 -7
- squirrels/_constants.py +29 -9
- squirrels/{_dashboards_io.py → _dashboards.py} +87 -6
- squirrels/_data_sources.py +570 -0
- squirrels/{dataset_result.py → _dataset_types.py} +2 -4
- squirrels/_exceptions.py +9 -37
- squirrels/_initializer.py +83 -59
- squirrels/_logging.py +117 -0
- squirrels/_manifest.py +129 -62
- squirrels/_model_builder.py +10 -52
- squirrels/_model_configs.py +3 -3
- squirrels/_model_queries.py +1 -1
- squirrels/_models.py +249 -118
- squirrels/{package_data → _package_data}/base_project/.env +16 -4
- squirrels/{package_data → _package_data}/base_project/.env.example +15 -3
- squirrels/{package_data → _package_data}/base_project/connections.yml +4 -3
- squirrels/{package_data → _package_data}/base_project/dashboards/dashboard_example.py +4 -4
- squirrels/_package_data/base_project/dashboards/dashboard_example.yml +22 -0
- squirrels/{package_data → _package_data}/base_project/duckdb_init.sql +1 -0
- squirrels/_package_data/base_project/macros/macros_example.sql +17 -0
- squirrels/{package_data → _package_data}/base_project/models/builds/build_example.py +2 -2
- squirrels/{package_data → _package_data}/base_project/models/builds/build_example.sql +1 -1
- squirrels/{package_data → _package_data}/base_project/models/builds/build_example.yml +2 -0
- squirrels/_package_data/base_project/models/dbviews/dbview_example.sql +17 -0
- squirrels/_package_data/base_project/models/dbviews/dbview_example.yml +32 -0
- squirrels/_package_data/base_project/models/federates/federate_example.py +48 -0
- squirrels/_package_data/base_project/models/federates/federate_example.sql +21 -0
- squirrels/{package_data → _package_data}/base_project/models/federates/federate_example.yml +7 -7
- squirrels/{package_data → _package_data}/base_project/models/sources.yml +5 -6
- squirrels/{package_data → _package_data}/base_project/parameters.yml +32 -45
- squirrels/_package_data/base_project/pyconfigs/connections.py +18 -0
- squirrels/{package_data → _package_data}/base_project/pyconfigs/context.py +31 -22
- squirrels/_package_data/base_project/pyconfigs/parameters.py +141 -0
- squirrels/_package_data/base_project/pyconfigs/user.py +44 -0
- squirrels/{package_data → _package_data}/base_project/seeds/seed_categories.yml +1 -1
- squirrels/{package_data → _package_data}/base_project/seeds/seed_subcategories.yml +1 -1
- squirrels/_package_data/base_project/squirrels.yml.j2 +61 -0
- squirrels/_package_data/templates/dataset_results.html +112 -0
- squirrels/_package_data/templates/oauth_login.html +271 -0
- squirrels/_package_data/templates/squirrels_studio.html +20 -0
- squirrels/_parameter_configs.py +76 -55
- squirrels/_parameter_options.py +348 -0
- squirrels/_parameter_sets.py +53 -45
- squirrels/_parameters.py +1664 -0
- squirrels/_project.py +403 -242
- squirrels/_py_module.py +3 -2
- squirrels/_request_context.py +33 -0
- squirrels/_schemas/__init__.py +0 -0
- squirrels/_schemas/auth_models.py +167 -0
- squirrels/_schemas/query_param_models.py +75 -0
- squirrels/{_api_response_models.py → _schemas/response_models.py} +48 -18
- squirrels/_seeds.py +1 -1
- squirrels/_sources.py +23 -19
- squirrels/_utils.py +121 -39
- squirrels/_version.py +1 -1
- squirrels/arguments.py +7 -0
- squirrels/auth.py +4 -0
- squirrels/connections.py +3 -0
- squirrels/dashboards.py +2 -81
- squirrels/data_sources.py +14 -563
- squirrels/parameter_options.py +13 -348
- squirrels/parameters.py +14 -1266
- squirrels/types.py +16 -0
- {squirrels-0.5.0rc0.dist-info → squirrels-0.5.1.dist-info}/METADATA +42 -30
- squirrels-0.5.1.dist-info/RECORD +98 -0
- squirrels/package_data/base_project/dashboards/dashboard_example.yml +0 -22
- squirrels/package_data/base_project/macros/macros_example.sql +0 -15
- squirrels/package_data/base_project/models/dbviews/dbview_example.sql +0 -12
- squirrels/package_data/base_project/models/dbviews/dbview_example.yml +0 -26
- squirrels/package_data/base_project/models/federates/federate_example.py +0 -44
- squirrels/package_data/base_project/models/federates/federate_example.sql +0 -17
- squirrels/package_data/base_project/pyconfigs/connections.py +0 -14
- squirrels/package_data/base_project/pyconfigs/parameters.py +0 -93
- squirrels/package_data/base_project/pyconfigs/user.py +0 -23
- squirrels/package_data/base_project/squirrels.yml.j2 +0 -71
- squirrels-0.5.0rc0.dist-info/RECORD +0 -70
- /squirrels/{package_data → _package_data}/base_project/assets/expenses.db +0 -0
- /squirrels/{package_data → _package_data}/base_project/assets/weather.db +0 -0
- /squirrels/{package_data → _package_data}/base_project/docker/.dockerignore +0 -0
- /squirrels/{package_data → _package_data}/base_project/docker/Dockerfile +0 -0
- /squirrels/{package_data → _package_data}/base_project/docker/compose.yml +0 -0
- /squirrels/{package_data/base_project/.gitignore → _package_data/base_project/gitignore} +0 -0
- /squirrels/{package_data → _package_data}/base_project/seeds/seed_categories.csv +0 -0
- /squirrels/{package_data → _package_data}/base_project/seeds/seed_subcategories.csv +0 -0
- /squirrels/{package_data → _package_data}/base_project/tmp/.gitignore +0 -0
- {squirrels-0.5.0rc0.dist-info → squirrels-0.5.1.dist-info}/WHEEL +0 -0
- {squirrels-0.5.0rc0.dist-info → squirrels-0.5.1.dist-info}/entry_points.txt +0 -0
- {squirrels-0.5.0rc0.dist-info → squirrels-0.5.1.dist-info}/licenses/LICENSE +0 -0
squirrels/types.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from ._data_sources import DataSource
|
|
2
|
+
|
|
3
|
+
from ._parameter_options import ParameterOption
|
|
4
|
+
|
|
5
|
+
from ._parameters import Parameter, TextValue
|
|
6
|
+
|
|
7
|
+
from ._dataset_types import DatasetMetadata, DatasetResult
|
|
8
|
+
|
|
9
|
+
from ._dashboards import Dashboard
|
|
10
|
+
|
|
11
|
+
from ._parameter_configs import ParameterConfigBase
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"DataSource", "ParameterOption", "Parameter", "TextValue",
|
|
15
|
+
"DatasetMetadata", "DatasetResult", "Dashboard", "ParameterConfigBase"
|
|
16
|
+
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: squirrels
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: Squirrels - API Framework for Data Analytics
|
|
5
5
|
Project-URL: Homepage, https://squirrels-analytics.github.io
|
|
6
6
|
Project-URL: Repository, https://github.com/squirrels-analytics/squirrels
|
|
@@ -13,26 +13,28 @@ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
|
13
13
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
14
14
|
Classifier: Typing :: Typed
|
|
15
15
|
Requires-Python: ~=3.10
|
|
16
|
+
Requires-Dist: authlib<2,>=1.5.2
|
|
16
17
|
Requires-Dist: bcrypt<5,>=4.0.1
|
|
17
|
-
Requires-Dist: cachetools
|
|
18
|
-
Requires-Dist: duckdb<2,>=1.
|
|
18
|
+
Requires-Dist: cachetools>=5.3.2
|
|
19
|
+
Requires-Dist: duckdb<2,>=1.4.0
|
|
19
20
|
Requires-Dist: fastapi<1,>=0.112.1
|
|
20
21
|
Requires-Dist: gitpython<4,>=3.1.41
|
|
21
22
|
Requires-Dist: inquirer<4,>=3.2.1
|
|
23
|
+
Requires-Dist: itsdangerous<3,>=2.2.0
|
|
22
24
|
Requires-Dist: jinja2<4,>=3.1.3
|
|
25
|
+
Requires-Dist: libpass<2,>=1.9.0
|
|
23
26
|
Requires-Dist: matplotlib<4,>=3.8.3
|
|
24
|
-
Requires-Dist:
|
|
27
|
+
Requires-Dist: mcp>=1.13.1
|
|
25
28
|
Requires-Dist: pandas<3,>=2.1.4
|
|
26
|
-
Requires-Dist: passlib<2,>=1.7.4
|
|
27
29
|
Requires-Dist: polars<2,>=1.14.0
|
|
28
|
-
Requires-Dist: pyarrow
|
|
30
|
+
Requires-Dist: pyarrow>=19.0.1
|
|
29
31
|
Requires-Dist: pydantic<3,>=2.8.2
|
|
30
32
|
Requires-Dist: pyjwt<3,>=2.8.0
|
|
31
33
|
Requires-Dist: python-dotenv<2,>=1.0.1
|
|
32
34
|
Requires-Dist: python-multipart<1,>=0.0.9
|
|
33
35
|
Requires-Dist: pyyaml<7,>=6.0.1
|
|
34
36
|
Requires-Dist: sqlalchemy<3,>=2.0.25
|
|
35
|
-
Requires-Dist: sqlglot
|
|
37
|
+
Requires-Dist: sqlglot>=26.12.1
|
|
36
38
|
Requires-Dist: uvicorn<1,>=0.30.6
|
|
37
39
|
Description-Content-Type: text/markdown
|
|
38
40
|
|
|
@@ -48,22 +50,38 @@ Squirrels is an API framework that lets you create REST APIs for dynamic data an
|
|
|
48
50
|
|
|
49
51
|
- [Main Features](#main-features)
|
|
50
52
|
- [License](#license)
|
|
51
|
-
- [Contributing to
|
|
53
|
+
- [Contributing to Squirrels](#contributing-to-squirrels)
|
|
52
54
|
- [Setup](#setup)
|
|
53
55
|
- [Testing](#testing)
|
|
54
56
|
- [Project Structure](#project-structure)
|
|
55
57
|
|
|
56
58
|
## Main Features
|
|
57
59
|
|
|
58
|
-
Here are a few of the things that
|
|
60
|
+
Here are a few of the things that Squirrels can do:
|
|
59
61
|
|
|
60
62
|
- Connect to any database by specifying its SQLAlchemy url (in `squirrels.yml`) or by using its native connector library in python (in `connections.py`).
|
|
61
63
|
- Configure API routes for datasets (in `squirrels.yml`) without writing code.
|
|
62
64
|
- Configure parameter widgets (types include single-select, multi-select, date, number, etc.) for your datasets (in `parameters.py`).
|
|
63
|
-
- Use
|
|
65
|
+
- Use SQL templates (templated with Jinja, like dbt) or python functions (that return a Python dataframe in polars or pandas) to define dynamic query logic based on parameter selections.
|
|
64
66
|
- Query multiple databases and join the results together in a final view in one API endpoint/dataset!
|
|
65
|
-
- Test your API endpoints with
|
|
66
|
-
- Define
|
|
67
|
+
- Test your API endpoints with Squirrels Studio or by a command line that generates rendered sql queries and results as files (for a given set of parameter selections).
|
|
68
|
+
- Define User model (in `user.py`) and authorize privacy scope per dataset (in `squirrels.yml`). The user's attributes can even be used in your query logic!
|
|
69
|
+
- Serve dataset metadata and results to AI agents via MCP (Model Context Protocol)
|
|
70
|
+
|
|
71
|
+
## Quick Start
|
|
72
|
+
|
|
73
|
+
In a new virtual environment, install `squirrels`. Then, in your project directory, activate the virtual environment and run the following commands:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
sqrl new --use-defaults --curr-dir
|
|
77
|
+
sqrl build
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
To run the API server, simply run:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
sqrl run
|
|
84
|
+
```
|
|
67
85
|
|
|
68
86
|
## License
|
|
69
87
|
|
|
@@ -71,46 +89,40 @@ Squirrels is released under the Apache 2.0 license.
|
|
|
71
89
|
|
|
72
90
|
See the file LICENSE for more details.
|
|
73
91
|
|
|
74
|
-
## Contributing to
|
|
92
|
+
## Contributing to Squirrels
|
|
75
93
|
|
|
76
|
-
The sections below describe how to set up your local environment for
|
|
94
|
+
The sections below describe how to set up your local environment for Squirrels development and run unit tests. A high level overview of the project structure is also provided.
|
|
77
95
|
|
|
78
96
|
### Setup
|
|
79
97
|
|
|
80
|
-
This project requires python version 3.10 or above to be installed. It also uses the python
|
|
98
|
+
This project requires python version 3.10 or above to be installed. It also uses the python package manager `uv`. Information on setting up poetry can be found at: https://docs.astral.sh/uv/getting-started/installation/.
|
|
81
99
|
|
|
82
|
-
Then, to install all dependencies, run:
|
|
100
|
+
Then, to install all dependencies in a virtual environment, run:
|
|
83
101
|
|
|
84
|
-
```
|
|
85
|
-
|
|
102
|
+
```bash
|
|
103
|
+
uv sync
|
|
86
104
|
```
|
|
87
105
|
|
|
88
|
-
And activate the virtual environment
|
|
106
|
+
And activate the virtual environment with:
|
|
89
107
|
|
|
90
|
-
```
|
|
91
|
-
|
|
108
|
+
```bash
|
|
109
|
+
source .venv/bin/activate
|
|
92
110
|
```
|
|
93
111
|
|
|
94
|
-
To confirm that the setup worked, run the following to show the help page for all
|
|
112
|
+
To confirm that the setup worked, run the following to show the help page for all Squirrels CLI commands:
|
|
95
113
|
|
|
96
114
|
```bash
|
|
97
115
|
sqrl -h
|
|
98
116
|
```
|
|
99
117
|
|
|
100
|
-
You can enter `exit` to exit the virtual environment shell. You can also run `poetry run sqrl -h` to run squirrels commands without activating the virtual environment.
|
|
101
|
-
|
|
102
118
|
### Testing
|
|
103
119
|
|
|
104
|
-
|
|
120
|
+
Run `uv run pytest`. Or if you have the virtual environment activated, simply run `pytest`.
|
|
105
121
|
|
|
106
122
|
### Project Structure
|
|
107
123
|
|
|
108
124
|
From the root of the git repo, the source code can be found in the `squirrels` folder and unit tests can be found in the `tests` folder.
|
|
109
125
|
|
|
110
|
-
To understand what a specific
|
|
126
|
+
To understand what a specific Squirrels command is doing, start from the `_command_line.py` file as your entry point.
|
|
111
127
|
|
|
112
128
|
The library version is maintained in both the `pyproject.toml` and the `squirrels/_version.py` files.
|
|
113
|
-
|
|
114
|
-
When a user initializes a squirrels project using `sqrl init`, the files are copied from the `squirrels/package_data/base_project` folder. The contents in the `database` subfolder were constructed from the scripts in the `database_elt` folder.
|
|
115
|
-
|
|
116
|
-
For the Squirrels UI activated by `sqrl run`, the HTML, CSS, and Javascript files can be found in the `static` and `templates` subfolders of `squirrels/package_data`. The CSS and Javascript files are minified and built from the source files in this project: https://github.com/squirrels-analytics/squirrels-testing-ui.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
dateutils/__init__.py,sha256=dq4VSlJ5ztaDPdvYBRAvXSyanT_CZif3I4O0YVmWfa8,277
|
|
2
|
+
dateutils/_enums.py,sha256=WBrnLqta_iMMhGMEn24cCO1Vlr7bST0E8oEfAL3z0P8,373
|
|
3
|
+
dateutils/_implementation.py,sha256=PVJAdNolDdTpCZXwvokKoMIZzTSNpCUvZlVLWpMeSho,15173
|
|
4
|
+
dateutils/types.py,sha256=xcRwBoftQi-uHM1tlVTW5xgN84qdrqCo5tQT7A34S8Y,124
|
|
5
|
+
squirrels/__init__.py,sha256=nvzVVd5yHYbpQAfyKdQGDMxZpW7wVq3uUlpg4Urc_ws,320
|
|
6
|
+
squirrels/_api_server.py,sha256=f1Dh3hOqtU8ycMuXWY5s77kYw6O-PaWqQPPR4JMho_0,17965
|
|
7
|
+
squirrels/_auth.py,sha256=wR49uT3mU-4PlgLcZqPgYjSbtwVYHm-2QyclApTiHLU,43532
|
|
8
|
+
squirrels/_command_line.py,sha256=wTJr_WahULV8iZwUyhJIiNTGFd0YByprpo9DBDyczpU,12797
|
|
9
|
+
squirrels/_compile_prompts.py,sha256=XIbRciSXak6NuDD4KedeDoUV5YSHvctQGk6HMxKchBw,5562
|
|
10
|
+
squirrels/_connection_set.py,sha256=qSNcFdEKRcgZyr9OEqAuoIZBk-DY_C_aL_F7OE9GDK4,4457
|
|
11
|
+
squirrels/_constants.py,sha256=SuAaceUN95BLdOt500A8fUx88dvwm-v-WBj3v87z4qM,4035
|
|
12
|
+
squirrels/_dashboards.py,sha256=FF6KG-GXohR5Hp-BMYRwEZ2hUQ_jbkFpcK5epwoD64w,4891
|
|
13
|
+
squirrels/_data_sources.py,sha256=jiTzYsECny4KBnalzuHYy6wQo4YXubJesDLH_a1M3dc,26433
|
|
14
|
+
squirrels/_dataset_types.py,sha256=J9nhLVZ1eOk_qfqjEXRaXQTB9sqyZcE_iUad0NNstgU,2742
|
|
15
|
+
squirrels/_exceptions.py,sha256=-hfDZoV-JhvuNRAERTFg-5NFjr0uNk4i9ogNgJfAyyc,1171
|
|
16
|
+
squirrels/_initializer.py,sha256=9BDMGVbZLdRnV9erzqw1FvpKBlWRk8-uiSsl9UioxJ0,14249
|
|
17
|
+
squirrels/_logging.py,sha256=dhFLZKde7iobSWSMwIBsbO_77tB0TYuDTpABRouAWkw,4142
|
|
18
|
+
squirrels/_manifest.py,sha256=S4TicbPm5-4u9gEocbeO1dKb8CgTV8rsR5RERFjpkU0,12779
|
|
19
|
+
squirrels/_model_builder.py,sha256=gOAcN_C0dfAvBe9YTM3QpdiA_2VeatRSHsALp2OVdJA,2844
|
|
20
|
+
squirrels/_model_configs.py,sha256=eJne5L-QLv42s7uodUOOASMRn1NbzGbiBmwMllkO5C4,3303
|
|
21
|
+
squirrels/_model_queries.py,sha256=2fl07feHtzddBpiXUWGfNBYeoN_EZ7K5mAz2Jc-vCvs,1087
|
|
22
|
+
squirrels/_models.py,sha256=Nq0klbCDRcDF2KL0XlAZopqkSUpv0jaJQPlz3H255DM,54711
|
|
23
|
+
squirrels/_package_loader.py,sha256=xcIur5Z38OWd-OVjsueFstVV567zlkK9UBnLS4NawJY,1158
|
|
24
|
+
squirrels/_parameter_configs.py,sha256=K7p_pIobT-gPZ99ewzLKV1aUzhnmfbGO7WjuzgjhDM8,24867
|
|
25
|
+
squirrels/_parameter_options.py,sha256=HatFFPyHrZo2ct3BS-FCHPzNqcIst4dVh14SgkhhFyw,16874
|
|
26
|
+
squirrels/_parameter_sets.py,sha256=hwzgC4sm6KMIASGlaLlhg-UheH5p0qIKU483pZRLRBU,10275
|
|
27
|
+
squirrels/_parameters.py,sha256=Ta929_a-b8r1miDKXT_SZtHT_d8jJ2W5ABvkXL7k074,76372
|
|
28
|
+
squirrels/_project.py,sha256=7ePxfCF6BTwsbE0i4XQRBm-OxvyAIYG7V36JG1Nyol8,37103
|
|
29
|
+
squirrels/_py_module.py,sha256=NW86sv1oYWh8oMqgGh2oIUwuFcLXoq3cwEuKRxPfEwY,2683
|
|
30
|
+
squirrels/_request_context.py,sha256=5FBxIQJ_Ki0sekZC_XrzS4GIegqoJuPnalQhGBsm-kQ,964
|
|
31
|
+
squirrels/_seeds.py,sha256=Q6ihhou5PBfdH2mKhWEkDOfpdi1CmftUtv8Yz3S18dg,2216
|
|
32
|
+
squirrels/_sources.py,sha256=3tgI5FtMDzFtWBiHa2vF3x4Qaj5Pnu6hK_xSGBAcORI,5102
|
|
33
|
+
squirrels/_utils.py,sha256=5jhZ1UvK1ZR7IJno0TEVL3p6F9Sfx7osBU3Rqf9C2oI,14894
|
|
34
|
+
squirrels/_version.py,sha256=4vCxnO9GT2Qn6oB5htQ_xPhxVh7TjOfYjzjZs11aM5s,105
|
|
35
|
+
squirrels/arguments.py,sha256=6rWDwv8jbimBUYv4peE2kEuFzOQ4jn9Tr_QXUmEj0_o,324
|
|
36
|
+
squirrels/auth.py,sha256=oX5-0QT4aKiUSyImKkLtPLYoki1SVNgaU3KBQzIizP4,193
|
|
37
|
+
squirrels/connections.py,sha256=FVK0se1LUAzsapPZYlWc1q6jTJ6hiU2RuYinBEvZ5a0,122
|
|
38
|
+
squirrels/dashboards.py,sha256=egYWL7jV9hvyxZ0vFziQb4q3sKDLfE_TNJN5niQbzX4,98
|
|
39
|
+
squirrels/data_sources.py,sha256=P3VIGWqspXLlxKUTDXc5u5eJ2yQoo4rvy9RGEb_OIbQ,347
|
|
40
|
+
squirrels/parameter_options.py,sha256=5ucgTWvdwefurMrk7xiJhmRn6fbBXXOhQdH7Mbnm-1I,382
|
|
41
|
+
squirrels/parameters.py,sha256=TJcsjtj0Kg0F69I5Zk7r0uDJC7p8duk3gtjXjcQPE40,366
|
|
42
|
+
squirrels/types.py,sha256=O4SMn9mqeV3wSEr_RIT1CKjumbqcbmZ6wk0tnXcxYHQ,437
|
|
43
|
+
squirrels/_api_routes/__init__.py,sha256=-oGMDfM5Qo7NDiwpjHt8BKVZNNZ4798-NZCJzYCUdbc,106
|
|
44
|
+
squirrels/_api_routes/auth.py,sha256=AvQbvyjrgEgN0kWPuBs8rgfJpsDL9ETFQbeFJ9S6qVw,15206
|
|
45
|
+
squirrels/_api_routes/base.py,sha256=oAIe3JXCeUwEcnPVAhwv5TFtaGhaA-eCfteJI0oj1G0,8260
|
|
46
|
+
squirrels/_api_routes/dashboards.py,sha256=BzSpidoQHyBoPk9igMbalVbnYiCSPbyfda9TW1QxyBw,9281
|
|
47
|
+
squirrels/_api_routes/data_management.py,sha256=03GeaT4m4aKXFO-qvAH7XiFFNJVYimpBvR-p617Qxa0,8752
|
|
48
|
+
squirrels/_api_routes/datasets.py,sha256=U8a1O8S7TeOO8QWPYEGXMdW1P9lqeRuFFGN7eYgApx8,15612
|
|
49
|
+
squirrels/_api_routes/oauth2.py,sha256=JXx5svIz0gVt6SHFOG-Ql9QcoJIizQ5IVFPPnZ5V1Bg,14827
|
|
50
|
+
squirrels/_api_routes/project.py,sha256=alH0IwyPe2-tctrTwok30BSogVAR2o7GX-lZRz261Ww,14140
|
|
51
|
+
squirrels/_arguments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
52
|
+
squirrels/_arguments/init_time_args.py,sha256=Y5gVbrU_yd1r5JtAChcL1xTpfz0i8gwNtZMe5QBT2mc,3511
|
|
53
|
+
squirrels/_arguments/run_time_args.py,sha256=bnibUxUHnLvKR1tlri0WCuqRnYKXi0mJ8R_rhIDEil0,5100
|
|
54
|
+
squirrels/_package_data/base_project/.env,sha256=KfUwxOG5KFicU1E-FkP8EyQRvAx5tAqXbZwtZxBPf08,1619
|
|
55
|
+
squirrels/_package_data/base_project/.env.example,sha256=XPqYRUVCim1MnPU8iJe5y_sRpp9HObDrJk7NFd-SSao,1656
|
|
56
|
+
squirrels/_package_data/base_project/connections.yml,sha256=eBIbTQqyp5FlxDs0HyQ_NuE2Nx87EW53Qp1Y_c1ygv0,1093
|
|
57
|
+
squirrels/_package_data/base_project/duckdb_init.sql,sha256=PYUiQZajja-TG7EU1__PoiyDajgngEil4Lxenv5FWT0,284
|
|
58
|
+
squirrels/_package_data/base_project/gitignore,sha256=B9OEkQ_j9fZGA2IAyVUvXeylxpya-AUwzLzqzMN4Bfc,155
|
|
59
|
+
squirrels/_package_data/base_project/parameters.yml,sha256=--N_u3vA2tnT4uDxnkgxSs135i37N9N01gnYjD2jMRY,6741
|
|
60
|
+
squirrels/_package_data/base_project/squirrels.yml.j2,sha256=MRJ130wNarGRQKXqBip9-OHVFVrsvqB1OghcU_ObcV0,1862
|
|
61
|
+
squirrels/_package_data/base_project/assets/expenses.db,sha256=aO0QdApW9ad8LRc73MW1o3eimryzmOAH5vz9Vc3dWK0,77824
|
|
62
|
+
squirrels/_package_data/base_project/assets/weather.db,sha256=dsHPO36gQdZ4ULAA726Hg3jp8a1dCdig1DhrGg8wTeg,86016
|
|
63
|
+
squirrels/_package_data/base_project/dashboards/dashboard_example.py,sha256=c2B81GIlp7uGVplT5LFK9S2g06HRXjL6BfKu-XgeOfc,1621
|
|
64
|
+
squirrels/_package_data/base_project/dashboards/dashboard_example.yml,sha256=qeJRKZwhEcpjs52DsBnjzTWV5TsChI2XAkzL8Oz43zA,485
|
|
65
|
+
squirrels/_package_data/base_project/docker/.dockerignore,sha256=IN0ZmxwLdmYlw6I2ziTdzXkTbZWCUyV4kfUI9_lDz-A,201
|
|
66
|
+
squirrels/_package_data/base_project/docker/Dockerfile,sha256=DBOfPajd7ikNr1Qg08TcQmQmWDYamlxoDv7u6FSWElE,470
|
|
67
|
+
squirrels/_package_data/base_project/docker/compose.yml,sha256=xMAjfJeNVv49ypMGxR8bG27P5JSbPTNMR7UeGTHGyeA,105
|
|
68
|
+
squirrels/_package_data/base_project/macros/macros_example.sql,sha256=kJMAxL9ihCd-ULPOfHkqt8TDIMcH6QAOFFw89VplGL0,508
|
|
69
|
+
squirrels/_package_data/base_project/models/sources.yml,sha256=axBHFoJtWjAcklZyibrr7zhyDRATxi9r_bGjI09Kulk,1816
|
|
70
|
+
squirrels/_package_data/base_project/models/builds/build_example.py,sha256=QqNicirKK_JXn44QGrp48Ods5iGfAnoD_PZN5u-YLzQ,1022
|
|
71
|
+
squirrels/_package_data/base_project/models/builds/build_example.sql,sha256=52tqAIzFWJgX13CP4HNeBd5BFy7Z929Z0XxfLgGKthM,508
|
|
72
|
+
squirrels/_package_data/base_project/models/builds/build_example.yml,sha256=kUd6j5u8qU6UD294AowPBHFOb8yYDA_dxWlCIBrPl90,1407
|
|
73
|
+
squirrels/_package_data/base_project/models/dbviews/dbview_example.sql,sha256=DXBdikZayi7XJrE3a4_PFgFZwT1hBzpnOp89858IGPE,369
|
|
74
|
+
squirrels/_package_data/base_project/models/dbviews/dbview_example.yml,sha256=V2OWPN9TZ5yWB49SPcDMCzfz-zPhJ8RyQ08APF_P6xQ,1191
|
|
75
|
+
squirrels/_package_data/base_project/models/federates/federate_example.py,sha256=xwquVszyMEEDaxUKsNQs9aA0x8FhSPnl7lvut9fQyeE,1969
|
|
76
|
+
squirrels/_package_data/base_project/models/federates/federate_example.sql,sha256=9eTJfTSWAMV8lGtQ0Bg4A_Wpv0w1LRIf5fMx6OIZ7Uk,674
|
|
77
|
+
squirrels/_package_data/base_project/models/federates/federate_example.yml,sha256=kxdgua47AWjvXPyLbpj4qS8Fmwj4A8RurKnzX-geHNU,2310
|
|
78
|
+
squirrels/_package_data/base_project/pyconfigs/connections.py,sha256=XQ8PEVEF05jpWCMEowO_oWAW0QMeGKanwnJmKIZ7tDw,633
|
|
79
|
+
squirrels/_package_data/base_project/pyconfigs/context.py,sha256=QinFkAryLqrbtSDzA360pgRA-U9koRgeRizJwo6Tv94,4305
|
|
80
|
+
squirrels/_package_data/base_project/pyconfigs/parameters.py,sha256=-UlrCcuW2NqlNlEnYttQ-S09Lq5IpNkAVP5FNR2e33g,4794
|
|
81
|
+
squirrels/_package_data/base_project/pyconfigs/user.py,sha256=wstsSgx1FYIMHtovESxvya1FJnDnSTIM0hYM7JcVSHk,1770
|
|
82
|
+
squirrels/_package_data/base_project/seeds/seed_categories.csv,sha256=jppjf1nOIxy7-bi5lJn5CVqmnLfJHHq0ABgp6UqbXnw,104
|
|
83
|
+
squirrels/_package_data/base_project/seeds/seed_categories.yml,sha256=UM2gIrwHU2qogKdQqeqP6s4QfE7fEzUsPr7HjqlX7ow,425
|
|
84
|
+
squirrels/_package_data/base_project/seeds/seed_subcategories.csv,sha256=Tta1oIgnc2nukNMDlUkIErRKNH_8YT5EPp1A2kQKcow,327
|
|
85
|
+
squirrels/_package_data/base_project/seeds/seed_subcategories.yml,sha256=fqXzZfVIQIlrVjW83K3epnVYFvF0X2Kiqe3KpvHgI5c,573
|
|
86
|
+
squirrels/_package_data/base_project/tmp/.gitignore,sha256=XImoqcWvJY0C0L_TWCx1ljvqU7qh9fUTJmK4ACCmNFI,13
|
|
87
|
+
squirrels/_package_data/templates/dataset_results.html,sha256=Y-1xtw4ZzHcoW1vfWR1amnFJqFUMvwJDY3eeY7bfKJw,2793
|
|
88
|
+
squirrels/_package_data/templates/oauth_login.html,sha256=LmR7zbjFUYxWIhB9nhIkoGDmqUgEtSXCqo0pKrWqwXw,7108
|
|
89
|
+
squirrels/_package_data/templates/squirrels_studio.html,sha256=M0X3DP5dLRNvO6aJYSasbjWa4NbpsicrxAWV8Ephkyw,785
|
|
90
|
+
squirrels/_schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
91
|
+
squirrels/_schemas/auth_models.py,sha256=PEDr3jPmaQo7tigjhjyQZ6BYWafbzMUX-jZdo3jRtMU,6392
|
|
92
|
+
squirrels/_schemas/query_param_models.py,sha256=y9ZYa2QLS_1tKN7ODSR0DBOWU-M6cz4niAq5qAAklok,4488
|
|
93
|
+
squirrels/_schemas/response_models.py,sha256=3OVelx3DZmmze7RKmCFzukvHt1nIiLWfmzxSoCNpY50,15218
|
|
94
|
+
squirrels-0.5.1.dist-info/METADATA,sha256=yLjuyu8i3LaaiaYYotMvNw4-CPxBbledjrdkDx4Czp8,4838
|
|
95
|
+
squirrels-0.5.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
96
|
+
squirrels-0.5.1.dist-info/entry_points.txt,sha256=i6vgjhJ3o_cdSFYofFcNY9DFMPr4MIcuwnkskSTXfJc,95
|
|
97
|
+
squirrels-0.5.1.dist-info/licenses/LICENSE,sha256=qqERuumQtQVsMrEXvJHuecJvV2sLxbleEubd_Zk8dY8,11338
|
|
98
|
+
squirrels-0.5.1.dist-info/RECORD,,
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
label: Dashboard Example
|
|
2
|
-
|
|
3
|
-
description: This is an example dashboard
|
|
4
|
-
|
|
5
|
-
scope: protected
|
|
6
|
-
|
|
7
|
-
format: png
|
|
8
|
-
|
|
9
|
-
parameters:
|
|
10
|
-
- date_range
|
|
11
|
-
- category
|
|
12
|
-
|
|
13
|
-
depends_on:
|
|
14
|
-
- name: dataset_example_month
|
|
15
|
-
dataset: federate_dataset_example
|
|
16
|
-
fixed_parameters:
|
|
17
|
-
- group_by: g4 (Month)
|
|
18
|
-
|
|
19
|
-
- name: dataset_example_subcategory
|
|
20
|
-
dataset: federate_dataset_example
|
|
21
|
-
fixed_parameters:
|
|
22
|
-
- group_by: g3 (Subcategory)
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{%- macro date_and_amount_filters(use_from_range) -%}
|
|
2
|
-
|
|
3
|
-
{%- if use_from_range -%}
|
|
4
|
-
date >= {{ ctx.start_date_from_range }}
|
|
5
|
-
AND date <= {{ ctx.end_date_from_range }}
|
|
6
|
-
AND amount >= {{ ctx.min_amount_from_range }}
|
|
7
|
-
AND amount <= {{ ctx.max_amount_from_range }}
|
|
8
|
-
{%- else -%}
|
|
9
|
-
date >= {{ ctx.start_date }}
|
|
10
|
-
AND date <= {{ ctx.end_date }}
|
|
11
|
-
AND amount >= {{ ctx.min_amount }}
|
|
12
|
-
AND amount <= {{ ctx.max_amount }}
|
|
13
|
-
{%- endif -%}
|
|
14
|
-
|
|
15
|
-
{%- endmacro -%}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{# SQLite dialect (based on connection used) #}
|
|
2
|
-
|
|
3
|
-
SELECT STRFTIME('%Y-%m', date) AS month
|
|
4
|
-
, printf('%.2f', SUM(amount)) as total_amount
|
|
5
|
-
|
|
6
|
-
FROM {{ source("src_transactions") }}
|
|
7
|
-
|
|
8
|
-
WHERE {{ date_and_amount_filters(use_from_range=false) }}
|
|
9
|
-
|
|
10
|
-
GROUP BY 1
|
|
11
|
-
|
|
12
|
-
ORDER BY 1 DESC
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
description: |
|
|
2
|
-
This is an example of a database view model. It finds the total amount spent by month.
|
|
3
|
-
|
|
4
|
-
Parameters are available to filter the date and amount of the transactions.
|
|
5
|
-
|
|
6
|
-
connection: default # optional - if not provided, will use default connection specified in the SQRL_CONNECTIONS__DEFAULT_NAME_USED setting
|
|
7
|
-
|
|
8
|
-
translate_to_duckdb: true # optional - default is false - if true, then the model will be translated to duckdb for supported dialects
|
|
9
|
-
|
|
10
|
-
depends_on: # optional - the "source" macro also adds to this set
|
|
11
|
-
- src_transactions
|
|
12
|
-
|
|
13
|
-
columns:
|
|
14
|
-
- name: month
|
|
15
|
-
type: string
|
|
16
|
-
description: The months for which the amount is aggregated by, in descending order
|
|
17
|
-
category: dimension
|
|
18
|
-
depends_on:
|
|
19
|
-
- src_transactions.date
|
|
20
|
-
|
|
21
|
-
- name: total_amount
|
|
22
|
-
type: float
|
|
23
|
-
description: The total amount spent by the group-by dimension
|
|
24
|
-
category: measure
|
|
25
|
-
depends_on:
|
|
26
|
-
- src_transactions.amount
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
from squirrels import ModelArgs, parameters as p
|
|
2
|
-
import polars as pl, pandas as pd
|
|
3
|
-
|
|
4
|
-
def dequote(value: str) -> str:
|
|
5
|
-
return value[1:-1]
|
|
6
|
-
|
|
7
|
-
def joined_str_to_list(value: str) -> list[str]:
|
|
8
|
-
return [dequote(category) for category in str(value).split(",")]
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def main(sqrl: ModelArgs) -> pl.LazyFrame | pl.DataFrame | pd.DataFrame:
|
|
12
|
-
"""
|
|
13
|
-
Create federated models by joining/processing dependent models (sources, seeds, builds, dbviews, other federates, etc.) to
|
|
14
|
-
form a new Python DataFrame (using polars LazyFrame, polars DataFrame, or pandas DataFrame).
|
|
15
|
-
"""
|
|
16
|
-
df = sqrl.ref("build_example")
|
|
17
|
-
|
|
18
|
-
df = df.filter(
|
|
19
|
-
(pl.col("amount") >= sqrl.ctx["min_amount_from_range"]) &
|
|
20
|
-
(pl.col("amount") <= sqrl.ctx["max_amount_from_range"]) &
|
|
21
|
-
(pl.col("date") >= dequote(sqrl.ctx["start_date_from_range"])) &
|
|
22
|
-
(pl.col("date") <= dequote(sqrl.ctx["end_date_from_range"]))
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
if sqrl.ctx["has_categories"]:
|
|
26
|
-
categories_list = joined_str_to_list(sqrl.ctx["categories"])
|
|
27
|
-
df = df.filter(pl.col("category_id").is_in(categories_list))
|
|
28
|
-
|
|
29
|
-
if sqrl.ctx["has_subcategories"]:
|
|
30
|
-
subcategories_list = joined_str_to_list(sqrl.ctx["subcategories"])
|
|
31
|
-
df = df.filter(pl.col("subcategory_id").is_in(subcategories_list))
|
|
32
|
-
|
|
33
|
-
dimension_cols = sqrl.ctx["group_by_cols_list"]
|
|
34
|
-
df = df.group_by(dimension_cols).agg(
|
|
35
|
-
pl.sum("amount").cast(pl.Decimal(precision=15, scale=2)).alias("total_amount")
|
|
36
|
-
)
|
|
37
|
-
df = df.sort(dimension_cols, descending=True)
|
|
38
|
-
|
|
39
|
-
if sqrl.param_exists("limit"):
|
|
40
|
-
assert isinstance(limit := sqrl.prms["limit"], p.NumberParameter)
|
|
41
|
-
df = df.limit(int(limit.get_selected_value()))
|
|
42
|
-
|
|
43
|
-
df = df.select(*dimension_cols, "total_amount")
|
|
44
|
-
return df.rename(sqrl.ctx["rename_dict"])
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{# DuckDB dialect #}
|
|
2
|
-
|
|
3
|
-
SELECT {{ ctx.select_dim_cols }}
|
|
4
|
-
, CAST(SUM(amount) AS DECIMAL(15, 2)) as total_amount
|
|
5
|
-
|
|
6
|
-
{# ref() can be used on a sources, seeds, builds, dbviews, or other federate models -#}
|
|
7
|
-
FROM {{ ref("build_example") }} AS a
|
|
8
|
-
|
|
9
|
-
WHERE {{ date_and_amount_filters(use_from_range=true) }}
|
|
10
|
-
{% if ctx.has_categories -%} AND category_id IN ({{ ctx.categories }}) {%- endif %}
|
|
11
|
-
{% if ctx.has_subcategories -%} AND subcategory_id IN ({{ ctx.subcategories }}) {%- endif %}
|
|
12
|
-
|
|
13
|
-
GROUP BY {{ ctx.group_by_cols }}
|
|
14
|
-
|
|
15
|
-
ORDER BY {{ ctx.order_by_cols }}
|
|
16
|
-
|
|
17
|
-
{{ ctx.limit_clause }}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
from typing import Any
|
|
2
|
-
from squirrels import ConnectionsArgs, ConnectionProperties, ConnectionType
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def main(connections: dict[str, ConnectionProperties | Any], sqrl: ConnectionsArgs) -> None:
|
|
6
|
-
"""
|
|
7
|
-
Define sqlalchemy engines by adding them to the "connections" dictionary
|
|
8
|
-
"""
|
|
9
|
-
## SQLAlchemy URL for a connection engine
|
|
10
|
-
conn_str: str = sqrl.env_vars["SQLITE_URI"].format(project_path=sqrl.project_path)
|
|
11
|
-
|
|
12
|
-
## Assigning names to connection engines
|
|
13
|
-
connections["default"] = ConnectionProperties(label="SQLite Expenses Database", type=ConnectionType.SQLALCHEMY, uri=conn_str)
|
|
14
|
-
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
from squirrels import ParametersArgs, parameters as p, parameter_options as po, data_sources as ds
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def main(sqrl: ParametersArgs) -> None:
|
|
5
|
-
"""
|
|
6
|
-
Create all widget parameters in this file. If two or more datasets use a different set of parameters, define them all
|
|
7
|
-
here, and specify the subset of parameters used for each dataset in the "squirrels.yml" file.
|
|
8
|
-
|
|
9
|
-
Parameters are created by a factory method associated to the parameter class. For example, "CreateWithOptions" is the factory method used here:
|
|
10
|
-
> p.SingleSelectParameter.CreateWithOptions(...)
|
|
11
|
-
|
|
12
|
-
The parameter classes available are:
|
|
13
|
-
- SingleSelectParameter, MultiSelectParameter, DateParameter, DateRangeParameter, NumberParameter, NumberRangeParameter, TextParameter
|
|
14
|
-
|
|
15
|
-
The factory methods available are:
|
|
16
|
-
- CreateSimple, CreateWithOptions, CreateFromSource
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
## Example of creating SingleSelectParameter and specifying each option by code
|
|
20
|
-
user_attribute = "role"
|
|
21
|
-
group_by_options = [
|
|
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"]),
|
|
27
|
-
]
|
|
28
|
-
p.SingleSelectParameter.CreateWithOptions(
|
|
29
|
-
"group_by", "Group By", group_by_options, description="Dimension(s) to aggregate by", user_attribute=user_attribute
|
|
30
|
-
)
|
|
31
|
-
|
|
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"
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
## Example of creating DateParameter
|
|
40
|
-
start_date_source = ds.DateDataSource(
|
|
41
|
-
"SELECT min(date) AS min_date, max(date) AS max_date FROM expenses",
|
|
42
|
-
default_date_col="min_date", min_date_col="min_date", max_date_col="max_date"
|
|
43
|
-
)
|
|
44
|
-
p.DateParameter.CreateFromSource(
|
|
45
|
-
"start_date", "Start Date", start_date_source, description="Start date to filter transactions by"
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
## Example of creating DateParameter from list of DateParameterOption's
|
|
49
|
-
end_date_option = [po.DateParameterOption("2024-12-31", min_date="2024-01-01", max_date="2024-12-31")]
|
|
50
|
-
p.DateParameter.CreateWithOptions(
|
|
51
|
-
"end_date", "End Date", end_date_option, description="End date to filter transactions by"
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
## Example of creating DateRangeParameter
|
|
55
|
-
p.DateRangeParameter.CreateSimple(
|
|
56
|
-
"date_range", "Date Range", "2024-01-01", "2024-12-31", min_date="2024-01-01", max_date="2024-12-31",
|
|
57
|
-
description="Date range to filter transactions by"
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
## Example of creating MultiSelectParameter from lookup query/table
|
|
61
|
-
category_ds = ds.SelectDataSource("seed_categories", "category_id", "category", from_seeds=True)
|
|
62
|
-
p.MultiSelectParameter.CreateFromSource(
|
|
63
|
-
"category", "Category Filter", category_ds, description="The expense categories to filter transactions by"
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
## Example of creating MultiSelectParameter with parent from lookup query/table
|
|
67
|
-
parent_name = "category"
|
|
68
|
-
subcategory_ds = ds.SelectDataSource(
|
|
69
|
-
"seed_subcategories", "subcategory_id", "subcategory", from_seeds=True, parent_id_col="category_id"
|
|
70
|
-
)
|
|
71
|
-
p.MultiSelectParameter.CreateFromSource(
|
|
72
|
-
"subcategory", "Subcategory Filter", subcategory_ds, parent_name=parent_name,
|
|
73
|
-
description="The expense subcategories to filter transactions by (available options are based on selected value(s) of 'Category Filter')"
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
## Example of creating NumberParameter
|
|
77
|
-
p.NumberParameter.CreateSimple(
|
|
78
|
-
"min_filter", "Amounts Greater Than", min_value=0, max_value=300, increment=10,
|
|
79
|
-
description="Number to filter on transactions with an amount greater than this value"
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
## Example of creating NumberParameter from lookup query/table
|
|
83
|
-
query = "SELECT 0 as min_value, 300 as max_value, 10 as increment"
|
|
84
|
-
max_amount_ds = ds.NumberDataSource(query, "min_value", "max_value", increment_col="increment", default_value_col="max_value")
|
|
85
|
-
p.NumberParameter.CreateFromSource(
|
|
86
|
-
"max_filter", "Amounts Less Than", max_amount_ds, description="Number to filter on transactions with an amount less than this value"
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
## Example of creating NumberRangeParameter
|
|
90
|
-
p.NumberRangeParameter.CreateSimple(
|
|
91
|
-
"between_filter", "Amounts Between", 0, 300, default_lower_value=0, default_upper_value=300,
|
|
92
|
-
description="Number range to filter on transactions with an amount within this range"
|
|
93
|
-
)
|
|
@@ -1,23 +0,0 @@
|
|
|
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 []
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
project_variables:
|
|
2
|
-
name: sample
|
|
3
|
-
label: Sample Project - Expenses
|
|
4
|
-
description: This is a sample squirrels project for analyzing expense transactions
|
|
5
|
-
major_version: 1
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
packages: []
|
|
9
|
-
|
|
10
|
-
## Example for packages section:
|
|
11
|
-
# packages:
|
|
12
|
-
# - git: https://.../myrepo.git
|
|
13
|
-
# revision: v0.1.0
|
|
14
|
-
# directory: custom_name ## optional
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{{ connections -}}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{{ parameters -}}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
datasets:
|
|
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
|
|
28
|
-
scope: public ## optional - one of 'public' (default), 'protected', or 'private'
|
|
29
|
-
parameters: ## optional - if not specified, then all parameters are used
|
|
30
|
-
- start_date
|
|
31
|
-
- end_date
|
|
32
|
-
- min_filter
|
|
33
|
-
- max_filter
|
|
34
|
-
traits: {} ## optional - defaults to empty object
|
|
35
|
-
|
|
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
|
|
41
|
-
parameters:
|
|
42
|
-
- group_by
|
|
43
|
-
- limit
|
|
44
|
-
- date_range
|
|
45
|
-
- category
|
|
46
|
-
- subcategory
|
|
47
|
-
- between_filter
|
|
48
|
-
default_test_set: auth_test1 ## optional - if not specified, uses setting 'selection_test_sets.default_name_used'
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
selection_test_sets:
|
|
52
|
-
- name: no_auth_test1
|
|
53
|
-
datasets: ## optional section - if not provided, then test set is applicable for any dataset
|
|
54
|
-
- dbview_dataset_example
|
|
55
|
-
parameters: ## optional section - if not provided, then assumes no parameters. For unspecified parameters, default value is used
|
|
56
|
-
start_date: 2024-07-01 ## this parameter only exists for dataset 'dataset_example'
|
|
57
|
-
|
|
58
|
-
- name: auth_test1
|
|
59
|
-
datasets:
|
|
60
|
-
- federate_dataset_example
|
|
61
|
-
user_attributes: ## optional section - required if using test set on non-public datasets
|
|
62
|
-
role: employee
|
|
63
|
-
parameters:
|
|
64
|
-
date_range: [2024-02-01,2024-12-01] ## this parameter only exists for dataset 'protected_dataset_example'
|
|
65
|
-
|
|
66
|
-
- name: auth_test2
|
|
67
|
-
user_attributes:
|
|
68
|
-
is_internal: True ## optional - defaults to False
|
|
69
|
-
role: manager
|
|
70
|
-
parameters:
|
|
71
|
-
group_by: g3 ## this parameter exists for all datasets. "g3" is the id for option "subcategory"
|