squirrels 0.5.0b4__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.
- squirrels/__init__.py +2 -0
- squirrels/_api_routes/auth.py +83 -74
- squirrels/_api_routes/base.py +58 -41
- squirrels/_api_routes/dashboards.py +37 -21
- squirrels/_api_routes/data_management.py +72 -27
- squirrels/_api_routes/datasets.py +107 -84
- squirrels/_api_routes/oauth2.py +11 -13
- squirrels/_api_routes/project.py +71 -33
- squirrels/_api_server.py +130 -63
- squirrels/_arguments/run_time_args.py +9 -9
- squirrels/_auth.py +117 -162
- squirrels/_command_line.py +68 -32
- squirrels/_compile_prompts.py +147 -0
- squirrels/_connection_set.py +11 -2
- squirrels/_constants.py +22 -8
- squirrels/_data_sources.py +38 -32
- squirrels/_dataset_types.py +2 -4
- squirrels/_initializer.py +1 -1
- squirrels/_logging.py +117 -0
- squirrels/_manifest.py +125 -58
- squirrels/_model_builder.py +10 -54
- squirrels/_models.py +224 -108
- squirrels/_package_data/base_project/.env +15 -4
- squirrels/_package_data/base_project/.env.example +14 -3
- squirrels/_package_data/base_project/connections.yml +4 -3
- squirrels/_package_data/base_project/dashboards/dashboard_example.py +2 -2
- squirrels/_package_data/base_project/dashboards/dashboard_example.yml +4 -4
- squirrels/_package_data/base_project/duckdb_init.sql +1 -0
- squirrels/_package_data/base_project/models/dbviews/dbview_example.sql +7 -2
- squirrels/_package_data/base_project/models/dbviews/dbview_example.yml +16 -10
- squirrels/_package_data/base_project/models/federates/federate_example.py +22 -15
- squirrels/_package_data/base_project/models/federates/federate_example.sql +3 -7
- squirrels/_package_data/base_project/models/federates/federate_example.yml +1 -1
- squirrels/_package_data/base_project/models/sources.yml +5 -6
- squirrels/_package_data/base_project/parameters.yml +24 -38
- squirrels/_package_data/base_project/pyconfigs/connections.py +5 -1
- squirrels/_package_data/base_project/pyconfigs/context.py +23 -12
- squirrels/_package_data/base_project/pyconfigs/parameters.py +68 -33
- squirrels/_package_data/base_project/pyconfigs/user.py +11 -18
- squirrels/_package_data/base_project/seeds/seed_categories.yml +1 -1
- squirrels/_package_data/base_project/seeds/seed_subcategories.yml +1 -1
- squirrels/_package_data/base_project/squirrels.yml.j2 +18 -28
- squirrels/_package_data/templates/squirrels_studio.html +20 -0
- squirrels/_parameter_configs.py +43 -22
- squirrels/_parameter_options.py +1 -1
- squirrels/_parameter_sets.py +8 -10
- squirrels/_project.py +351 -234
- squirrels/_request_context.py +33 -0
- squirrels/_schemas/auth_models.py +32 -9
- squirrels/_schemas/query_param_models.py +9 -1
- squirrels/_schemas/response_models.py +36 -10
- squirrels/_seeds.py +1 -1
- squirrels/_sources.py +23 -19
- squirrels/_utils.py +83 -35
- squirrels/_version.py +1 -1
- squirrels/arguments.py +5 -0
- squirrels/auth.py +4 -1
- squirrels/connections.py +2 -0
- squirrels/dashboards.py +3 -1
- squirrels/data_sources.py +6 -0
- squirrels/parameter_options.py +5 -0
- squirrels/parameters.py +5 -0
- squirrels/types.py +6 -1
- {squirrels-0.5.0b4.dist-info → squirrels-0.5.1.dist-info}/METADATA +28 -13
- squirrels-0.5.1.dist-info/RECORD +98 -0
- squirrels-0.5.0b4.dist-info/RECORD +0 -94
- {squirrels-0.5.0b4.dist-info → squirrels-0.5.1.dist-info}/WHEEL +0 -0
- {squirrels-0.5.0b4.dist-info → squirrels-0.5.1.dist-info}/entry_points.txt +0 -0
- {squirrels-0.5.0b4.dist-info → squirrels-0.5.1.dist-info}/licenses/LICENSE +0 -0
squirrels/_command_line.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from argparse import ArgumentParser, _SubParsersAction
|
|
2
|
+
from pathlib import Path
|
|
2
3
|
import sys, asyncio, traceback, io, subprocess
|
|
3
4
|
|
|
4
5
|
sys.path.append('.')
|
|
@@ -9,18 +10,31 @@ from ._initializer import Initializer
|
|
|
9
10
|
from ._package_loader import PackageLoaderIO
|
|
10
11
|
from ._project import SquirrelsProject
|
|
11
12
|
from . import _constants as c, _utils as u
|
|
13
|
+
from ._compile_prompts import prompt_compile_options
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
def _run_duckdb_cli(project: SquirrelsProject, ui: bool):
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
init_sql = u._read_duckdb_init_sql(datalake_db_path=project._datalake_db_path)
|
|
18
|
+
|
|
19
|
+
target_init_path = None
|
|
20
|
+
if init_sql:
|
|
21
|
+
target_init_path = Path(c.TARGET_FOLDER, c.DUCKDB_INIT_FILE)
|
|
22
|
+
target_init_path.parent.mkdir(parents=True, exist_ok=True)
|
|
23
|
+
target_init_path.write_text(init_sql)
|
|
24
|
+
|
|
25
|
+
init_args = ["-init", str(target_init_path)] if target_init_path else []
|
|
17
26
|
command = ['duckdb']
|
|
18
27
|
if ui:
|
|
19
28
|
command.append('-ui')
|
|
20
29
|
if init_args:
|
|
21
|
-
command.extend(init_args
|
|
22
|
-
|
|
23
|
-
print(
|
|
30
|
+
command.extend(init_args)
|
|
31
|
+
|
|
32
|
+
print("Starting DuckDB CLI with command:")
|
|
33
|
+
print(f"$ {' '.join(command)}")
|
|
34
|
+
print()
|
|
35
|
+
print("To exit the DuckDB CLI, enter '.exit'")
|
|
36
|
+
print()
|
|
37
|
+
|
|
24
38
|
try:
|
|
25
39
|
subprocess.run(command, check=True)
|
|
26
40
|
except FileNotFoundError:
|
|
@@ -33,19 +47,19 @@ def main():
|
|
|
33
47
|
"""
|
|
34
48
|
Main entry point for the squirrels command line utilities.
|
|
35
49
|
"""
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
# Create a parent parser with common logging options
|
|
51
|
+
parent_parser = ArgumentParser(add_help=False)
|
|
52
|
+
parent_parser.add_argument('-h', '--help', action="help", help="Show this help message and exit")
|
|
53
|
+
parent_parser.add_argument('--log-level', type=str, choices=["DEBUG", "INFO", "WARNING"], help='Level of logging to use. Default is from SQRL_LOGGING__LOG_LEVEL environment variable or INFO.')
|
|
54
|
+
parent_parser.add_argument('--log-format', type=str, choices=["text", "json"], help='Format of the log records. Default is from SQRL_LOGGING__LOG_FORMAT environment variable or text.')
|
|
55
|
+
parent_parser.add_argument('--log-to-file', action='store_true', help='Enable logging to file(s) in the "logs/" folder with rotation and retention policies.')
|
|
56
|
+
|
|
57
|
+
parser = ArgumentParser(description="Command line utilities from the squirrels python package", add_help=False, parents=[parent_parser])
|
|
41
58
|
parser.add_argument('-V', '--version', action='store_true', help='Show the version and exit')
|
|
42
|
-
parser.add_argument('--log-level', type=str, choices=["DEBUG", "INFO", "WARNING"], default="INFO", help='Level of logging to use')
|
|
43
|
-
parser.add_argument('--log-format', type=str, choices=["text", "json"], default="text", help='Format of the log records')
|
|
44
|
-
parser.add_argument('--log-file', type=str, default=c.LOGS_FILE, help=f'Name of log file to write to in the "logs/" folder. Default is {c.LOGS_FILE}. If name is empty, then file logging is disabled')
|
|
45
59
|
subparsers = parser.add_subparsers(title='commands', dest='command')
|
|
46
60
|
|
|
47
61
|
def add_subparser(subparsers: _SubParsersAction, cmd: str, help_text: str):
|
|
48
|
-
subparser =
|
|
62
|
+
subparser: ArgumentParser = subparsers.add_parser(cmd, description=help_text, help=help_text, add_help=False, parents=[parent_parser])
|
|
49
63
|
return subparser
|
|
50
64
|
|
|
51
65
|
init_parser = add_subparser(subparsers, c.INIT_CMD, 'Create a new squirrels project')
|
|
@@ -92,25 +106,26 @@ def main():
|
|
|
92
106
|
deps_parser = add_subparser(subparsers, c.DEPS_CMD, f'Load all packages specified in {c.MANIFEST_FILE} (from git)')
|
|
93
107
|
|
|
94
108
|
compile_parser = add_subparser(subparsers, c.COMPILE_CMD, 'Create rendered SQL files in the folder "./target/compile"')
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
109
|
+
compile_parser.add_argument('-y', '--yes', action='store_true', help='Disable prompts and assume the default for all settings not overridden by CLI options')
|
|
110
|
+
compile_parser.add_argument('-c', '--clear', action='store_true', help='Clear the "target/compile/" folder before compiling')
|
|
111
|
+
compile_scope_group = compile_parser.add_mutually_exclusive_group(required=False)
|
|
112
|
+
compile_scope_group.add_argument('--buildtime-only', action='store_true', help='Compile only buildtime models')
|
|
113
|
+
compile_scope_group.add_argument('--runtime-only', action='store_true', help='Compile only runtime models')
|
|
98
114
|
compile_test_set_group = compile_parser.add_mutually_exclusive_group(required=False)
|
|
99
|
-
compile_test_set_group.add_argument('-t', '--test-set', type=str, help="The selection test set to use. If not specified, default selections are used
|
|
100
|
-
compile_test_set_group.add_argument('-T', '--all-test-sets', action="store_true", help="Compile models for all selection test sets")
|
|
101
|
-
compile_parser.add_argument('-s', '--select', type=str, help="Select single model to compile. If not specified, all models
|
|
102
|
-
compile_parser.add_argument('-r', '--runquery', action='store_true', help='
|
|
103
|
-
|
|
104
|
-
build_parser = add_subparser(subparsers, c.BUILD_CMD, 'Build the
|
|
115
|
+
compile_test_set_group.add_argument('-t', '--test-set', type=str, help="The selection test set to use. If not specified, default selections are used (unless using --all-test-sets). Not applicable for buildtime models")
|
|
116
|
+
compile_test_set_group.add_argument('-T', '--all-test-sets', action="store_true", help="Compile models for all selection test sets. Not applicable for buildtime models")
|
|
117
|
+
compile_parser.add_argument('-s', '--select', type=str, help="Select single model to compile. If not specified, all models are compiled")
|
|
118
|
+
compile_parser.add_argument('-r', '--runquery', action='store_true', help='Run runtime models and write CSV outputs too. Does not apply to buildtime models')
|
|
119
|
+
|
|
120
|
+
build_parser = add_subparser(subparsers, c.BUILD_CMD, 'Build the Virtual Data Lake (VDL) for the project')
|
|
105
121
|
build_parser.add_argument('-f', '--full-refresh', action='store_true', help='Drop all tables before building')
|
|
106
122
|
build_parser.add_argument('-s', '--select', type=str, help="Select one static model to build. If not specified, all models are built")
|
|
107
|
-
build_parser.add_argument('--stage', type=str, help='If the venv file is in use, stage the duckdb file to replace the venv later')
|
|
108
123
|
|
|
109
124
|
duckdb_parser = add_subparser(subparsers, c.DUCKDB_CMD, 'Run the duckdb command line tool')
|
|
110
125
|
duckdb_parser.add_argument('--ui', action='store_true', help='Run the duckdb local UI')
|
|
111
126
|
|
|
112
127
|
run_parser = add_subparser(subparsers, c.RUN_CMD, 'Run the API server')
|
|
113
|
-
run_parser.add_argument('--build', action='store_true', help='Build the
|
|
128
|
+
run_parser.add_argument('--build', action='store_true', help='Build the VDL first (without full refresh) before running the API server')
|
|
114
129
|
run_parser.add_argument('--no-cache', action='store_true', help='Do not cache any api results')
|
|
115
130
|
run_parser.add_argument('--host', type=str, default='127.0.0.1', help="The host to run on")
|
|
116
131
|
run_parser.add_argument('--port', type=int, default=4465, help="The port to run on")
|
|
@@ -126,12 +141,12 @@ def main():
|
|
|
126
141
|
elif args.command is None:
|
|
127
142
|
print(f'Command is missing. Enter "squirrels -h" for help.')
|
|
128
143
|
else:
|
|
129
|
-
project = SquirrelsProject(log_level=args.log_level, log_format=args.log_format,
|
|
144
|
+
project = SquirrelsProject(load_dotenv_globally=True, log_level=args.log_level, log_format=args.log_format, log_to_file=args.log_to_file)
|
|
130
145
|
try:
|
|
131
146
|
if args.command == c.DEPS_CMD:
|
|
132
147
|
PackageLoaderIO.load_packages(project._logger, project._manifest_cfg, reload=True)
|
|
133
148
|
elif args.command == c.BUILD_CMD:
|
|
134
|
-
task = project.build(full_refresh=args.full_refresh, select=args.select
|
|
149
|
+
task = project.build(full_refresh=args.full_refresh, select=args.select)
|
|
135
150
|
asyncio.run(task)
|
|
136
151
|
print()
|
|
137
152
|
elif args.command == c.DUCKDB_CMD:
|
|
@@ -143,11 +158,32 @@ def main():
|
|
|
143
158
|
server = ApiServer(args.no_cache, project)
|
|
144
159
|
server.run(args)
|
|
145
160
|
elif args.command == c.COMPILE_CMD:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
161
|
+
# Derive final options with optional interactive prompts (unless --yes is provided)
|
|
162
|
+
buildtime_only = args.buildtime_only
|
|
163
|
+
runtime_only = args.runtime_only
|
|
164
|
+
test_set = args.test_set
|
|
165
|
+
do_all_test_sets = args.all_test_sets
|
|
166
|
+
selected_model = args.select
|
|
167
|
+
|
|
168
|
+
try:
|
|
169
|
+
if not args.yes:
|
|
170
|
+
buildtime_only, runtime_only, test_set, do_all_test_sets, selected_model = prompt_compile_options(
|
|
171
|
+
project,
|
|
172
|
+
buildtime_only=buildtime_only,
|
|
173
|
+
runtime_only=runtime_only,
|
|
174
|
+
test_set=test_set,
|
|
175
|
+
do_all_test_sets=do_all_test_sets,
|
|
176
|
+
selected_model=selected_model,
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
task = project.compile(
|
|
180
|
+
selected_model=selected_model, test_set=test_set, do_all_test_sets=do_all_test_sets, runquery=args.runquery,
|
|
181
|
+
clear=args.clear, buildtime_only=buildtime_only, runtime_only=runtime_only
|
|
182
|
+
)
|
|
183
|
+
asyncio.run(task)
|
|
184
|
+
|
|
185
|
+
except KeyError:
|
|
186
|
+
pass
|
|
151
187
|
else:
|
|
152
188
|
print(f'Error: No such command "{args.command}". Enter "squirrels -h" for help.')
|
|
153
189
|
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
from typing import Tuple, Optional
|
|
2
|
+
import inquirer
|
|
3
|
+
|
|
4
|
+
from ._project import SquirrelsProject
|
|
5
|
+
from . import _constants as c, _models as m
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def prompt_compile_options(
|
|
9
|
+
project: SquirrelsProject,
|
|
10
|
+
*,
|
|
11
|
+
buildtime_only: bool,
|
|
12
|
+
runtime_only: bool,
|
|
13
|
+
test_set: Optional[str],
|
|
14
|
+
do_all_test_sets: bool,
|
|
15
|
+
selected_model: Optional[str],
|
|
16
|
+
) -> Tuple[bool, bool, Optional[str], bool, Optional[str]]:
|
|
17
|
+
"""
|
|
18
|
+
Interactive prompts to derive compile options when --yes is not provided.
|
|
19
|
+
|
|
20
|
+
Returns updated values for:
|
|
21
|
+
(buildtime_only, runtime_only, test_set, do_all_test_sets, selected_model)
|
|
22
|
+
"""
|
|
23
|
+
# 1) Scope prompt (skip if explicit flags provided)
|
|
24
|
+
if not buildtime_only and not runtime_only:
|
|
25
|
+
scope_answer = inquirer.prompt([
|
|
26
|
+
inquirer.List(
|
|
27
|
+
'scope',
|
|
28
|
+
message='Select scope',
|
|
29
|
+
choices=[
|
|
30
|
+
('All models', 'all'),
|
|
31
|
+
('Buildtime models only', 'buildtime'),
|
|
32
|
+
('Runtime models only', 'runtime'),
|
|
33
|
+
],
|
|
34
|
+
default='all',
|
|
35
|
+
)
|
|
36
|
+
]) or {}
|
|
37
|
+
scope_val = scope_answer['scope']
|
|
38
|
+
if scope_val == 'buildtime':
|
|
39
|
+
buildtime_only, runtime_only = True, False
|
|
40
|
+
elif scope_val == 'runtime':
|
|
41
|
+
buildtime_only, runtime_only = False, True
|
|
42
|
+
else:
|
|
43
|
+
buildtime_only, runtime_only = False, False
|
|
44
|
+
|
|
45
|
+
# 2) Runtime test set prompt (only if runtime is included and -t/-T not provided)
|
|
46
|
+
runtime_included, buildtime_included = not buildtime_only, not runtime_only
|
|
47
|
+
if runtime_included and not test_set and not do_all_test_sets:
|
|
48
|
+
test_mode_answer = inquirer.prompt([
|
|
49
|
+
inquirer.List(
|
|
50
|
+
'ts_mode',
|
|
51
|
+
message='Runtime selections for parameters, configurables, and user attributes?',
|
|
52
|
+
choices=[
|
|
53
|
+
('Use default selections', 'default'),
|
|
54
|
+
('Use a custom test set', 'custom'),
|
|
55
|
+
('Use all test sets (including default selections)', 'all'),
|
|
56
|
+
],
|
|
57
|
+
default='default',
|
|
58
|
+
)
|
|
59
|
+
]) or {}
|
|
60
|
+
ts_mode = test_mode_answer['ts_mode']
|
|
61
|
+
if ts_mode == 'all':
|
|
62
|
+
do_all_test_sets = True
|
|
63
|
+
elif ts_mode == 'custom':
|
|
64
|
+
# Build available test set list
|
|
65
|
+
ts_names = list(project._manifest_cfg.selection_test_sets.keys())
|
|
66
|
+
ts_answer = inquirer.prompt([
|
|
67
|
+
inquirer.List(
|
|
68
|
+
'test_set',
|
|
69
|
+
message='Pick a selection test set',
|
|
70
|
+
choices=ts_names if ts_names else [c.DEFAULT_TEST_SET_NAME],
|
|
71
|
+
default=c.DEFAULT_TEST_SET_NAME,
|
|
72
|
+
)
|
|
73
|
+
]) or {}
|
|
74
|
+
test_set = ts_answer['test_set']
|
|
75
|
+
|
|
76
|
+
# 3) Model selection prompt (only if -s not provided)
|
|
77
|
+
if not selected_model:
|
|
78
|
+
# Ask whether to compile all or a specific model
|
|
79
|
+
model_mode_answer = inquirer.prompt([
|
|
80
|
+
inquirer.List(
|
|
81
|
+
'model_mode',
|
|
82
|
+
message='Compile all models in scope or just a specific model?',
|
|
83
|
+
choices=[
|
|
84
|
+
('All models', 'all'),
|
|
85
|
+
('Select a specific model', 'one'),
|
|
86
|
+
],
|
|
87
|
+
default='all',
|
|
88
|
+
)
|
|
89
|
+
]) or {}
|
|
90
|
+
model_mode = model_mode_answer['model_mode']
|
|
91
|
+
|
|
92
|
+
if model_mode == 'one':
|
|
93
|
+
# Build list of runtime query models (dbviews + federates) and build models if included
|
|
94
|
+
models_dict = project._get_models_dict(always_python_df=False)
|
|
95
|
+
|
|
96
|
+
valid_model_types: list[m.ModelType] = []
|
|
97
|
+
if runtime_included:
|
|
98
|
+
valid_model_types.extend([m.ModelType.DBVIEW, m.ModelType.FEDERATE])
|
|
99
|
+
if buildtime_included:
|
|
100
|
+
valid_model_types.append(m.ModelType.BUILD)
|
|
101
|
+
|
|
102
|
+
runtime_names = sorted([
|
|
103
|
+
(f"({model.model_type.value}) {name}", name) for name, model in models_dict.items()
|
|
104
|
+
if isinstance(model, m.QueryModel) and model.model_type in valid_model_types
|
|
105
|
+
])
|
|
106
|
+
if runtime_names:
|
|
107
|
+
model_answer = inquirer.prompt([
|
|
108
|
+
inquirer.List(
|
|
109
|
+
'selected_model',
|
|
110
|
+
message='Pick a runtime model to compile',
|
|
111
|
+
choices=runtime_names,
|
|
112
|
+
)
|
|
113
|
+
]) or {}
|
|
114
|
+
selected_model = model_answer['selected_model']
|
|
115
|
+
|
|
116
|
+
# Tips and equivalent command without prompts
|
|
117
|
+
def _maybe_quote(val: str) -> str:
|
|
118
|
+
return f'"{val}"' if any(ch.isspace() for ch in val) else val
|
|
119
|
+
|
|
120
|
+
parts = ["sqrl", "compile", "-y"]
|
|
121
|
+
if buildtime_only:
|
|
122
|
+
parts.append("--buildtime-only")
|
|
123
|
+
elif runtime_only:
|
|
124
|
+
parts.append("--runtime-only")
|
|
125
|
+
if do_all_test_sets:
|
|
126
|
+
parts.append("-T")
|
|
127
|
+
elif test_set:
|
|
128
|
+
parts.extend(["-t", _maybe_quote(test_set)])
|
|
129
|
+
if selected_model:
|
|
130
|
+
parts.extend(["-s", _maybe_quote(selected_model)])
|
|
131
|
+
|
|
132
|
+
# Pretty tips block
|
|
133
|
+
tips_header = " Compile tips "
|
|
134
|
+
border = "=" * 80
|
|
135
|
+
print(border)
|
|
136
|
+
print(tips_header)
|
|
137
|
+
print("-" * len(border))
|
|
138
|
+
print("Equivalent command (no prompts):")
|
|
139
|
+
print(f" $ {' '.join(parts)}")
|
|
140
|
+
print()
|
|
141
|
+
print("You can also:")
|
|
142
|
+
print(" - Add -c/--clear to clear the 'target/compile/' folder before compiling")
|
|
143
|
+
print(" - Add -r/--runquery to generate CSVs for runtime models")
|
|
144
|
+
print(border)
|
|
145
|
+
print()
|
|
146
|
+
|
|
147
|
+
return buildtime_only, runtime_only, test_set, do_all_test_sets, selected_model
|
squirrels/_connection_set.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
from dataclasses import dataclass, field
|
|
3
3
|
from sqlalchemy import Engine
|
|
4
|
-
import time, polars as pl
|
|
4
|
+
import time, polars as pl, duckdb
|
|
5
5
|
|
|
6
6
|
from . import _utils as u, _constants as c, _py_module as pm
|
|
7
7
|
from ._arguments.init_time_args import ConnectionsArgs
|
|
@@ -38,6 +38,13 @@ class ConnectionSet:
|
|
|
38
38
|
elif isinstance(conn, ConnectionProperties) and conn.type == ConnectionTypeEnum.SQLALCHEMY:
|
|
39
39
|
with conn.engine.connect() as connection:
|
|
40
40
|
df = pl.read_database(query, connection, execute_options={"parameters": placeholders})
|
|
41
|
+
elif isinstance(conn, ConnectionProperties) and conn.type == ConnectionTypeEnum.DUCKDB:
|
|
42
|
+
path = conn.uri # .replace("duckdb://", "")
|
|
43
|
+
dd_conn = duckdb.connect(path)
|
|
44
|
+
try:
|
|
45
|
+
df = dd_conn.sql(query, params=placeholders).pl()
|
|
46
|
+
finally:
|
|
47
|
+
dd_conn.close()
|
|
41
48
|
else:
|
|
42
49
|
df = pl.read_database(query, conn, execute_options={"parameters": placeholders}) # type: ignore
|
|
43
50
|
return df
|
|
@@ -83,7 +90,9 @@ class ConnectionSetIO:
|
|
|
83
90
|
connections: dict[str, ConnectionProperties | Any] = {}
|
|
84
91
|
|
|
85
92
|
for config in manifest_cfg.connections.values():
|
|
86
|
-
connections[config.name] = ConnectionProperties(
|
|
93
|
+
connections[config.name] = ConnectionProperties(
|
|
94
|
+
label=config.label, type=config.type, uri=config.uri, sa_create_engine_args=config.sa_create_engine_args
|
|
95
|
+
)
|
|
87
96
|
|
|
88
97
|
pm.run_pyconfig_main(base_path, c.CONNECTIONS_FILE, {"connections": connections, "sqrl": conn_args})
|
|
89
98
|
|
squirrels/_constants.py
CHANGED
|
@@ -17,21 +17,32 @@ SQRL_AUTH_CREDENTIAL_ORIGINS = 'SQRL_AUTH__ALLOWED_ORIGINS_FOR_COOKIES'
|
|
|
17
17
|
|
|
18
18
|
SQRL_PARAMETERS_CACHE_SIZE = 'SQRL_PARAMETERS__CACHE_SIZE'
|
|
19
19
|
SQRL_PARAMETERS_CACHE_TTL_MINUTES = 'SQRL_PARAMETERS__CACHE_TTL_MINUTES'
|
|
20
|
+
SQRL_PARAMETERS_DATASOURCE_REFRESH_MINUTES = 'SQRL_PARAMETERS__DATASOURCE_REFRESH_MINUTES'
|
|
20
21
|
|
|
21
22
|
SQRL_DATASETS_CACHE_SIZE = 'SQRL_DATASETS__CACHE_SIZE'
|
|
22
23
|
SQRL_DATASETS_CACHE_TTL_MINUTES = 'SQRL_DATASETS__CACHE_TTL_MINUTES'
|
|
24
|
+
SQRL_DATASETS_MAX_ROWS_FOR_AI = 'SQRL_DATASETS__MAX_ROWS_FOR_AI'
|
|
23
25
|
|
|
24
26
|
SQRL_DASHBOARDS_CACHE_SIZE = 'SQRL_DASHBOARDS__CACHE_SIZE'
|
|
25
27
|
SQRL_DASHBOARDS_CACHE_TTL_MINUTES = 'SQRL_DASHBOARDS__CACHE_TTL_MINUTES'
|
|
26
28
|
|
|
29
|
+
SQRL_PERMISSIONS_ELEVATED_ACCESS_LEVEL = 'SQRL_PERMISSIONS__ELEVATED_ACCESS_LEVEL'
|
|
30
|
+
|
|
27
31
|
SQRL_SEEDS_INFER_SCHEMA = 'SQRL_SEEDS__INFER_SCHEMA'
|
|
28
32
|
SQRL_SEEDS_NA_VALUES = 'SQRL_SEEDS__NA_VALUES'
|
|
29
33
|
|
|
30
|
-
SQRL_TEST_SETS_DEFAULT_NAME_USED = 'SQRL_TEST_SETS__DEFAULT_NAME_USED'
|
|
31
|
-
|
|
32
34
|
SQRL_CONNECTIONS_DEFAULT_NAME_USED = 'SQRL_CONNECTIONS__DEFAULT_NAME_USED'
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
SQRL_VDL_CATALOG_DB_PATH = 'SQRL_VDL__CATALOG_DB_PATH'
|
|
37
|
+
SQRL_VDL_DATA_PATH = 'SQRL_VDL__DATA_PATH'
|
|
38
|
+
|
|
39
|
+
SQRL_STUDIO_BASE_URL = 'SQRL_STUDIO__BASE_URL'
|
|
40
|
+
|
|
41
|
+
SQRL_LOGGING_LOG_LEVEL = 'SQRL_LOGGING__LOG_LEVEL'
|
|
42
|
+
SQRL_LOGGING_LOG_FORMAT = 'SQRL_LOGGING__LOG_FORMAT'
|
|
43
|
+
SQRL_LOGGING_LOG_TO_FILE = 'SQRL_LOGGING__LOG_TO_FILE'
|
|
44
|
+
SQRL_LOGGING_LOG_FILE_SIZE_MB = 'SQRL_LOGGING__LOG_FILE_SIZE_MB'
|
|
45
|
+
SQRL_LOGGING_LOG_FILE_BACKUP_COUNT = 'SQRL_LOGGING__LOG_FILE_BACKUP_COUNT'
|
|
35
46
|
|
|
36
47
|
# Folder/File names
|
|
37
48
|
PACKAGE_DATA_FOLDER = '_package_data'
|
|
@@ -53,6 +64,7 @@ LOGS_FILE = 'squirrels.log'
|
|
|
53
64
|
|
|
54
65
|
DATABASE_FOLDER = 'assets'
|
|
55
66
|
PACKAGES_FOLDER = 'sqrl_packages'
|
|
67
|
+
PUBLIC_FOLDER = 'public'
|
|
56
68
|
|
|
57
69
|
MACROS_FOLDER = 'macros'
|
|
58
70
|
MACROS_FILE = 'macros_example.sql'
|
|
@@ -78,17 +90,19 @@ USER_FILE = 'user.py'
|
|
|
78
90
|
ADMIN_USERNAME = 'admin'
|
|
79
91
|
|
|
80
92
|
TARGET_FOLDER = 'target'
|
|
81
|
-
DB_FILE = 'auth.sqlite'
|
|
82
93
|
COMPILE_FOLDER = 'compile'
|
|
83
|
-
|
|
94
|
+
COMPILE_BUILDTIME_FOLDER = 'buildtime'
|
|
95
|
+
COMPILE_RUNTIME_FOLDER = 'runtime'
|
|
96
|
+
DB_FILE = 'auth.sqlite'
|
|
97
|
+
DEFAULT_VDL_CATALOG_DB_PATH = 'ducklake:{project_path}/target/vdl_catalog.duckdb'
|
|
98
|
+
DEFAULT_VDL_DATA_PATH = '{project_path}/target/vdl_data/'
|
|
84
99
|
|
|
85
100
|
SEEDS_FOLDER = 'seeds'
|
|
86
101
|
SEED_CATEGORY_FILE_STEM = 'seed_categories'
|
|
87
102
|
SEED_SUBCATEGORY_FILE_STEM = 'seed_subcategories'
|
|
88
103
|
|
|
89
|
-
#
|
|
90
|
-
|
|
91
|
-
PARAMETERS_SECTION = 'parameters'
|
|
104
|
+
# Test sets
|
|
105
|
+
DEFAULT_TEST_SET_NAME = 'default'
|
|
92
106
|
|
|
93
107
|
# Init Command Choices
|
|
94
108
|
SQL_FILE_TYPE = 'sql'
|