sibi-dst 0.3.43__tar.gz → 0.3.45__tar.gz

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.
Files changed (62) hide show
  1. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/PKG-INFO +1 -1
  2. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/pyproject.toml +1 -1
  3. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/_parquet_artifact.py +25 -1
  4. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/django/_load_from_db.py +1 -0
  5. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/parquet/_filter_handler.py +2 -1
  6. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/parquet/_parquet_options.py +2 -3
  7. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/sqlalchemy/_io_dask.py +2 -5
  8. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/core/_filter_handler.py +2 -1
  9. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/log_utils.py +6 -0
  10. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/README.md +0 -0
  11. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/__init__.py +0 -0
  12. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/__init__.py +0 -0
  13. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/_artifact_updater_multi_wrapper.py +0 -0
  14. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/_df_helper.py +0 -0
  15. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/_parquet_reader.py +0 -0
  16. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/__init__.py +0 -0
  17. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/django/__init__.py +0 -0
  18. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/django/_db_connection.py +0 -0
  19. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/django/_io_dask.py +0 -0
  20. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/django/_sql_model_builder.py +0 -0
  21. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/http/__init__.py +0 -0
  22. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/http/_http_config.py +0 -0
  23. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/parquet/__init__.py +0 -0
  24. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/sqlalchemy/__init__.py +0 -0
  25. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/sqlalchemy/_db_connection.py +0 -0
  26. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/sqlalchemy/_filter_handler.py +0 -0
  27. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/sqlalchemy/_load_from_db.py +0 -0
  28. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/backends/sqlalchemy/_sql_model_builder.py +0 -0
  29. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/core/__init__.py +0 -0
  30. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/core/_defaults.py +0 -0
  31. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/core/_params_config.py +0 -0
  32. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/core/_query_config.py +0 -0
  33. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/df_helper/data_cleaner.py +0 -0
  34. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/geopy_helper/__init__.py +0 -0
  35. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/geopy_helper/geo_location_service.py +0 -0
  36. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/geopy_helper/utils.py +0 -0
  37. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/osmnx_helper/__init__.py +0 -0
  38. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/osmnx_helper/v1/__init__.py +0 -0
  39. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/osmnx_helper/v1/base_osm_map.py +0 -0
  40. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/osmnx_helper/v1/basemaps/__init__.py +0 -0
  41. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/osmnx_helper/v1/basemaps/calendar_html.py +0 -0
  42. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/osmnx_helper/v1/basemaps/router_plotter.py +0 -0
  43. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/osmnx_helper/v1/utils.py +0 -0
  44. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/osmnx_helper/v2/__init__.py +0 -0
  45. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/osmnx_helper/v2/base_osm_map.py +0 -0
  46. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/osmnx_helper/v2/basemaps/__init__.py +0 -0
  47. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/osmnx_helper/v2/basemaps/utils.py +0 -0
  48. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/tests/__init__.py +0 -0
  49. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/tests/test_data_wrapper_class.py +0 -0
  50. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/__init__.py +0 -0
  51. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/airflow_manager.py +0 -0
  52. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/clickhouse_writer.py +0 -0
  53. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/credentials.py +0 -0
  54. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/data_utils.py +0 -0
  55. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/data_wrapper.py +0 -0
  56. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/date_utils.py +0 -0
  57. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/df_utils.py +0 -0
  58. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/file_utils.py +0 -0
  59. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/filepath_generator.py +0 -0
  60. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/parquet_saver.py +0 -0
  61. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/phone_formatter.py +0 -0
  62. {sibi_dst-0.3.43 → sibi_dst-0.3.45}/sibi_dst/utils/storage_manager.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sibi-dst
3
- Version: 0.3.43
3
+ Version: 0.3.45
4
4
  Summary: Data Science Toolkit
5
5
  Author: Luis Valverde
6
6
  Author-email: lvalverdeb@gmail.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "sibi-dst"
3
- version = "0.3.43"
3
+ version = "0.3.45"
4
4
  description = "Data Science Toolkit"
5
5
  authors = ["Luis Valverde <lvalverdeb@gmail.com>"]
6
6
  readme = "README.md"
@@ -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
- kwargs.update(self.parse_parquet_period(period=period))
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
- #self.fs = fsspec.filesystem("file") if "://" not in str(self.parquet_storage_path) else fsspec.filesystem(
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):
@@ -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.
File without changes