sibi-dst 0.3.43__py3-none-any.whl → 0.3.45__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.
- sibi_dst/df_helper/_parquet_artifact.py +25 -1
- sibi_dst/df_helper/backends/django/_load_from_db.py +1 -0
- sibi_dst/df_helper/backends/parquet/_filter_handler.py +2 -1
- sibi_dst/df_helper/backends/parquet/_parquet_options.py +2 -3
- sibi_dst/df_helper/backends/sqlalchemy/_io_dask.py +2 -5
- sibi_dst/df_helper/core/_filter_handler.py +2 -1
- sibi_dst/utils/log_utils.py +6 -0
- {sibi_dst-0.3.43.dist-info → sibi_dst-0.3.45.dist-info}/METADATA +1 -1
- {sibi_dst-0.3.43.dist-info → sibi_dst-0.3.45.dist-info}/RECORD +10 -10
- {sibi_dst-0.3.43.dist-info → sibi_dst-0.3.45.dist-info}/WHEEL +0 -0
@@ -1,3 +1,4 @@
|
|
1
|
+
import datetime
|
1
2
|
import logging
|
2
3
|
from typing import Optional, Any, Dict
|
3
4
|
|
@@ -136,7 +137,30 @@ class ParquetArtifact(DfHelper):
|
|
136
137
|
|
137
138
|
def update_parquet(self, period: str = 'today', **kwargs) -> None:
|
138
139
|
"""Update the Parquet file with data from a specific period."""
|
139
|
-
|
140
|
+
|
141
|
+
def itd_config():
|
142
|
+
try:
|
143
|
+
start_date = kwargs.pop('history_begins_on')
|
144
|
+
except KeyError:
|
145
|
+
raise ValueError("For period 'itd', you must provide 'history_begins_on' in kwargs.")
|
146
|
+
return {'parquet_start_date': start_date, 'parquet_end_date': datetime.date.today().strftime('%Y-%m-%d')}
|
147
|
+
|
148
|
+
def ytd_config():
|
149
|
+
return {
|
150
|
+
'parquet_start_date': datetime.date(datetime.date.today().year, 1, 1).strftime('%Y-%m-%d'),
|
151
|
+
'parquet_end_date': datetime.date.today().strftime('%Y-%m-%d')
|
152
|
+
}
|
153
|
+
|
154
|
+
config_map = {
|
155
|
+
'itd': itd_config,
|
156
|
+
'ytd': ytd_config
|
157
|
+
}
|
158
|
+
|
159
|
+
if period in config_map:
|
160
|
+
kwargs.update(config_map[period]())
|
161
|
+
else:
|
162
|
+
kwargs.update(self.parse_parquet_period(period=period))
|
163
|
+
self.logger.debug(f"kwargs passed to update parquet: {kwargs}")
|
140
164
|
self.generate_parquet(**kwargs)
|
141
165
|
|
142
166
|
def rebuild_parquet(self, **kwargs) -> None:
|
@@ -64,6 +64,7 @@ class DjangoLoadFromDb:
|
|
64
64
|
self.connection_config = db_connection
|
65
65
|
self.debug = kwargs.pop('debug', False)
|
66
66
|
self.logger = logger or Logger.default_logger(logger_name=self.__class__.__name__)
|
67
|
+
self.logger.set_level(Logger.DEBUG if self.debug else Logger.INFO)
|
67
68
|
if self.connection_config.model is None:
|
68
69
|
if self.debug:
|
69
70
|
self.logger.debug('Model must be specified')
|
@@ -17,8 +17,9 @@ class ParquetFilterHandler(object):
|
|
17
17
|
:ivar logger: Logger object to handle logging within the class. Defaults to the class-level logger.
|
18
18
|
:type logger: Logger
|
19
19
|
"""
|
20
|
-
def __init__(self, logger=None):
|
20
|
+
def __init__(self, logger=None, debug=False):
|
21
21
|
self.logger = logger or Logger.default_logger(logger_name=self.__class__.__name__)
|
22
|
+
self.logger.set_level(Logger.DEBUG if debug else Logger.INFO)
|
22
23
|
|
23
24
|
@staticmethod
|
24
25
|
def apply_filters_dask(df, filters):
|
@@ -62,6 +62,7 @@ class ParquetConfig(BaseModel):
|
|
62
62
|
parquet_end_date: Optional[str] = None
|
63
63
|
fs: Optional[fsspec.spec.AbstractFileSystem] = None # Your fsspec filesystem object
|
64
64
|
logger: Optional[Logger] = None
|
65
|
+
debug: bool = False
|
65
66
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
66
67
|
|
67
68
|
@model_validator(mode='after')
|
@@ -83,9 +84,7 @@ class ParquetConfig(BaseModel):
|
|
83
84
|
# Configure paths based on fsspec
|
84
85
|
if self.logger is None:
|
85
86
|
self.logger = Logger.default_logger(logger_name=self.__class__.__name__)
|
86
|
-
|
87
|
-
# str(self.parquet_storage_path).split("://")[0])
|
88
|
-
# Validation for parquet path
|
87
|
+
self.logger.set_level(Logger.DEBUG if self.debug else Logger.INFO)
|
89
88
|
|
90
89
|
|
91
90
|
if self.parquet_storage_path is None:
|
@@ -29,6 +29,7 @@ class SQLAlchemyDask:
|
|
29
29
|
self.engine = create_engine(engine_url)
|
30
30
|
self.Session = sessionmaker(bind=self.engine)
|
31
31
|
self.logger = logger or Logger.default_logger(logger_name=self.__class__.__name__)
|
32
|
+
self.logger.set_level(logger.DEBUG if debug else logger.INFO)
|
32
33
|
|
33
34
|
@staticmethod
|
34
35
|
def infer_dtypes_from_model(model):
|
@@ -70,11 +71,7 @@ class SQLAlchemyDask:
|
|
70
71
|
# Build query
|
71
72
|
self.query = select(self.model)
|
72
73
|
if self.filters:
|
73
|
-
""
|
74
|
-
deprecated specific filter handling to a generic one
|
75
|
-
#self.query = SqlAlchemyFilterHandler.apply_filters_sqlalchemy(self.query, self.model, self.filters)
|
76
|
-
"""
|
77
|
-
self.query = FilterHandler(backend="sqlalchemy", logger=self.logger).apply_filters(self.query,
|
74
|
+
self.query = FilterHandler(backend="sqlalchemy", logger=self.logger, debug=self.debug).apply_filters(self.query,
|
78
75
|
model=self.model,
|
79
76
|
filters=self.filters)
|
80
77
|
else:
|
@@ -25,7 +25,7 @@ class FilterHandler:
|
|
25
25
|
:ivar backend_methods: A dictionary mapping backend-specific methods for column retrieval and operation application.
|
26
26
|
:type backend_methods: dict
|
27
27
|
"""
|
28
|
-
def __init__(self, backend, logger=None):
|
28
|
+
def __init__(self, backend, logger=None, debug=False):
|
29
29
|
"""
|
30
30
|
Initialize the FilterHandler.
|
31
31
|
|
@@ -36,6 +36,7 @@ class FilterHandler:
|
|
36
36
|
self.backend = backend
|
37
37
|
self.logger = logger or Logger.default_logger(
|
38
38
|
logger_name=self.__class__.__name__) # No-op logger if none provided
|
39
|
+
self.logger.set_level(Logger.DEBUG if debug else Logger.INFO)
|
39
40
|
self.backend_methods = self._get_backend_methods(backend)
|
40
41
|
|
41
42
|
def apply_filters(self, query_or_df, model=None, filters=None):
|
sibi_dst/utils/log_utils.py
CHANGED
@@ -26,6 +26,12 @@ class Logger:
|
|
26
26
|
:type logger: logging.Logger
|
27
27
|
"""
|
28
28
|
|
29
|
+
DEBUG = logging.DEBUG
|
30
|
+
INFO = logging.INFO
|
31
|
+
WARNING = logging.WARNING
|
32
|
+
ERROR = logging.ERROR
|
33
|
+
CRITICAL = logging.CRITICAL
|
34
|
+
|
29
35
|
def __init__(self, log_dir: str, logger_name: str, log_file: str, log_level: int = logging.DEBUG):
|
30
36
|
"""
|
31
37
|
Initialize the Logger instance.
|
@@ -2,28 +2,28 @@ sibi_dst/__init__.py,sha256=CLHfzrFNqklNx5uMKAPtbZfkbBbVYR5qsiMro0RTfmA,252
|
|
2
2
|
sibi_dst/df_helper/__init__.py,sha256=A-f5cCBy949HHxgiPt0T4MG3qdLAnDpGOpRvP-2dXWc,400
|
3
3
|
sibi_dst/df_helper/_artifact_updater_multi_wrapper.py,sha256=toH2QvNF-CQNJ4Bc8xreytuWr37G0EWz4ciWVdFMVqU,11646
|
4
4
|
sibi_dst/df_helper/_df_helper.py,sha256=IS1m9r9U-eJ7EVMBqmITmre6S0JfIl6nJtPIwNI3xKY,29771
|
5
|
-
sibi_dst/df_helper/_parquet_artifact.py,sha256
|
5
|
+
sibi_dst/df_helper/_parquet_artifact.py,sha256=qt3WZXrE2EZs3KI0biGzm3znIZazzTh8fgiipCVr_Ic,10196
|
6
6
|
sibi_dst/df_helper/_parquet_reader.py,sha256=L6mr2FeKtTeIn37G9EGpvOx8PwMqXb6qnEECqBaiwxo,3954
|
7
7
|
sibi_dst/df_helper/backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
8
|
sibi_dst/df_helper/backends/django/__init__.py,sha256=uWHi-DtQX5re7b2HcqoXUH3_FZWOw1VTmDf552FAkNs,256
|
9
9
|
sibi_dst/df_helper/backends/django/_db_connection.py,sha256=AGbqCnmiX4toMaFPE5ne5h7QCkImjnBKvzGtUD6Ge8Q,3698
|
10
10
|
sibi_dst/df_helper/backends/django/_io_dask.py,sha256=NjvJg6y9qKKCRiNrJL4f_A03iKDKEcjCi7LGbr9DgtM,19555
|
11
|
-
sibi_dst/df_helper/backends/django/_load_from_db.py,sha256=
|
11
|
+
sibi_dst/df_helper/backends/django/_load_from_db.py,sha256=htG9ec4ix371ClEHQVpx4r3mhBdQaSykeHUCCRhN7L4,10637
|
12
12
|
sibi_dst/df_helper/backends/django/_sql_model_builder.py,sha256=at9J7ecGkZbOOYba85uofe9C-ic4wwOqVgJcHpQNiYQ,21449
|
13
13
|
sibi_dst/df_helper/backends/http/__init__.py,sha256=d1pfgYxbiYg7E0Iw8RbJ7xfqIfJShqqTBQQGU_S6OOo,105
|
14
14
|
sibi_dst/df_helper/backends/http/_http_config.py,sha256=eGPFdqZ5M3Tscqx2P93B6XoBEEzlmdt7yNg7PXUQnNQ,4726
|
15
15
|
sibi_dst/df_helper/backends/parquet/__init__.py,sha256=esWJ9aSuYC26d-T01z9dPrJ1uqJzvdaPNTYRb5qXTlQ,182
|
16
|
-
sibi_dst/df_helper/backends/parquet/_filter_handler.py,sha256=
|
17
|
-
sibi_dst/df_helper/backends/parquet/_parquet_options.py,sha256=
|
16
|
+
sibi_dst/df_helper/backends/parquet/_filter_handler.py,sha256=TvDf0RXta7mwJv11GNQttYJsXgFf2XDj4oLIjt4xTzA,5219
|
17
|
+
sibi_dst/df_helper/backends/parquet/_parquet_options.py,sha256=TaU5_wG1Y3lQC8DVCItVvMnc6ZJmECLu3avssVEMbaM,10591
|
18
18
|
sibi_dst/df_helper/backends/sqlalchemy/__init__.py,sha256=TuVp8Ce49dCIIxtyrtFGRblarQUl8QGcS-TDZd515IE,348
|
19
19
|
sibi_dst/df_helper/backends/sqlalchemy/_db_connection.py,sha256=Kli83IEg5SFVqkhsK4w45cV6PbZnfdGanfsyiW6Xw00,2502
|
20
20
|
sibi_dst/df_helper/backends/sqlalchemy/_filter_handler.py,sha256=58RCda1Hg_nsuJw-2V36IstsT8O84IQFgsdE7FnqvMk,4655
|
21
|
-
sibi_dst/df_helper/backends/sqlalchemy/_io_dask.py,sha256=
|
21
|
+
sibi_dst/df_helper/backends/sqlalchemy/_io_dask.py,sha256=BtiRSYA4kFIM-mBCdrwE20vzByfq8_Biv_jPLUCDv58,5466
|
22
22
|
sibi_dst/df_helper/backends/sqlalchemy/_load_from_db.py,sha256=I2Us3RrxHci561yyZYBuUCrLVOhB0F3KBnae78m_ARw,6259
|
23
23
|
sibi_dst/df_helper/backends/sqlalchemy/_sql_model_builder.py,sha256=9oOOGrqAj9yL0FNWR1Fm9PdN7GoFi03ktCOyMjxAKLY,8402
|
24
24
|
sibi_dst/df_helper/core/__init__.py,sha256=o4zDwgVmaijde3oix0ezb6KLxI5QFy-SGUhFTDVFLT4,569
|
25
25
|
sibi_dst/df_helper/core/_defaults.py,sha256=eNpHD2sZxir-2xO0b3_V16ryw8YP_5FfpIKK0HNuiN4,7011
|
26
|
-
sibi_dst/df_helper/core/_filter_handler.py,sha256=
|
26
|
+
sibi_dst/df_helper/core/_filter_handler.py,sha256=Pmbzygry2mpkNPVS7DBMulHpAb1yYZNFqUU0bJTWJF0,11214
|
27
27
|
sibi_dst/df_helper/core/_params_config.py,sha256=DYx2drDz3uF-lSPzizPkchhy-kxRrQKE5FQRxcEWsac,6736
|
28
28
|
sibi_dst/df_helper/core/_query_config.py,sha256=Y8LVSyaKuVkrPluRDkQoOwuXHQxner1pFWG3HPfnDHM,441
|
29
29
|
sibi_dst/df_helper/data_cleaner.py,sha256=lkxQoXLvGzXCicFUimnA5nen5qkrO1oxgl_p2Be2o8w,5183
|
@@ -53,10 +53,10 @@ sibi_dst/utils/date_utils.py,sha256=QSsL_O9ZqIdNjhppyiVOjCFLmhJEKH6F2TeiGBZe9m4,
|
|
53
53
|
sibi_dst/utils/df_utils.py,sha256=GAX0lthULTmGaDvYzuLmo0op7YKaCM5uot403QpztoM,11278
|
54
54
|
sibi_dst/utils/file_utils.py,sha256=JpsybYj3XvVJisSBeVU6YSaZnYRm4_6YWTI3TLnnY4Y,1257
|
55
55
|
sibi_dst/utils/filepath_generator.py,sha256=volVm0SSlBrtZp1RpTHxyui5rj5asNcVsWEBRY5FOUQ,6673
|
56
|
-
sibi_dst/utils/log_utils.py,sha256=
|
56
|
+
sibi_dst/utils/log_utils.py,sha256=eSAbi_jmMpJ8RpycakzT4S4zNkqVZDj3FY8WwnxpdXc,4623
|
57
57
|
sibi_dst/utils/parquet_saver.py,sha256=_BFeD0HDXceBaBR0Y48t9MR_fY9G1Y8HrZCkj2X1yJs,8173
|
58
58
|
sibi_dst/utils/phone_formatter.py,sha256=tsVTDamuthFYgy4-5UwmQkPQ-FGTGH7MjZyH8utAkIY,4945
|
59
59
|
sibi_dst/utils/storage_manager.py,sha256=H_itUFJv9nP0BfXYYQDsw4RzB0YWfgVOAHNWAiMpZ_w,4443
|
60
|
-
sibi_dst-0.3.
|
61
|
-
sibi_dst-0.3.
|
62
|
-
sibi_dst-0.3.
|
60
|
+
sibi_dst-0.3.45.dist-info/METADATA,sha256=rH9MmLHB02ZhPVAs7gG5iYn6KvAnZMLHiIQeYYv6Rrg,6514
|
61
|
+
sibi_dst-0.3.45.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
62
|
+
sibi_dst-0.3.45.dist-info/RECORD,,
|
File without changes
|