squirrels 0.4.1__py3-none-any.whl → 0.5.0__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 +13 -11
- squirrels/_api_routes/__init__.py +5 -0
- squirrels/_api_routes/auth.py +271 -0
- squirrels/_api_routes/base.py +165 -0
- squirrels/_api_routes/dashboards.py +150 -0
- squirrels/_api_routes/data_management.py +145 -0
- squirrels/_api_routes/datasets.py +257 -0
- squirrels/_api_routes/oauth2.py +298 -0
- squirrels/_api_routes/project.py +252 -0
- squirrels/_api_server.py +256 -450
- squirrels/_arguments/__init__.py +0 -0
- squirrels/_arguments/init_time_args.py +108 -0
- squirrels/_arguments/run_time_args.py +147 -0
- squirrels/_auth.py +960 -0
- squirrels/_command_line.py +126 -45
- squirrels/_compile_prompts.py +147 -0
- squirrels/_connection_set.py +48 -26
- squirrels/_constants.py +68 -38
- squirrels/_dashboards.py +160 -0
- squirrels/_data_sources.py +570 -0
- squirrels/_dataset_types.py +84 -0
- squirrels/_exceptions.py +29 -0
- squirrels/_initializer.py +177 -80
- squirrels/_logging.py +115 -0
- squirrels/_manifest.py +208 -79
- squirrels/_model_builder.py +69 -0
- squirrels/_model_configs.py +74 -0
- squirrels/_model_queries.py +52 -0
- squirrels/_models.py +926 -367
- squirrels/_package_data/base_project/.env +42 -0
- squirrels/_package_data/base_project/.env.example +42 -0
- squirrels/_package_data/base_project/assets/expenses.db +0 -0
- squirrels/_package_data/base_project/connections.yml +16 -0
- squirrels/_package_data/base_project/dashboards/dashboard_example.py +34 -0
- squirrels/_package_data/base_project/dashboards/dashboard_example.yml +22 -0
- squirrels/{package_data → _package_data}/base_project/docker/.dockerignore +5 -2
- squirrels/{package_data → _package_data}/base_project/docker/Dockerfile +3 -3
- squirrels/{package_data → _package_data}/base_project/docker/compose.yml +1 -1
- squirrels/_package_data/base_project/duckdb_init.sql +10 -0
- squirrels/{package_data/base_project/.gitignore → _package_data/base_project/gitignore} +3 -2
- squirrels/_package_data/base_project/macros/macros_example.sql +17 -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 +57 -0
- squirrels/_package_data/base_project/models/dbviews/dbview_example.sql +12 -0
- squirrels/_package_data/base_project/models/dbviews/dbview_example.yml +26 -0
- squirrels/_package_data/base_project/models/federates/federate_example.py +37 -0
- squirrels/_package_data/base_project/models/federates/federate_example.sql +19 -0
- squirrels/_package_data/base_project/models/federates/federate_example.yml +65 -0
- squirrels/_package_data/base_project/models/sources.yml +38 -0
- squirrels/{package_data → _package_data}/base_project/parameters.yml +56 -40
- squirrels/_package_data/base_project/pyconfigs/connections.py +14 -0
- squirrels/{package_data → _package_data}/base_project/pyconfigs/context.py +21 -40
- squirrels/_package_data/base_project/pyconfigs/parameters.py +141 -0
- squirrels/_package_data/base_project/pyconfigs/user.py +44 -0
- squirrels/_package_data/base_project/seeds/seed_categories.yml +15 -0
- squirrels/_package_data/base_project/seeds/seed_subcategories.csv +15 -0
- squirrels/_package_data/base_project/seeds/seed_subcategories.yml +21 -0
- 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/_package_loader.py +8 -4
- squirrels/_parameter_configs.py +104 -103
- squirrels/_parameter_options.py +348 -0
- squirrels/_parameter_sets.py +57 -47
- squirrels/_parameters.py +1664 -0
- squirrels/_project.py +721 -0
- squirrels/_py_module.py +7 -5
- 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} +126 -47
- squirrels/_seeds.py +35 -16
- squirrels/_sources.py +110 -0
- squirrels/_utils.py +248 -73
- 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 -631
- squirrels/parameter_options.py +13 -348
- squirrels/parameters.py +14 -1266
- squirrels/types.py +16 -0
- squirrels-0.5.0.dist-info/METADATA +113 -0
- squirrels-0.5.0.dist-info/RECORD +97 -0
- {squirrels-0.4.1.dist-info → squirrels-0.5.0.dist-info}/WHEEL +1 -1
- squirrels-0.5.0.dist-info/entry_points.txt +3 -0
- {squirrels-0.4.1.dist-info → squirrels-0.5.0.dist-info/licenses}/LICENSE +1 -1
- squirrels/_authenticator.py +0 -85
- squirrels/_dashboards_io.py +0 -61
- squirrels/_environcfg.py +0 -84
- squirrels/arguments/init_time_args.py +0 -40
- squirrels/arguments/run_time_args.py +0 -208
- 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/assets/expenses.db +0 -0
- squirrels/package_data/base_project/connections.yml +0 -7
- squirrels/package_data/base_project/dashboards/dashboard_example.py +0 -32
- 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/models/dbviews/dbview_example.sql +0 -22
- squirrels/package_data/base_project/models/federates/federate_example.py +0 -21
- squirrels/package_data/base_project/models/federates/federate_example.sql +0 -3
- squirrels/package_data/base_project/pyconfigs/auth.py +0 -45
- squirrels/package_data/base_project/pyconfigs/connections.py +0 -19
- squirrels/package_data/base_project/pyconfigs/parameters.py +0 -95
- squirrels/package_data/base_project/seeds/seed_subcategories.csv +0 -15
- squirrels/package_data/base_project/squirrels.yml.j2 +0 -94
- 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/METADATA +0 -117
- squirrels-0.4.1.dist-info/RECORD +0 -60
- squirrels-0.4.1.dist-info/entry_points.txt +0 -4
- /squirrels/{package_data → _package_data}/base_project/assets/weather.db +0 -0
- /squirrels/{package_data → _package_data}/base_project/seeds/seed_categories.csv +0 -0
- /squirrels/{package_data → _package_data}/base_project/tmp/.gitignore +0 -0
|
Binary file
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
from squirrels import DashboardArgs, dashboards as d
|
|
2
|
-
from matplotlib import pyplot as plt, figure as f, axes as a
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
async def main(sqrl: DashboardArgs) -> d.PngDashboard:
|
|
6
|
-
"""
|
|
7
|
-
Create a dashboard by retrieving datasets using "sqrl.dataset" method and transform the datasets to return as a PngDashboard or a HtmlDashboard.
|
|
8
|
-
- The PngDashboard constructor takes a single argument for either a matplotlib.figure.Figure or io.BytesIO/bytes of PNG data
|
|
9
|
-
- The HtmlDashboard constructor takes a single argument for a io.StringIO/string of HTML data
|
|
10
|
-
|
|
11
|
-
It is imperative to set the correct return type in the function signature for "main" above! It allows Squirrels to provide the correct format to
|
|
12
|
-
the data catalog without having to run this function.
|
|
13
|
-
"""
|
|
14
|
-
spending_by_month_df = await sqrl.dataset("dataset_example", fixed_parameters={"group_by": "g4"})
|
|
15
|
-
spending_by_subcategory_df = await sqrl.dataset("dataset_example", fixed_parameters={"group_by": "g3"})
|
|
16
|
-
|
|
17
|
-
# Create a figure with two subplots
|
|
18
|
-
fig, (ax0, ax1) = plt.subplots(2, 1, figsize=(8, 8), height_ratios=(1, 2))
|
|
19
|
-
fig: f.Figure; ax0: a.Axes; ax1: a.Axes
|
|
20
|
-
fig.tight_layout(pad=4, h_pad=6)
|
|
21
|
-
|
|
22
|
-
# Create a bar chart of spending by month
|
|
23
|
-
spending_by_month_df.sort_values("month").plot(x="month", y="total_amount", ax=ax0)
|
|
24
|
-
ax0.set_title("Spending by Month")
|
|
25
|
-
|
|
26
|
-
# Create a pie chart of spending by subcategory
|
|
27
|
-
df_by_subcategory = spending_by_subcategory_df.set_index("subcategory").sort_values("total_amount", ascending=False)
|
|
28
|
-
autopct = lambda pct: ('%.1f%%' % pct) if pct > 6 else ''
|
|
29
|
-
df_by_subcategory.plot(y="total_amount", kind='pie', ax=ax1, autopct=autopct, legend=False, ylabel="")
|
|
30
|
-
ax1.set_title("Spending by Subcategory")
|
|
31
|
-
|
|
32
|
-
return d.PngDashboard(fig)
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
## Note: You can copy this file to the .squirrels folder in your home directory to make
|
|
2
|
-
## the configurations global for all squirrels projects on the current machine
|
|
3
|
-
|
|
4
|
-
## Fake users for local development testing. Must have an 'auth.py' file with a 'User' model to use custom attributes like 'role'
|
|
5
|
-
users:
|
|
6
|
-
alice:
|
|
7
|
-
is_internal: True
|
|
8
|
-
password: I<3Squirrels
|
|
9
|
-
full_name: Alice Doe
|
|
10
|
-
role: manager
|
|
11
|
-
bob:
|
|
12
|
-
is_internal: False
|
|
13
|
-
password: abcd5678
|
|
14
|
-
full_name: Bob Doe
|
|
15
|
-
role: customer
|
|
16
|
-
|
|
17
|
-
## Custom environment variables / secrets
|
|
18
|
-
env_vars:
|
|
19
|
-
sqlite_conn_str: sqlite://{username}:{password}@/{project_path}/assets/expenses.db
|
|
20
|
-
|
|
21
|
-
## Database credentials
|
|
22
|
-
credentials:
|
|
23
|
-
db_user:
|
|
24
|
-
username: user1
|
|
25
|
-
password: pass1
|
|
26
|
-
|
|
27
|
-
## Predefined secrets used by the squirrels framework
|
|
28
|
-
secrets:
|
|
29
|
-
jwt_secret: ## generate a random 32 byte hex string here for the jwt secret/private key. For instance, you can run "openssl rand -hex 32" in bash
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
from textwrap import dedent
|
|
2
|
-
from squirrels import ModelArgs
|
|
3
|
-
import pandas as pd
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def main(sqrl: ModelArgs) -> pd.DataFrame:
|
|
7
|
-
"""
|
|
8
|
-
Create a database view model in Python by sending an external query to a database or API, and return a
|
|
9
|
-
pandas DataFrame of the result in this function. Since the result is loaded into server memory, be mindful of
|
|
10
|
-
the size of the results coming from the external query.
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
## If working with sqlalchemy ORMs, use 'sqrl.connections' to get a sqlalchemy engine
|
|
14
|
-
# from typing import Union
|
|
15
|
-
# engine1 = sqrl.connections[sqrl.connection_name] ## using the pre-assigned key
|
|
16
|
-
# engine2 = sqrl.connections["my_connection_name"] ## or use any defined key
|
|
17
|
-
|
|
18
|
-
## Example with building and running a sql query
|
|
19
|
-
masked_id = "id" if getattr(sqrl.user, "role", "") == "manager" else "'***'"
|
|
20
|
-
desc_cond = "description LIKE :desc_pattern" if sqrl.is_placeholder("desc_pattern") else "true"
|
|
21
|
-
category_cond = f"category IN ({sqrl.ctx['categories']})" if sqrl.ctx["has_categories"] else "true"
|
|
22
|
-
subcategory_cond = f"subcategory IN ({sqrl.ctx['subcategories']})" if sqrl.ctx["has_subcategories"] else "true"
|
|
23
|
-
query = dedent(f"""
|
|
24
|
-
WITH
|
|
25
|
-
transactions_with_masked_id AS (
|
|
26
|
-
SELECT *,
|
|
27
|
-
{masked_id} as masked_id,
|
|
28
|
-
STRFTIME('%Y-%m', date) AS month
|
|
29
|
-
FROM transactions
|
|
30
|
-
)
|
|
31
|
-
SELECT {sqrl.ctx["select_dim_cols"]}
|
|
32
|
-
, sum(-amount) as total_amount
|
|
33
|
-
FROM transactions_with_masked_id
|
|
34
|
-
WHERE date >= :start_date
|
|
35
|
-
AND date <= :end_date
|
|
36
|
-
AND -amount >= :min_amount
|
|
37
|
-
AND -amount <= :max_amount
|
|
38
|
-
AND {desc_cond}
|
|
39
|
-
AND {category_cond}
|
|
40
|
-
AND {subcategory_cond}
|
|
41
|
-
GROUP BY {sqrl.ctx["group_by_cols"]}
|
|
42
|
-
""").strip()
|
|
43
|
-
|
|
44
|
-
return sqrl.run_external_sql(query)
|
|
45
|
-
|
|
46
|
-
## A 'connection_name' argument is available to use a different connection key
|
|
47
|
-
# return sqrl.run_external_sql(query, connection_name="different_key")
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
WITH
|
|
2
|
-
transactions_with_masked_id AS (
|
|
3
|
-
SELECT *,
|
|
4
|
-
{%- if user.role == "manager" %}
|
|
5
|
-
id as masked_id
|
|
6
|
-
{%- else %}
|
|
7
|
-
'***' as masked_id
|
|
8
|
-
{%- endif %},
|
|
9
|
-
STRFTIME('%Y-%m', date) AS month
|
|
10
|
-
FROM transactions
|
|
11
|
-
)
|
|
12
|
-
SELECT {{ ctx.select_dim_cols }}
|
|
13
|
-
, SUM(-amount) as total_amount
|
|
14
|
-
FROM transactions_with_masked_id
|
|
15
|
-
WHERE date >= :start_date
|
|
16
|
-
AND date <= :end_date
|
|
17
|
-
AND -amount >= :min_amount
|
|
18
|
-
AND -amount <= :max_amount
|
|
19
|
-
{% if is_placeholder("desc_pattern") -%} AND description LIKE :desc_pattern {%- endif %}
|
|
20
|
-
{% if ctx.has_categories -%} AND category IN ({{ ctx.categories }}) {%- endif %}
|
|
21
|
-
{% if ctx.has_subcategories -%} AND subcategory IN ({{ ctx.subcategories }}) {%- endif %}
|
|
22
|
-
GROUP BY {{ ctx.group_by_cols }}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
from typing import Sequence
|
|
2
|
-
from squirrels import ModelDepsArgs, ModelArgs
|
|
3
|
-
import pandas as pd
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def dependencies(sqrl: ModelDepsArgs) -> Sequence[str]:
|
|
7
|
-
"""
|
|
8
|
-
Define list of dependent models here. This will determine the dependencies first, at compile-time,
|
|
9
|
-
before running the model.
|
|
10
|
-
"""
|
|
11
|
-
return ["dbview_example"]
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def main(sqrl: ModelArgs) -> pd.DataFrame:
|
|
15
|
-
"""
|
|
16
|
-
Create federated models by joining/processing dependent database views and/or other federated models to
|
|
17
|
-
form and return the result as a new pandas DataFrame.
|
|
18
|
-
"""
|
|
19
|
-
(DBVIEW_EXAMPLE,) = dependencies(sqrl)
|
|
20
|
-
df = sqrl.ref(DBVIEW_EXAMPLE)
|
|
21
|
-
return df.sort_values(sqrl.ctx["order_by_cols_list"], ascending=False)
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
from typing import Union
|
|
2
|
-
from squirrels import User as UserBase, AuthArgs, WrongPassword
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class User(UserBase):
|
|
6
|
-
def set_attributes(self, **kwargs) -> None:
|
|
7
|
-
"""
|
|
8
|
-
Use this method to add custom attributes in the User model that don't exist in UserBase
|
|
9
|
-
(i.e., anything that's not 'username' or 'is_internal')
|
|
10
|
-
"""
|
|
11
|
-
self.role = kwargs["role"]
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def get_user_if_valid(sqrl: AuthArgs) -> Union[User, WrongPassword, None]:
|
|
15
|
-
"""
|
|
16
|
-
This function allows the squirrels framework to know how to authenticate input username and password.
|
|
17
|
-
|
|
18
|
-
Return:
|
|
19
|
-
- User instance - if username and password are correct
|
|
20
|
-
- WrongPassword() - if username exists but password is incorrect
|
|
21
|
-
- None - if the username doesn't exist (and search for username will continue for "fake users" configured in env.yml)
|
|
22
|
-
"""
|
|
23
|
-
mock_users_db = {
|
|
24
|
-
"johndoe": {
|
|
25
|
-
"username": "johndoe",
|
|
26
|
-
"is_admin": True,
|
|
27
|
-
"role": "manager",
|
|
28
|
-
"hashed_password": str(hash("I<3Squirrels"))
|
|
29
|
-
},
|
|
30
|
-
"mattdoe": {
|
|
31
|
-
"username": "mattdoe",
|
|
32
|
-
"is_admin": False,
|
|
33
|
-
"role": "customer",
|
|
34
|
-
"hashed_password": str(hash("abcd5678"))
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
user_obj = mock_users_db.get(sqrl.username)
|
|
39
|
-
if user_obj is None:
|
|
40
|
-
return None
|
|
41
|
-
|
|
42
|
-
if str(hash(sqrl.password)) == user_obj["hashed_password"]:
|
|
43
|
-
return User.Create(sqrl.username, is_internal=user_obj["is_admin"], role=user_obj["role"])
|
|
44
|
-
else:
|
|
45
|
-
return WrongPassword()
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
from sqlalchemy import create_engine, Engine
|
|
2
|
-
from squirrels import ConnectionsArgs
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def main(connections: dict[str, Engine], sqrl: ConnectionsArgs) -> None:
|
|
6
|
-
"""
|
|
7
|
-
Define sqlalchemy engines by adding them to the "connections" dictionary
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
## SQLAlchemy URL for a connection engine
|
|
11
|
-
conn_str = 'sqlite:///./assets/expenses.db'
|
|
12
|
-
|
|
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
|
-
## Assigning names to connection engines
|
|
19
|
-
connections["default"] = create_engine(conn_str)
|
|
@@ -1,95 +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
|
-
group_by_options = [
|
|
21
|
-
po.SelectParameterOption("g0", "Transaction", columns=["masked_id", "date", "description"], aliases=["id", "date", "description"]),
|
|
22
|
-
po.SelectParameterOption("g1", "Date", columns=["date"]),
|
|
23
|
-
po.SelectParameterOption("g4", "Month", columns=["month"]),
|
|
24
|
-
po.SelectParameterOption("g2", "Category", columns=["category"]),
|
|
25
|
-
po.SelectParameterOption("g3", "Subcategory", columns=["category", "subcategory"]),
|
|
26
|
-
]
|
|
27
|
-
p.SingleSelectParameter.CreateWithOptions(
|
|
28
|
-
"group_by", "Group By", group_by_options, description="Dimension(s) to aggregate by"
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
## Example of creating a TextParameter
|
|
32
|
-
parent_name = "group_by"
|
|
33
|
-
description_text_options = [
|
|
34
|
-
po.TextParameterOption(parent_option_ids="g0")
|
|
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"
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
## Example of creating DateParameter from lookup query/table
|
|
42
|
-
start_date_source = ds.DateDataSource(
|
|
43
|
-
"SELECT min(date) AS min_date, max(date) AS max_date FROM transactions",
|
|
44
|
-
default_date_col="min_date", min_date_col="min_date", max_date_col="max_date"
|
|
45
|
-
)
|
|
46
|
-
p.DateParameter.CreateFromSource(
|
|
47
|
-
"start_date", "Start Date", start_date_source, description="Start date to filter transactions by"
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
## Example of creating DateParameter from list of DateParameterOption's
|
|
51
|
-
end_date_option = [po.DateParameterOption("2023-12-31", min_date="2023-01-01", max_date="2023-12-31")]
|
|
52
|
-
p.DateParameter.CreateWithOptions(
|
|
53
|
-
"end_date", "End Date", end_date_option, description="End date to filter transactions by"
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
## Example of creating DateRangeParameter
|
|
57
|
-
p.DateRangeParameter.CreateSimple(
|
|
58
|
-
"date_range", "Date Range", "2023-01-01", "2023-12-31", min_date="2023-01-01", max_date="2023-12-31",
|
|
59
|
-
description="Date range to filter transactions by"
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
## Example of creating MultiSelectParameter from lookup query/table
|
|
63
|
-
category_ds = ds.SelectDataSource("seed_categories", "category_id", "category", from_seeds=True)
|
|
64
|
-
p.MultiSelectParameter.CreateFromSource(
|
|
65
|
-
"category", "Category Filter", category_ds, description="The expense categories to filter transactions by"
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
## Example of creating MultiSelectParameter with parent from lookup query/table
|
|
69
|
-
parent_name = "category"
|
|
70
|
-
subcategory_ds = ds.SelectDataSource(
|
|
71
|
-
"seed_subcategories", "subcategory_id", "subcategory", from_seeds=True, parent_id_col="category_id"
|
|
72
|
-
)
|
|
73
|
-
p.MultiSelectParameter.CreateFromSource(
|
|
74
|
-
"subcategory", "Subcategory Filter", subcategory_ds, parent_name=parent_name,
|
|
75
|
-
description="The expense subcategories to filter transactions by (available options are based on selected value(s) of 'Category Filter')"
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
## Example of creating NumberParameter
|
|
79
|
-
p.NumberParameter.CreateSimple(
|
|
80
|
-
"min_filter", "Amounts Greater Than", min_value=0, max_value=500, increment=10,
|
|
81
|
-
description="Number to filter on transactions with an amount greater than this value"
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
## Example of creating NumberParameter from lookup query/table
|
|
85
|
-
query = "SELECT 0 as min_value, max(-amount) as max_value, 10 as increment FROM transactions WHERE category <> 'Income'"
|
|
86
|
-
max_amount_ds = ds.NumberDataSource(query, "min_value", "max_value", increment_col="increment", default_value_col="max_value")
|
|
87
|
-
p.NumberParameter.CreateFromSource(
|
|
88
|
-
"max_filter", "Amounts Less Than", max_amount_ds, description="Number to filter on transactions with an amount less than this value"
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
## Example of creating NumberRangeParameter
|
|
92
|
-
p.NumberRangeParameter.CreateSimple(
|
|
93
|
-
"between_filter", "Amounts Between", 0, 500, default_lower_value=10, default_upper_value=400,
|
|
94
|
-
description="Number range to filter on transactions with an amount within this range"
|
|
95
|
-
)
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"subcategory","category_id","subcategory_id"
|
|
2
|
-
"Dining Out","0","0"
|
|
3
|
-
"Groceries","0","1"
|
|
4
|
-
"Utilities","1","2"
|
|
5
|
-
"Electronics","2","3"
|
|
6
|
-
"Ride Sharing","3","4"
|
|
7
|
-
"Mobile","1","5"
|
|
8
|
-
"Home Decor","2","6"
|
|
9
|
-
"Internet","1","7"
|
|
10
|
-
"Theater","4","8"
|
|
11
|
-
"Movies","4","9"
|
|
12
|
-
"Sports","2","10"
|
|
13
|
-
"Public Transit","3","11"
|
|
14
|
-
"Clothing","2","12"
|
|
15
|
-
"Concerts","4","13"
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
project_variables:
|
|
2
|
-
name: sample
|
|
3
|
-
label: Sample Project
|
|
4
|
-
major_version: 1
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
packages: []
|
|
8
|
-
|
|
9
|
-
## Example for packages section:
|
|
10
|
-
# packages:
|
|
11
|
-
# - git: https://.../myrepo.git
|
|
12
|
-
# revision: v0.1.0
|
|
13
|
-
# directory: custom_name ## optional
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{{ connections -}}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
{{ parameters -}}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
datasets:
|
|
23
|
-
- name: dataset_example ## model name uses same name unless "model" field is specified
|
|
24
|
-
label: Dataset Example
|
|
25
|
-
model: federate_example ## optional - if not specified, then the "name" field is used
|
|
26
|
-
scope: public ## optional - one of 'public' (default), 'protected', or 'private'
|
|
27
|
-
parameters: ## optional - if not specified, then all parameters are used
|
|
28
|
-
- group_by
|
|
29
|
-
- description_filter
|
|
30
|
-
- start_date
|
|
31
|
-
- end_date
|
|
32
|
-
- category
|
|
33
|
-
- subcategory
|
|
34
|
-
- min_filter
|
|
35
|
-
- max_filter
|
|
36
|
-
traits: {} ## optional - defaults to empty object
|
|
37
|
-
|
|
38
|
-
- name: protected_dataset_example ## requires auth.py file to work
|
|
39
|
-
label: Dataset Example 2
|
|
40
|
-
model: federate_example
|
|
41
|
-
scope: protected
|
|
42
|
-
parameters:
|
|
43
|
-
- group_by
|
|
44
|
-
- description_filter
|
|
45
|
-
- date_range
|
|
46
|
-
- category
|
|
47
|
-
- subcategory
|
|
48
|
-
- between_filter
|
|
49
|
-
default_test_set: auth_test1 ## optional - if not specified, uses setting 'selection_test_sets.default_name_used'
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
{{ dashboards -}}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
selection_test_sets:
|
|
56
|
-
- name: no_auth_test1
|
|
57
|
-
datasets: ## optional section - if not provided, then test set is applicable for any dataset
|
|
58
|
-
- dataset_example
|
|
59
|
-
parameters: ## optional section - if not provided, then assumes no parameters. For unspecified parameters, default value is used
|
|
60
|
-
start_date: 2023-07-01 ## this parameter only exists for dataset 'dataset_example'
|
|
61
|
-
|
|
62
|
-
- name: auth_test1
|
|
63
|
-
datasets:
|
|
64
|
-
- protected_dataset_example
|
|
65
|
-
user_attributes: ## optional section - required if using test set on non-public datasets
|
|
66
|
-
role: customer
|
|
67
|
-
parameters:
|
|
68
|
-
date_range: [2023-02-01,2023-12-01] ## this parameter only exists for dataset 'protected_dataset_example'
|
|
69
|
-
|
|
70
|
-
- name: auth_test2
|
|
71
|
-
user_attributes:
|
|
72
|
-
username: alice ## optional - defaults to empty string
|
|
73
|
-
is_internal: True ## optional - defaults to False
|
|
74
|
-
role: manager
|
|
75
|
-
parameters:
|
|
76
|
-
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]
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link id="favicon" rel="icon" type="image/x-icon" href="/assets/favicon.ico" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<script>
|
|
8
|
-
const hostname = '';
|
|
9
|
-
const projectMetadataURL = '{{ project_metadata_path }}';
|
|
10
|
-
</script>
|
|
11
|
-
<title>Squirrels Testing UI</title>
|
|
12
|
-
<script type="module" crossorigin src="/assets/index.js?version=0.4.1"></script>
|
|
13
|
-
<link rel="stylesheet" crossorigin href="/assets/index.css?version=0.4.1">
|
|
14
|
-
</head>
|
|
15
|
-
<body>
|
|
16
|
-
<div id="root"></div>
|
|
17
|
-
</body>
|
|
18
|
-
</html>
|