squirrels 0.5.0b1__py3-none-any.whl → 0.5.0b3__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.
- 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 +7 -13
- squirrels/_api_server.py +5 -5
- squirrels/{arguments/init_time_args.py → _arguments/_init_time_args.py} +2 -2
- squirrels/{arguments/run_time_args.py → _arguments/_run_time_args.py} +4 -26
- squirrels/_auth.py +2 -2
- squirrels/_command_line.py +13 -9
- squirrels/_connection_set.py +5 -5
- squirrels/_constants.py +1 -1
- squirrels/_dashboard_types.py +82 -0
- squirrels/_dashboards_io.py +2 -2
- squirrels/_data_sources.py +564 -0
- squirrels/_exceptions.py +1 -1
- squirrels/_initializer.py +82 -58
- squirrels/_manifest.py +5 -5
- squirrels/_model_builder.py +2 -0
- squirrels/_model_configs.py +3 -3
- squirrels/_model_queries.py +1 -1
- squirrels/_models.py +28 -14
- squirrels/{package_data → _package_data}/base_project/dashboards/dashboard_example.py +4 -4
- squirrels/{package_data → _package_data}/base_project/dashboards/dashboard_example.yml +2 -2
- 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 → _package_data}/base_project/models/dbviews/dbview_example.sql +1 -1
- squirrels/_package_data/base_project/models/federates/federate_example.py +41 -0
- squirrels/_package_data/base_project/models/federates/federate_example.sql +25 -0
- squirrels/{package_data → _package_data}/base_project/models/federates/federate_example.yml +6 -6
- squirrels/{package_data → _package_data}/base_project/parameters.yml +9 -8
- squirrels/_package_data/base_project/pyconfigs/connections.py +14 -0
- squirrels/{package_data → _package_data}/base_project/pyconfigs/context.py +14 -16
- squirrels/{package_data → _package_data}/base_project/pyconfigs/parameters.py +13 -8
- squirrels/{package_data → _package_data}/base_project/pyconfigs/user.py +2 -2
- squirrels/_parameter_configs.py +34 -34
- squirrels/_parameter_options.py +348 -0
- squirrels/_parameter_sets.py +18 -18
- squirrels/_parameters.py +1266 -0
- squirrels/_project.py +37 -12
- squirrels/_utils.py +5 -3
- squirrels/arguments.py +2 -0
- squirrels/connections.py +1 -0
- squirrels/dashboards.py +1 -82
- squirrels/data_sources.py +8 -563
- squirrels/parameter_options.py +8 -348
- squirrels/parameters.py +9 -1266
- squirrels/types.py +11 -0
- {squirrels-0.5.0b1.dist-info → squirrels-0.5.0b3.dist-info}/METADATA +11 -17
- squirrels-0.5.0b3.dist-info/RECORD +80 -0
- squirrels/package_data/base_project/macros/macros_example.sql +0 -15
- 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-0.5.0b1.dist-info/RECORD +0 -70
- /squirrels/{dataset_result.py → _dataset_types.py} +0 -0
- /squirrels/{package_data → _package_data}/base_project/.env +0 -0
- /squirrels/{package_data → _package_data}/base_project/.env.example +0 -0
- /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/connections.yml +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 → _package_data}/base_project/duckdb_init.sql +0 -0
- /squirrels/{package_data/base_project/.gitignore → _package_data/base_project/gitignore} +0 -0
- /squirrels/{package_data → _package_data}/base_project/models/dbviews/dbview_example.yml +0 -0
- /squirrels/{package_data → _package_data}/base_project/models/sources.yml +0 -0
- /squirrels/{package_data → _package_data}/base_project/seeds/seed_categories.csv +0 -0
- /squirrels/{package_data → _package_data}/base_project/seeds/seed_categories.yml +0 -0
- /squirrels/{package_data → _package_data}/base_project/seeds/seed_subcategories.csv +0 -0
- /squirrels/{package_data → _package_data}/base_project/seeds/seed_subcategories.yml +0 -0
- /squirrels/{package_data → _package_data}/base_project/squirrels.yml.j2 +0 -0
- /squirrels/{package_data → _package_data}/base_project/tmp/.gitignore +0 -0
- {squirrels-0.5.0b1.dist-info → squirrels-0.5.0b3.dist-info}/WHEEL +0 -0
- {squirrels-0.5.0b1.dist-info → squirrels-0.5.0b3.dist-info}/entry_points.txt +0 -0
- {squirrels-0.5.0b1.dist-info → squirrels-0.5.0b3.dist-info}/licenses/LICENSE +0 -0
squirrels/_connection_set.py
CHANGED
|
@@ -4,8 +4,8 @@ from sqlalchemy import Engine
|
|
|
4
4
|
import time, polars as pl
|
|
5
5
|
|
|
6
6
|
from . import _utils as u, _constants as c, _py_module as pm
|
|
7
|
-
from .
|
|
8
|
-
from ._manifest import ManifestConfig, ConnectionProperties,
|
|
7
|
+
from ._arguments._init_time_args import ConnectionsArgs
|
|
8
|
+
from ._manifest import ManifestConfig, ConnectionProperties, ConnectionTypeEnum
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@dataclass
|
|
@@ -31,11 +31,11 @@ class ConnectionSet:
|
|
|
31
31
|
def run_sql_query_from_conn_name(self, query: str, conn_name: str, placeholders: dict = {}) -> pl.DataFrame:
|
|
32
32
|
conn = self.get_connection(conn_name)
|
|
33
33
|
try:
|
|
34
|
-
if isinstance(conn, ConnectionProperties) and (conn.type ==
|
|
34
|
+
if isinstance(conn, ConnectionProperties) and (conn.type == ConnectionTypeEnum.CONNECTORX or conn.type == ConnectionTypeEnum.ADBC):
|
|
35
35
|
if len(placeholders) > 0:
|
|
36
36
|
raise u.ConfigurationError(f"Connection '{conn_name}' is a ConnectorX or ADBC connection, which does not support placeholders")
|
|
37
37
|
df = pl.read_database_uri(query, conn.uri, engine=conn.type.value)
|
|
38
|
-
elif isinstance(conn, ConnectionProperties) and conn.type ==
|
|
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
41
|
else:
|
|
@@ -52,7 +52,7 @@ class ConnectionSet:
|
|
|
52
52
|
if isinstance(conn, Engine):
|
|
53
53
|
conn.dispose()
|
|
54
54
|
elif isinstance(conn, ConnectionProperties):
|
|
55
|
-
if conn.type ==
|
|
55
|
+
if conn.type == ConnectionTypeEnum.SQLALCHEMY:
|
|
56
56
|
conn.engine.dispose()
|
|
57
57
|
elif hasattr(conn, 'close'):
|
|
58
58
|
conn.close()
|
squirrels/_constants.py
CHANGED
|
@@ -33,7 +33,7 @@ SQRL_CONNECTIONS_DEFAULT_NAME_USED = 'SQRL_CONNECTIONS__DEFAULT_NAME_USED'
|
|
|
33
33
|
SQRL_DUCKDB_VENV_DB_FILE_PATH = 'SQRL_DUCKDB_VENV__DB_FILE_PATH'
|
|
34
34
|
|
|
35
35
|
# Folder/File names
|
|
36
|
-
PACKAGE_DATA_FOLDER = '
|
|
36
|
+
PACKAGE_DATA_FOLDER = '_package_data'
|
|
37
37
|
BASE_PROJECT_FOLDER = 'base_project'
|
|
38
38
|
|
|
39
39
|
GLOBAL_ENV_FOLDER = '.squirrels'
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import matplotlib.figure as figure, io, abc, typing
|
|
2
|
+
|
|
3
|
+
from . import _constants as c
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Dashboard(metaclass=abc.ABCMeta):
|
|
7
|
+
"""
|
|
8
|
+
Abstract parent class for all Dashboard classes.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
@property
|
|
12
|
+
@abc.abstractmethod
|
|
13
|
+
def _content(self) -> bytes | str:
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
@abc.abstractmethod
|
|
18
|
+
def _format(self) -> str:
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class PngDashboard(Dashboard):
|
|
23
|
+
"""
|
|
24
|
+
Instantiate a Dashboard in PNG format from a matplotlib figure or bytes
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, content: figure.Figure | io.BytesIO | bytes) -> None:
|
|
28
|
+
"""
|
|
29
|
+
Constructor for PngDashboard
|
|
30
|
+
|
|
31
|
+
Arguments:
|
|
32
|
+
content: The content of the dashboard as a matplotlib.figure.Figure or bytes
|
|
33
|
+
"""
|
|
34
|
+
if isinstance(content, figure.Figure):
|
|
35
|
+
buffer = io.BytesIO()
|
|
36
|
+
content.savefig(buffer, format=c.PNG)
|
|
37
|
+
content = buffer.getvalue()
|
|
38
|
+
|
|
39
|
+
if isinstance(content, io.BytesIO):
|
|
40
|
+
content = content.getvalue()
|
|
41
|
+
|
|
42
|
+
self.__content = content
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def _content(self) -> bytes:
|
|
46
|
+
return self.__content
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def _format(self) -> typing.Literal['png']:
|
|
50
|
+
return c.PNG
|
|
51
|
+
|
|
52
|
+
def _repr_png_(self):
|
|
53
|
+
return self._content
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class HtmlDashboard(Dashboard):
|
|
57
|
+
"""
|
|
58
|
+
Instantiate a Dashboard from an HTML string
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
def __init__(self, content: io.StringIO | str) -> None:
|
|
62
|
+
"""
|
|
63
|
+
Constructor for HtmlDashboard
|
|
64
|
+
|
|
65
|
+
Arguments:
|
|
66
|
+
content: The content of the dashboard as HTML string
|
|
67
|
+
"""
|
|
68
|
+
if isinstance(content, io.StringIO):
|
|
69
|
+
content = content.getvalue()
|
|
70
|
+
|
|
71
|
+
self.__content = content
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def _content(self) -> str:
|
|
75
|
+
return self.__content
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def _format(self) -> typing.Literal['html']:
|
|
79
|
+
return c.HTML
|
|
80
|
+
|
|
81
|
+
def _repr_html_(self):
|
|
82
|
+
return self._content
|
squirrels/_dashboards_io.py
CHANGED
|
@@ -4,11 +4,11 @@ from dataclasses import dataclass
|
|
|
4
4
|
from pydantic import BaseModel, Field
|
|
5
5
|
import os, time
|
|
6
6
|
|
|
7
|
-
from .
|
|
7
|
+
from ._arguments._run_time_args import DashboardArgs
|
|
8
8
|
from ._py_module import PyModule
|
|
9
9
|
from ._manifest import AnalyticsOutputConfig
|
|
10
10
|
from ._exceptions import InvalidInputError, ConfigurationError, FileExecutionError
|
|
11
|
-
from . import _constants as c,
|
|
11
|
+
from . import _constants as c, _dashboard_types as d, _utils as u
|
|
12
12
|
|
|
13
13
|
T = TypeVar('T', bound=d.Dashboard)
|
|
14
14
|
|