squirrels 0.4.0__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.0.dist-info → squirrels-0.5.0rc0.dist-info}/METADATA +31 -32
- squirrels-0.5.0rc0.dist-info/RECORD +70 -0
- {squirrels-0.4.0.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.0.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.0.dist-info/RECORD +0 -60
- squirrels-0.4.0.dist-info/entry_points.txt +0 -4
squirrels/__init__.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from ._version import __version__
|
|
2
2
|
|
|
3
|
-
from .arguments.init_time_args import ConnectionsArgs, ParametersArgs
|
|
4
|
-
from .arguments.run_time_args import
|
|
3
|
+
from .arguments.init_time_args import ConnectionsArgs, ParametersArgs, BuildModelArgs
|
|
4
|
+
from .arguments.run_time_args import AuthLoginArgs, AuthTokenArgs, ContextArgs, ModelArgs, DashboardArgs
|
|
5
5
|
|
|
6
6
|
from .parameter_options import SelectParameterOption, DateParameterOption, DateRangeParameterOption
|
|
7
7
|
from .parameter_options import NumberParameterOption, NumberRangeParameterOption, TextParameterOption
|
|
@@ -9,11 +9,15 @@ from .parameter_options import NumberParameterOption, NumberRangeParameterOption
|
|
|
9
9
|
from .parameters import SingleSelectParameter, MultiSelectParameter, DateParameter, DateRangeParameter
|
|
10
10
|
from .parameters import NumberParameter, NumberRangeParameter, TextParameter, TextValue
|
|
11
11
|
|
|
12
|
-
from .data_sources import
|
|
12
|
+
from .data_sources import SelectDataSource, DateDataSource, DateRangeDataSource
|
|
13
13
|
from .data_sources import NumberDataSource, NumberRangeDataSource, TextDataSource
|
|
14
14
|
|
|
15
|
-
from .user_base import User, WrongPassword
|
|
16
|
-
|
|
17
15
|
from .dashboards import PngDashboard, HtmlDashboard
|
|
18
16
|
|
|
19
|
-
from .
|
|
17
|
+
from ._auth import BaseUser
|
|
18
|
+
|
|
19
|
+
from ._manifest import ConnectionProperties, ConnectionType
|
|
20
|
+
|
|
21
|
+
from ._project import SquirrelsProject
|
|
22
|
+
|
|
23
|
+
from .dataset_result import DatasetResult
|
|
@@ -1,43 +1,18 @@
|
|
|
1
|
-
from typing import Annotated
|
|
1
|
+
from typing import Annotated, Literal
|
|
2
2
|
from pydantic import BaseModel, Field
|
|
3
3
|
from datetime import datetime, date
|
|
4
4
|
|
|
5
|
+
from . import _model_configs as mc, _sources as s
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
class LoginReponse(BaseModel):
|
|
7
9
|
access_token: Annotated[str, Field(examples=["encoded_jwt_token"], description="An encoded JSON web token to use subsequent API requests")]
|
|
8
10
|
token_type: Annotated[str, Field(examples=["bearer"], description='Always "bearer" for Bearer token')]
|
|
9
11
|
username: Annotated[str, Field(examples=["johndoe"], description='The username authenticated with from the form data')]
|
|
12
|
+
is_admin: Annotated[bool, Field(examples=[False], description="A boolean for whether the user is an admin")]
|
|
10
13
|
expiry_time: Annotated[datetime, Field(examples=["2023-08-01T12:00:00.000000Z"], description="The expiry time of the access token in yyyy-MM-dd'T'hh:mm:ss.SSSSSS'Z' format")]
|
|
11
14
|
|
|
12
15
|
|
|
13
|
-
## Datasets / Dashboards Catalog Response Models
|
|
14
|
-
|
|
15
|
-
name_description = "The name of the dataset / dashboard (usually in snake case)"
|
|
16
|
-
label_description = "The human-friendly display name for the dataset / dashboard"
|
|
17
|
-
description_description = "The description of the dataset / dashboard"
|
|
18
|
-
parameters_path_description = "The API path to the parameters for the dataset / dashboard"
|
|
19
|
-
result_path_description = "The API path to the results for the dataset / dashboard"
|
|
20
|
-
|
|
21
|
-
class DatasetItemModel(BaseModel):
|
|
22
|
-
name: Annotated[str, Field(examples=["mydataset"], description=name_description)]
|
|
23
|
-
label: Annotated[str, Field(examples=["My Dataset"], description=label_description)]
|
|
24
|
-
description: Annotated[str, Field(examples=[""], description=description_description)]
|
|
25
|
-
parameters_path: Annotated[str, Field(examples=["/squirrels-v0/myproject/v1/dataset/mydataset/parameters"], description=parameters_path_description)]
|
|
26
|
-
result_path: Annotated[str, Field(examples=["/squirrels-v0/myproject/v1/dataset/mydataset"], description=result_path_description)]
|
|
27
|
-
|
|
28
|
-
class DashboardItemModel(BaseModel):
|
|
29
|
-
name: Annotated[str, Field(examples=["mydashboard"], description=name_description)]
|
|
30
|
-
label: Annotated[str, Field(examples=["My Dashboard"], description=label_description)]
|
|
31
|
-
description: Annotated[str, Field(examples=[""], description=description_description)]
|
|
32
|
-
parameters_path: Annotated[str, Field(examples=["/squirrels-v0/myproject/v1/dashboard/mydashboard/parameters"], description=parameters_path_description)]
|
|
33
|
-
result_path: Annotated[str, Field(examples=["/squirrels-v0/myproject/v1/dashboard/mydashboard"], description=result_path_description)]
|
|
34
|
-
result_format: Annotated[str, Field(examples=["png", "html"], description="The format of the dashboard's result API response (one of 'png' or 'html')")]
|
|
35
|
-
|
|
36
|
-
class CatalogModel(BaseModel):
|
|
37
|
-
datasets: Annotated[list[DatasetItemModel], Field(description="The list of accessible datasets")]
|
|
38
|
-
dashboards: Annotated[list[DashboardItemModel], Field(description="The list of accessible dashboards")]
|
|
39
|
-
|
|
40
|
-
|
|
41
16
|
## Parameters Response Models
|
|
42
17
|
|
|
43
18
|
class ParameterOptionModel(BaseModel):
|
|
@@ -45,7 +20,7 @@ class ParameterOptionModel(BaseModel):
|
|
|
45
20
|
label: Annotated[str, Field(examples=["My Option"], description="The human-friendly display name for the option")]
|
|
46
21
|
|
|
47
22
|
class ParameterModelBase(BaseModel):
|
|
48
|
-
widget_type: Annotated[str, Field(examples=["
|
|
23
|
+
widget_type: Annotated[str, Field(examples=["disabled"], description="The parameter type")]
|
|
49
24
|
name: Annotated[str, Field(examples=["my_unique_param_name"], description="The name of the parameter. Use this as the key when providing the API request parameters")]
|
|
50
25
|
label: Annotated[str, Field(examples=["My Parameter"], description="The human-friendly display name for the parameter")]
|
|
51
26
|
description: Annotated[str, Field(examples=[""], description="The description of the parameter")]
|
|
@@ -102,27 +77,101 @@ class TextParameterModel(ParameterModelBase):
|
|
|
102
77
|
description='A string for the input type (one of "text", "textarea", "number", "date", "datetime-local", "month", "time", "color", or "password")'
|
|
103
78
|
)]
|
|
104
79
|
|
|
80
|
+
ParametersListType = list[
|
|
81
|
+
NoneParameterModel | SingleSelectParameterModel | MultiSelectParameterModel | DateParameterModel | DateRangeParameterModel |
|
|
82
|
+
NumberParameterModel | NumberRangeParameterModel | TextParameterModel
|
|
83
|
+
]
|
|
84
|
+
|
|
105
85
|
class ParametersModel(BaseModel):
|
|
106
|
-
parameters: list
|
|
107
|
-
NoneParameterModel | SingleSelectParameterModel | MultiSelectParameterModel | DateParameterModel | DateRangeParameterModel |
|
|
108
|
-
NumberParameterModel | NumberRangeParameterModel | TextParameterModel
|
|
109
|
-
]
|
|
86
|
+
parameters: Annotated[ParametersListType, Field(description="The list of parameters for the dataset / dashboard")]
|
|
110
87
|
|
|
111
88
|
|
|
112
|
-
##
|
|
89
|
+
## Datasets / Dashboards Catalog Response Models
|
|
90
|
+
|
|
91
|
+
name_description = "The name of the dataset / dashboard (usually in snake case)"
|
|
92
|
+
label_description = "The human-friendly display name for the dataset / dashboard"
|
|
93
|
+
description_description = "The description of the dataset / dashboard"
|
|
94
|
+
parameters_path_description = "The API path to the parameters for the dataset / dashboard"
|
|
95
|
+
metadata_path_description = "The API path to the metadata (i.e., description and schema) for the dataset"
|
|
96
|
+
result_path_description = "The API path to the results for the dataset / dashboard"
|
|
113
97
|
|
|
114
98
|
class ColumnModel(BaseModel):
|
|
115
99
|
name: Annotated[str, Field(examples=["mycol"], description="Name of column")]
|
|
116
|
-
type: Annotated[str, Field(examples=["string", "
|
|
100
|
+
type: Annotated[str, Field(examples=["string", "integer", "boolean", "datetime"], description='Column type (such as "string", "integer", "boolean", "datetime", etc.)')]
|
|
101
|
+
description: Annotated[str, Field(examples=["My column description"], description="The description of the column")]
|
|
102
|
+
category: Annotated[str, Field(examples=["dimension", "measure", "misc"], description="The category of the column (such as 'dimension', 'measure', or 'misc')")]
|
|
103
|
+
|
|
104
|
+
class ColumnWithConditionModel(ColumnModel):
|
|
105
|
+
condition: Annotated[str | None, Field(None, examples=["My condition"], description="The condition of when the column is included (such as based on a parameter selection)")]
|
|
117
106
|
|
|
118
107
|
class SchemaModel(BaseModel):
|
|
119
108
|
fields: Annotated[list[ColumnModel], Field(description="A list of JSON objects containing the 'name' and 'type' for each of the columns in the result")]
|
|
120
|
-
|
|
109
|
+
|
|
110
|
+
class SchemaWithConditionModel(BaseModel):
|
|
111
|
+
fields: Annotated[list[ColumnWithConditionModel], Field(description="A list of JSON objects containing the 'name' and 'type' for each of the columns in the result")]
|
|
112
|
+
|
|
113
|
+
class DatasetItemModel(BaseModel):
|
|
114
|
+
name: Annotated[str, Field(examples=["mydataset"], description=name_description)]
|
|
115
|
+
label: Annotated[str, Field(examples=["My Dataset"], description=label_description)]
|
|
116
|
+
description: Annotated[str, Field(examples=[""], description=description_description)]
|
|
117
|
+
parameters: Annotated[list[str], Field(examples=["myparam1", "myparam2"], description="The list of parameter names used by the dataset")]
|
|
118
|
+
data_schema: Annotated[SchemaWithConditionModel, Field(alias="schema", description="JSON object describing the schema of the dataset")]
|
|
119
|
+
parameters_path: Annotated[str, Field(examples=["/squirrels-v0/myproject/v1/dataset/mydataset/parameters"], description=parameters_path_description)]
|
|
120
|
+
result_path: Annotated[str, Field(examples=["/squirrels-v0/myproject/v1/dataset/mydataset"], description=result_path_description)]
|
|
121
|
+
|
|
122
|
+
class DashboardItemModel(ParametersModel):
|
|
123
|
+
name: Annotated[str, Field(examples=["mydashboard"], description=name_description)]
|
|
124
|
+
label: Annotated[str, Field(examples=["My Dashboard"], description=label_description)]
|
|
125
|
+
description: Annotated[str, Field(examples=[""], description=description_description)]
|
|
126
|
+
parameters: Annotated[list[str], Field(examples=["myparam1", "myparam2"], description="The list of parameter names used by the dashboard")]
|
|
127
|
+
parameters_path: Annotated[str, Field(examples=["/squirrels-v0/myproject/v1/dashboard/mydashboard/parameters"], description=parameters_path_description)]
|
|
128
|
+
result_path: Annotated[str, Field(examples=["/squirrels-v0/myproject/v1/dashboard/mydashboard"], description=result_path_description)]
|
|
129
|
+
result_format: Annotated[str, Field(examples=["png", "html"], description="The format of the dashboard's result API response (one of 'png' or 'html')")]
|
|
130
|
+
|
|
131
|
+
ModelConfigType = mc.ModelConfig | s.Source | mc.SeedConfig | mc.BuildModelConfig | mc.DbviewModelConfig | mc.FederateModelConfig
|
|
132
|
+
|
|
133
|
+
class ConnectionItemModel(BaseModel):
|
|
134
|
+
name: Annotated[str, Field(examples=["myconnection"], description="The name of the connection")]
|
|
135
|
+
label: Annotated[str, Field(examples=["My Connection"], description="The human-friendly display name for the connection")]
|
|
136
|
+
|
|
137
|
+
class DataModelItem(BaseModel):
|
|
138
|
+
name: Annotated[str, Field(examples=["model_name"], description="The name of the model")]
|
|
139
|
+
model_type: Annotated[Literal["source", "dbview", "federate", "seed", "build"], Field(
|
|
140
|
+
examples=["source", "dbview", "federate", "seed", "build"], description="The type of the model"
|
|
141
|
+
)]
|
|
142
|
+
config: Annotated[ModelConfigType, Field(description="The configuration of the model")]
|
|
143
|
+
is_queryable: Annotated[bool, Field(examples=[True], description="Whether the model is queryable")]
|
|
144
|
+
|
|
145
|
+
class LineageNode(BaseModel):
|
|
146
|
+
name: str
|
|
147
|
+
type: Literal["model", "dataset", "dashboard"]
|
|
148
|
+
|
|
149
|
+
class LineageRelation(BaseModel):
|
|
150
|
+
type: Literal["buildtime", "runtime"]
|
|
151
|
+
source: LineageNode
|
|
152
|
+
target: LineageNode
|
|
153
|
+
|
|
154
|
+
class CatalogModel(BaseModel):
|
|
155
|
+
parameters: Annotated[ParametersListType, Field(description="The list of all parameters in the project")]
|
|
156
|
+
datasets: Annotated[list[DatasetItemModel], Field(description="The list of accessible datasets")]
|
|
157
|
+
dashboards: Annotated[list[DashboardItemModel], Field(description="The list of accessible dashboards")]
|
|
158
|
+
connections: Annotated[list[ConnectionItemModel], Field(description="The list of connections in the project (only provided for admin users)")]
|
|
159
|
+
models: Annotated[list[DataModelItem], Field(description="The list of data models in the project (only provided for admin users)")]
|
|
160
|
+
lineage: Annotated[list[LineageRelation], Field(description="The lineage information between data assets (only provided for admin users)")]
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
## Dataset Results Response Models
|
|
164
|
+
|
|
165
|
+
class DataDetailsModel(BaseModel):
|
|
166
|
+
num_rows: Annotated[int, Field(examples=[2], description="The number of rows in the data field")]
|
|
167
|
+
orientation: Annotated[Literal["records", "rows", "columns"], Field(examples=["records", "rows", "columns"], description="The orientation of the data field")]
|
|
121
168
|
|
|
122
169
|
class DatasetResultModel(BaseModel):
|
|
123
170
|
data_schema: Annotated[SchemaModel, Field(alias="schema", description="JSON object describing the schema of the dataset")]
|
|
124
|
-
|
|
125
|
-
|
|
171
|
+
total_num_rows: Annotated[int, Field(examples=[2], description="The total number of rows for the dataset")]
|
|
172
|
+
data_details: Annotated[DataDetailsModel, Field(description="A JSON object containing the details of the data field")]
|
|
173
|
+
data: Annotated[list[dict] | list[list] | dict[str, list], Field(
|
|
174
|
+
examples=[[{"mycol": "col_value1"}, {"mycol": "col_value2"}], [["col_value1"], ["col_value2"]], {"mycol": ["col_value1", "col_value2"]}],
|
|
126
175
|
description="A list of JSON objects where each object is a row of the tabular results. The keys and values of the object are column names (described in fields) and values of the row."
|
|
127
176
|
)]
|
|
128
177
|
|
|
@@ -130,12 +179,12 @@ class DatasetResultModel(BaseModel):
|
|
|
130
179
|
## Project Metadata Response Models
|
|
131
180
|
|
|
132
181
|
class ProjectVersionModel(BaseModel):
|
|
133
|
-
major_version: int
|
|
134
|
-
|
|
135
|
-
token_path: Annotated[str, Field(examples=["/squirrels-v0/myproject/v1/token"])]
|
|
136
|
-
data_catalog_path: Annotated[str, Field(examples=["/squirrels-v0/myproject/v1/datasets"])]
|
|
182
|
+
major_version: Annotated[int, Field(examples=[1])]
|
|
183
|
+
data_catalog_path: Annotated[str, Field(examples=["/squirrels-v0/project/myproject/v1/data-catalog"])]
|
|
137
184
|
|
|
138
185
|
class ProjectModel(BaseModel):
|
|
139
186
|
name: Annotated[str, Field(examples=["myproject"])]
|
|
187
|
+
version: Annotated[str, Field(examples=["v1"])]
|
|
140
188
|
label: Annotated[str, Field(examples=["My Project"])]
|
|
141
|
-
|
|
189
|
+
description: Annotated[str, Field(examples=["My project description"])]
|
|
190
|
+
squirrels_version: Annotated[str, Field(examples=["0.1.0"])]
|