sibi-dst 0.3.44__py3-none-any.whl → 0.3.46__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.
Files changed (84) hide show
  1. sibi_dst/__init__.py +38 -0
  2. sibi_dst/{df_helper → v1/df_helper}/_artifact_updater_multi_wrapper.py +1 -1
  3. sibi_dst/{df_helper → v1/df_helper}/_df_helper.py +3 -3
  4. sibi_dst/{df_helper → v1/df_helper}/_parquet_artifact.py +3 -3
  5. sibi_dst/{df_helper → v1/df_helper}/_parquet_reader.py +2 -2
  6. sibi_dst/{df_helper → v1/df_helper}/backends/django/_load_from_db.py +3 -3
  7. sibi_dst/{df_helper → v1/df_helper}/backends/http/_http_config.py +1 -1
  8. sibi_dst/{df_helper → v1/df_helper}/backends/parquet/_filter_handler.py +1 -1
  9. sibi_dst/{df_helper → v1/df_helper}/backends/parquet/_parquet_options.py +2 -2
  10. sibi_dst/{df_helper → v1/df_helper}/backends/sqlalchemy/_io_dask.py +2 -2
  11. sibi_dst/{df_helper → v1/df_helper}/backends/sqlalchemy/_load_from_db.py +2 -2
  12. sibi_dst/{df_helper → v1/df_helper}/backends/sqlalchemy/_sql_model_builder.py +2 -1
  13. sibi_dst/{df_helper → v1/df_helper}/core/_filter_handler.py +1 -1
  14. sibi_dst/v1/osmnx_helper/__init__.py +6 -0
  15. sibi_dst/{tests → v1/tests}/test_data_wrapper_class.py +11 -10
  16. sibi_dst/{utils → v1/utils}/__init__.py +2 -0
  17. sibi_dst/{utils → v1/utils}/clickhouse_writer.py +1 -1
  18. sibi_dst/v1/utils/data_from_http_source.py +49 -0
  19. sibi_dst/{utils → v1/utils}/data_utils.py +5 -3
  20. sibi_dst/{utils → v1/utils}/data_wrapper.py +3 -1
  21. sibi_dst/{utils → v1/utils}/date_utils.py +1 -1
  22. sibi_dst/{utils → v1/utils}/file_utils.py +1 -1
  23. sibi_dst/{utils → v1/utils}/filepath_generator.py +1 -1
  24. sibi_dst/{utils → v1/utils}/parquet_saver.py +1 -1
  25. sibi_dst/v1/utils/storage_config.py +28 -0
  26. sibi_dst/v2/df_helper/__init__.py +7 -0
  27. sibi_dst/v2/df_helper/_df_helper.py +214 -0
  28. sibi_dst/v2/df_helper/backends/sqlalchemy/__init__.py +10 -0
  29. sibi_dst/v2/df_helper/backends/sqlalchemy/_db_connection.py +82 -0
  30. sibi_dst/v2/df_helper/backends/sqlalchemy/_io_dask.py +135 -0
  31. sibi_dst/v2/df_helper/backends/sqlalchemy/_load_from_db.py +142 -0
  32. sibi_dst/v2/df_helper/backends/sqlalchemy/_model_builder.py +297 -0
  33. sibi_dst/v2/df_helper/backends/sqlmodel/__init__.py +9 -0
  34. sibi_dst/v2/df_helper/backends/sqlmodel/_db_connection.py +78 -0
  35. sibi_dst/v2/df_helper/backends/sqlmodel/_io_dask.py +122 -0
  36. sibi_dst/v2/df_helper/backends/sqlmodel/_load_from_db.py +142 -0
  37. sibi_dst/v2/df_helper/backends/sqlmodel/_model_builder.py +283 -0
  38. sibi_dst/v2/df_helper/core/__init__.py +9 -0
  39. sibi_dst/v2/df_helper/core/_filter_handler.py +236 -0
  40. sibi_dst/v2/df_helper/core/_params_config.py +139 -0
  41. sibi_dst/v2/df_helper/core/_query_config.py +17 -0
  42. sibi_dst/v2/utils/__init__.py +5 -0
  43. sibi_dst/v2/utils/log_utils.py +120 -0
  44. {sibi_dst-0.3.44.dist-info → sibi_dst-0.3.46.dist-info}/METADATA +3 -2
  45. sibi_dst-0.3.46.dist-info/RECORD +80 -0
  46. sibi_dst/osmnx_helper/__init__.py +0 -9
  47. sibi_dst/osmnx_helper/v2/base_osm_map.py +0 -153
  48. sibi_dst/osmnx_helper/v2/basemaps/utils.py +0 -0
  49. sibi_dst-0.3.44.dist-info/RECORD +0 -62
  50. /sibi_dst/{df_helper/backends → v1}/__init__.py +0 -0
  51. /sibi_dst/{df_helper → v1/df_helper}/__init__.py +0 -0
  52. /sibi_dst/{osmnx_helper/v1 → v1/df_helper/backends}/__init__.py +0 -0
  53. /sibi_dst/{df_helper → v1/df_helper}/backends/django/__init__.py +0 -0
  54. /sibi_dst/{df_helper → v1/df_helper}/backends/django/_db_connection.py +0 -0
  55. /sibi_dst/{df_helper → v1/df_helper}/backends/django/_io_dask.py +0 -0
  56. /sibi_dst/{df_helper → v1/df_helper}/backends/django/_sql_model_builder.py +0 -0
  57. /sibi_dst/{df_helper → v1/df_helper}/backends/http/__init__.py +0 -0
  58. /sibi_dst/{df_helper → v1/df_helper}/backends/parquet/__init__.py +0 -0
  59. /sibi_dst/{df_helper → v1/df_helper}/backends/sqlalchemy/__init__.py +0 -0
  60. /sibi_dst/{df_helper → v1/df_helper}/backends/sqlalchemy/_db_connection.py +0 -0
  61. /sibi_dst/{df_helper → v1/df_helper}/backends/sqlalchemy/_filter_handler.py +0 -0
  62. /sibi_dst/{df_helper → v1/df_helper}/core/__init__.py +0 -0
  63. /sibi_dst/{df_helper → v1/df_helper}/core/_defaults.py +0 -0
  64. /sibi_dst/{df_helper → v1/df_helper}/core/_params_config.py +0 -0
  65. /sibi_dst/{df_helper → v1/df_helper}/core/_query_config.py +0 -0
  66. /sibi_dst/{df_helper → v1/df_helper}/data_cleaner.py +0 -0
  67. /sibi_dst/{geopy_helper → v1/geopy_helper}/__init__.py +0 -0
  68. /sibi_dst/{geopy_helper → v1/geopy_helper}/geo_location_service.py +0 -0
  69. /sibi_dst/{geopy_helper → v1/geopy_helper}/utils.py +0 -0
  70. /sibi_dst/{osmnx_helper/v1 → v1/osmnx_helper}/base_osm_map.py +0 -0
  71. /sibi_dst/{osmnx_helper/v1 → v1/osmnx_helper}/basemaps/__init__.py +0 -0
  72. /sibi_dst/{osmnx_helper/v1 → v1/osmnx_helper}/basemaps/calendar_html.py +0 -0
  73. /sibi_dst/{osmnx_helper/v1 → v1/osmnx_helper}/basemaps/router_plotter.py +0 -0
  74. /sibi_dst/{osmnx_helper/v1 → v1/osmnx_helper}/utils.py +0 -0
  75. /sibi_dst/{osmnx_helper/v2 → v1/tests}/__init__.py +0 -0
  76. /sibi_dst/{utils → v1/utils}/airflow_manager.py +0 -0
  77. /sibi_dst/{utils → v1/utils}/credentials.py +0 -0
  78. /sibi_dst/{utils → v1/utils}/df_utils.py +0 -0
  79. /sibi_dst/{utils → v1/utils}/log_utils.py +0 -0
  80. /sibi_dst/{utils → v1/utils}/phone_formatter.py +0 -0
  81. /sibi_dst/{utils → v1/utils}/storage_manager.py +0 -0
  82. /sibi_dst/{osmnx_helper/v2/basemaps → v2}/__init__.py +0 -0
  83. /sibi_dst/{tests → v2/df_helper/backends}/__init__.py +0 -0
  84. {sibi_dst-0.3.44.dist-info → sibi_dst-0.3.46.dist-info}/WHEEL +0 -0
@@ -0,0 +1,17 @@
1
+ from typing import Optional
2
+
3
+ from pydantic import BaseModel, model_validator
4
+
5
+
6
+ class QueryConfig(BaseModel):
7
+ use_exclude: bool = False
8
+ n_records: int = 100
9
+ dt_field: Optional[str] = None
10
+ use_dask: bool = False
11
+ as_dask: bool = False
12
+
13
+ @model_validator(mode='after')
14
+ def check_n_records(self):
15
+ if self.n_records < 0:
16
+ raise ValueError('Number of records must be non-negative')
17
+ return self
@@ -0,0 +1,5 @@
1
+ from .log_utils import Logger
2
+
3
+ __all__ = [
4
+ "Logger",
5
+ ]
@@ -0,0 +1,120 @@
1
+ import logging
2
+ import os
3
+ import sys
4
+ import time
5
+ from typing import Optional
6
+
7
+ class Logger:
8
+ """
9
+ Handles the creation, setup, and management of logging functionalities.
10
+ """
11
+ DEBUG = logging.DEBUG
12
+ INFO = logging.INFO
13
+ WARNING = logging.WARNING
14
+ ERROR = logging.ERROR
15
+ CRITICAL = logging.CRITICAL
16
+
17
+ def __init__(self, log_dir: str, logger_name: str, log_file: str, debug: bool = False):
18
+ """
19
+ Initialize the Logger instance.
20
+ :param log_dir: Directory where logs are stored.
21
+ :param logger_name: Name of the logger instance.
22
+ :param log_file: Base name of the log file.
23
+ :param debug: Whether to enable debug mode (defaults to False).
24
+ """
25
+ self.log_dir = log_dir
26
+ self.logger_name = logger_name
27
+ self.log_file = log_file
28
+ self.debug_mode = debug # Add a debug flag
29
+ self.logger = None
30
+ self._setup()
31
+
32
+ def _setup(self):
33
+ """Set up the logger with file and console handlers."""
34
+ # Ensure the log directory exists
35
+ os.makedirs(self.log_dir, exist_ok=True)
36
+
37
+ # Get the name of the calling script
38
+ calling_script = os.path.splitext(os.path.basename(sys.argv[0]))[0]
39
+
40
+ # Create a log file path
41
+ log_file_path = os.path.join(self.log_dir, f"{self.log_file}_{calling_script}.log")
42
+
43
+ # Delete the existing log file if it exists
44
+ if os.path.exists(log_file_path):
45
+ os.remove(log_file_path)
46
+
47
+ # Create a logger
48
+ self.logger = logging.getLogger(self.logger_name)
49
+ self.logger.setLevel(self._get_log_level()) # Dynamically set the log level
50
+
51
+ # Create a formatter
52
+ formatter = logging.Formatter(
53
+ '[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s',
54
+ datefmt='%Y-%m-%d %H:%M:%S'
55
+ )
56
+ formatter.converter = time.localtime # Set local time explicitly
57
+
58
+ # Create a file handler
59
+ file_handler = logging.FileHandler(log_file_path)
60
+ file_handler.setFormatter(formatter)
61
+ self.logger.addHandler(file_handler)
62
+
63
+ # Create a console handler (optional)
64
+ console_handler = logging.StreamHandler()
65
+ console_handler.setFormatter(formatter)
66
+ self.logger.addHandler(console_handler)
67
+
68
+ def _get_log_level(self) -> int:
69
+ """
70
+ Determine the logging level based on the debug flag.
71
+ :return: Logging level (DEBUG if debug is True, otherwise INFO).
72
+ """
73
+ return logging.DEBUG if self.debug_mode else logging.INFO
74
+
75
+ @classmethod
76
+ def default_logger(
77
+ cls,
78
+ log_dir: str = './logs/',
79
+ logger_name: Optional[str] = None,
80
+ log_file: Optional[str] = None,
81
+ debug: bool = False
82
+ ) -> 'Logger':
83
+ """
84
+ Class-level method to create a default logger with generic parameters.
85
+ :param log_dir: Directory where logs are stored (defaults to './logs/').
86
+ :param logger_name: Name of the logger (defaults to __name__).
87
+ :param log_file: Name of the log file (defaults to logger_name).
88
+ :param debug: Whether to enable debug mode (defaults to False).
89
+ :return: Instance of Logger.
90
+ """
91
+ logger_name = logger_name or __name__
92
+ log_file = log_file or logger_name
93
+ return cls(log_dir=log_dir, logger_name=logger_name, log_file=log_file, debug=debug)
94
+
95
+ def set_level(self, level: int):
96
+ """
97
+ Set the logging level for the logger.
98
+ :param level: Logging level (e.g., logging.DEBUG, logging.INFO).
99
+ """
100
+ self.logger.setLevel(level)
101
+
102
+ def debug(self, msg: str):
103
+ """Log a debug message."""
104
+ self.logger.debug(msg)
105
+
106
+ def info(self, msg: str):
107
+ """Log an info message."""
108
+ self.logger.info(msg)
109
+
110
+ def warning(self, msg: str):
111
+ """Log a warning message."""
112
+ self.logger.warning(msg)
113
+
114
+ def error(self, msg: str):
115
+ """Log an error message."""
116
+ self.logger.error(msg)
117
+
118
+ def critical(self, msg: str):
119
+ """Log a critical message."""
120
+ self.logger.critical(msg)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sibi-dst
3
- Version: 0.3.44
3
+ Version: 0.3.46
4
4
  Summary: Data Science Toolkit
5
5
  Author: Luis Valverde
6
6
  Author-email: lvalverdeb@gmail.com
@@ -14,12 +14,12 @@ Requires-Dist: chardet (>=5.2.0,<6.0.0)
14
14
  Requires-Dist: charset-normalizer (>=3.4.0,<4.0.0)
15
15
  Requires-Dist: clickhouse-connect (>=0.8.7,<0.9.0)
16
16
  Requires-Dist: clickhouse-driver (>=0.2.9,<0.3.0)
17
- Requires-Dist: dask-expr (>=1.1.20,<2.0.0)
18
17
  Requires-Dist: dask[complete] (>=2024.11.1,<2025.0.0)
19
18
  Requires-Dist: django (>=5.1.4,<6.0.0)
20
19
  Requires-Dist: djangorestframework (>=3.15.2,<4.0.0)
21
20
  Requires-Dist: folium (>=0.19.4,<0.20.0)
22
21
  Requires-Dist: geopandas (>=1.0.1,<2.0.0)
22
+ Requires-Dist: geopy (>=2.4.1,<3.0.0)
23
23
  Requires-Dist: gunicorn (>=23.0.0,<24.0.0)
24
24
  Requires-Dist: httpx (>=0.27.2,<0.28.0)
25
25
  Requires-Dist: ipython (>=8.29.0,<9.0.0)
@@ -40,6 +40,7 @@ Requires-Dist: pytest-mock (>=3.14.0,<4.0.0)
40
40
  Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
41
41
  Requires-Dist: s3fs (>=2024.12.0,<2025.0.0)
42
42
  Requires-Dist: sqlalchemy (>=2.0.36,<3.0.0)
43
+ Requires-Dist: sqlmodel (>=0.0.22,<0.0.23)
43
44
  Requires-Dist: tornado (>=6.4.1,<7.0.0)
44
45
  Requires-Dist: tqdm (>=4.67.0,<5.0.0)
45
46
  Requires-Dist: uvicorn (>=0.34.0,<0.35.0)
@@ -0,0 +1,80 @@
1
+ sibi_dst/__init__.py,sha256=uwF7KQ9TjongYh3qIA36hSSjR85TVJKuZI0WUPqLYJg,1576
2
+ sibi_dst/v1/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ sibi_dst/v1/df_helper/__init__.py,sha256=A-f5cCBy949HHxgiPt0T4MG3qdLAnDpGOpRvP-2dXWc,400
4
+ sibi_dst/v1/df_helper/_artifact_updater_multi_wrapper.py,sha256=Ghfee9dELU8CGUMdWeZxyThSFZMd6jTGKednLrRKh4U,11649
5
+ sibi_dst/v1/df_helper/_df_helper.py,sha256=veist8sExgeOT3Xpjp5L9n3djQdQoG435oPQx-NluF8,29780
6
+ sibi_dst/v1/df_helper/_parquet_artifact.py,sha256=HOgfANd3ivGBCHf63q8UN-75NWyo0Tr7fzRqfeVKB3I,10202
7
+ sibi_dst/v1/df_helper/_parquet_reader.py,sha256=fmSepQmxjWp59gbecAd_ThMC68gDnKMaAUeciVRVpQY,3960
8
+ sibi_dst/v1/df_helper/backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ sibi_dst/v1/df_helper/backends/django/__init__.py,sha256=uWHi-DtQX5re7b2HcqoXUH3_FZWOw1VTmDf552FAkNs,256
10
+ sibi_dst/v1/df_helper/backends/django/_db_connection.py,sha256=AGbqCnmiX4toMaFPE5ne5h7QCkImjnBKvzGtUD6Ge8Q,3698
11
+ sibi_dst/v1/df_helper/backends/django/_io_dask.py,sha256=NjvJg6y9qKKCRiNrJL4f_A03iKDKEcjCi7LGbr9DgtM,19555
12
+ sibi_dst/v1/df_helper/backends/django/_load_from_db.py,sha256=Htr4jDYB6MQQqQyJKOiqv9AfheUXlL4XzOlL3-wFBeY,10646
13
+ sibi_dst/v1/df_helper/backends/django/_sql_model_builder.py,sha256=at9J7ecGkZbOOYba85uofe9C-ic4wwOqVgJcHpQNiYQ,21449
14
+ sibi_dst/v1/df_helper/backends/http/__init__.py,sha256=d1pfgYxbiYg7E0Iw8RbJ7xfqIfJShqqTBQQGU_S6OOo,105
15
+ sibi_dst/v1/df_helper/backends/http/_http_config.py,sha256=YFpduRY-00dNwGJwFuHleGyp5mP56IfPdhSY_kTJ6O0,4729
16
+ sibi_dst/v1/df_helper/backends/parquet/__init__.py,sha256=esWJ9aSuYC26d-T01z9dPrJ1uqJzvdaPNTYRb5qXTlQ,182
17
+ sibi_dst/v1/df_helper/backends/parquet/_filter_handler.py,sha256=hBhrMLHFIOoVWEVyc6Jyp_XTopg6u7i3s0FhmVpISyI,5222
18
+ sibi_dst/v1/df_helper/backends/parquet/_parquet_options.py,sha256=yueBidL07wYr6EMZCERHqX0FPTZCGBHaZD6AXFcclCo,10597
19
+ sibi_dst/v1/df_helper/backends/sqlalchemy/__init__.py,sha256=TuVp8Ce49dCIIxtyrtFGRblarQUl8QGcS-TDZd515IE,348
20
+ sibi_dst/v1/df_helper/backends/sqlalchemy/_db_connection.py,sha256=Kli83IEg5SFVqkhsK4w45cV6PbZnfdGanfsyiW6Xw00,2502
21
+ sibi_dst/v1/df_helper/backends/sqlalchemy/_filter_handler.py,sha256=58RCda1Hg_nsuJw-2V36IstsT8O84IQFgsdE7FnqvMk,4655
22
+ sibi_dst/v1/df_helper/backends/sqlalchemy/_io_dask.py,sha256=FvsNYb__wmT-D8pZYEwfrq6uPJihi77AfEAinkuGiwo,5472
23
+ sibi_dst/v1/df_helper/backends/sqlalchemy/_load_from_db.py,sha256=PFA22DF3avh2jPEt6uqN16jpxRwPZIzs_E5qMjcdw9M,6265
24
+ sibi_dst/v1/df_helper/backends/sqlalchemy/_sql_model_builder.py,sha256=ksvJ0EvktrVsoJ9DTMIQHzHe8ghw2mzDIBD_YgWytgw,8402
25
+ sibi_dst/v1/df_helper/core/__init__.py,sha256=o4zDwgVmaijde3oix0ezb6KLxI5QFy-SGUhFTDVFLT4,569
26
+ sibi_dst/v1/df_helper/core/_defaults.py,sha256=eNpHD2sZxir-2xO0b3_V16ryw8YP_5FfpIKK0HNuiN4,7011
27
+ sibi_dst/v1/df_helper/core/_filter_handler.py,sha256=TLUSEiGudCTmOv5htAFi-RQtXXU367Wk6cqLKVSbT-U,11217
28
+ sibi_dst/v1/df_helper/core/_params_config.py,sha256=DYx2drDz3uF-lSPzizPkchhy-kxRrQKE5FQRxcEWsac,6736
29
+ sibi_dst/v1/df_helper/core/_query_config.py,sha256=Y8LVSyaKuVkrPluRDkQoOwuXHQxner1pFWG3HPfnDHM,441
30
+ sibi_dst/v1/df_helper/data_cleaner.py,sha256=lkxQoXLvGzXCicFUimnA5nen5qkrO1oxgl_p2Be2o8w,5183
31
+ sibi_dst/v1/geopy_helper/__init__.py,sha256=Q1RJiUZIOlV0QNNLjxZ_2IZS5LqIe5jRbeQkfD1Vm60,112
32
+ sibi_dst/v1/geopy_helper/geo_location_service.py,sha256=1ArI980QF_gRw096ZsABHwJt-m55jrfOlB8tPwL1BvY,2959
33
+ sibi_dst/v1/geopy_helper/utils.py,sha256=Sb7qfSqIyWh-AZ4GBdB9-z5FrQPWtrdtQLLcNjph0yw,3351
34
+ sibi_dst/v1/osmnx_helper/__init__.py,sha256=eHM2XenOdI-Rc1deeUCVoT_OidtPJRMcveKenqxzCJM,116
35
+ sibi_dst/v1/osmnx_helper/base_osm_map.py,sha256=L7g3VBiayHX41BcCBTOCS0iJOKzp2ZZYcrp8N-mnU90,19392
36
+ sibi_dst/v1/osmnx_helper/basemaps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ sibi_dst/v1/osmnx_helper/basemaps/calendar_html.py,sha256=UArt6FDgoCgoRte45Xo3IHqd-RNzW0YgitgZYfOFasY,4031
38
+ sibi_dst/v1/osmnx_helper/basemaps/router_plotter.py,sha256=SWdDz5XGDSHT6Iyr-EIatSNTvGPR3AVDJ5TTcWm0w4g,10947
39
+ sibi_dst/v1/osmnx_helper/utils.py,sha256=BzuY8CtYnBAAO8UAr_M7EOk6CP1zcifNLs8pkdFZEFg,20577
40
+ sibi_dst/v1/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
+ sibi_dst/v1/tests/test_data_wrapper_class.py,sha256=hCSZ0aubhWNlu2pBV8jG56UsSHhnjQ6hHLdN4Q4YLTw,3342
42
+ sibi_dst/v1/utils/__init__.py,sha256=QE4ZRfLWdsjMYJIxznjJlPoLneK8RPPf9gIh6aEhxkY,938
43
+ sibi_dst/v1/utils/airflow_manager.py,sha256=-d44EKUZNYJyp4wuNwRvilRQktunArPOB5fZuWdQv10,7526
44
+ sibi_dst/v1/utils/clickhouse_writer.py,sha256=JE_WMsnLTlxoABIDLuvrDUVHkTidlev8gSC4krDag3M,9879
45
+ sibi_dst/v1/utils/credentials.py,sha256=cHJPPsmVyijqbUQIq7WWPe-lIallA-mI5RAy3YUuRME,1724
46
+ sibi_dst/v1/utils/data_from_http_source.py,sha256=AcpKNsqTgN2ClNwuhgUpuNCx62r5_DdsAiKY8vcHEBA,1867
47
+ sibi_dst/v1/utils/data_utils.py,sha256=MqbwXk33BuANWeKKmsabHouhb8GZswSmbM-VetWWE-M,10357
48
+ sibi_dst/v1/utils/data_wrapper.py,sha256=pIIQxeHknUeQd0YbISkAhL-xYBK4OdijoATBY-oBznw,12114
49
+ sibi_dst/v1/utils/date_utils.py,sha256=7cqgC6WEcfkh6BKTgq-kyig4H9rf_0VzpySPYElSo_0,18359
50
+ sibi_dst/v1/utils/df_utils.py,sha256=GAX0lthULTmGaDvYzuLmo0op7YKaCM5uot403QpztoM,11278
51
+ sibi_dst/v1/utils/file_utils.py,sha256=Z99CZ_4nPDIaZqbCfzzUDfAYJjSudWDj-mwEO8grhbc,1253
52
+ sibi_dst/v1/utils/filepath_generator.py,sha256=-HHO0U-PR8fysDDFwnWdHRlgqksh_RkmgBZLWv9hM7s,6669
53
+ sibi_dst/v1/utils/log_utils.py,sha256=eSAbi_jmMpJ8RpycakzT4S4zNkqVZDj3FY8WwnxpdXc,4623
54
+ sibi_dst/v1/utils/parquet_saver.py,sha256=Tucxv9jRX66VuLQZn0dPQBN7JOttBou6SF8FxqufeGE,8169
55
+ sibi_dst/v1/utils/phone_formatter.py,sha256=tsVTDamuthFYgy4-5UwmQkPQ-FGTGH7MjZyH8utAkIY,4945
56
+ sibi_dst/v1/utils/storage_config.py,sha256=ugM70OHo63dN7LPukl0FZTWwXKBuoCILFh3RdNEeMgY,1239
57
+ sibi_dst/v1/utils/storage_manager.py,sha256=H_itUFJv9nP0BfXYYQDsw4RzB0YWfgVOAHNWAiMpZ_w,4443
58
+ sibi_dst/v2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
+ sibi_dst/v2/df_helper/__init__.py,sha256=XuH6jKYAPg2DdRbsxxBSxp9X3x-ARyaT0xe27uILrVo,99
60
+ sibi_dst/v2/df_helper/_df_helper.py,sha256=9pED3bjQ2Z81zqzJrZ9e7SguoO4-hBmNTJK4WOKrr4M,9297
61
+ sibi_dst/v2/df_helper/backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
+ sibi_dst/v2/df_helper/backends/sqlalchemy/__init__.py,sha256=MOEedyWqcb1_RiRYKyyWX0uFNCfBgmyYbTjco8-GBxU,262
63
+ sibi_dst/v2/df_helper/backends/sqlalchemy/_db_connection.py,sha256=8u3jdD0sR2fmm2H75GDdygoqiqDI6-N-azOJsLgUWFA,3189
64
+ sibi_dst/v2/df_helper/backends/sqlalchemy/_io_dask.py,sha256=6V9DruwckEsonYW5YvBY93-NzXYHbTA7OsyMKMYIZEs,5472
65
+ sibi_dst/v2/df_helper/backends/sqlalchemy/_load_from_db.py,sha256=jhgN0OO5Sk1zQFHrMUhJn2F_hHB5g3x3EJ8j5PXNb0U,6295
66
+ sibi_dst/v2/df_helper/backends/sqlalchemy/_model_builder.py,sha256=jX_mQAzl_6xdh7CTYw4uvUIX2wMp3NzXMlfbC5alOzs,13632
67
+ sibi_dst/v2/df_helper/backends/sqlmodel/__init__.py,sha256=LcwJjVVxxrnVZalWqnz5m7r77i9tmJR0-U2k8eSQ-m8,249
68
+ sibi_dst/v2/df_helper/backends/sqlmodel/_db_connection.py,sha256=b5xmxQr4a8fhE4qdCGJrNWjjX1NW5hrPNLmlfP20rIg,2897
69
+ sibi_dst/v2/df_helper/backends/sqlmodel/_io_dask.py,sha256=wVgNPo5V75aLtlZr_SIQ-yteyXq-Rg93eMfR8JCfkSo,5422
70
+ sibi_dst/v2/df_helper/backends/sqlmodel/_load_from_db.py,sha256=FIs6UrNxdJ7eDHDvTv-cJuybIue2-oCRedhW-MNe7CU,6285
71
+ sibi_dst/v2/df_helper/backends/sqlmodel/_model_builder.py,sha256=k0dnMLkLMMvkDYDYWkGFgibW5UD8pJgB3YrEg_R7pj8,13556
72
+ sibi_dst/v2/df_helper/core/__init__.py,sha256=rZhBh32Rgcxj4MBii-KsYVJQmrT9egiWKXk68gWKblo,197
73
+ sibi_dst/v2/df_helper/core/_filter_handler.py,sha256=54jyz7OUigUqwlyl5gzy1d7aJ_oXV3aMORCoqZIf6sY,10100
74
+ sibi_dst/v2/df_helper/core/_params_config.py,sha256=DYx2drDz3uF-lSPzizPkchhy-kxRrQKE5FQRxcEWsac,6736
75
+ sibi_dst/v2/df_helper/core/_query_config.py,sha256=Y8LVSyaKuVkrPluRDkQoOwuXHQxner1pFWG3HPfnDHM,441
76
+ sibi_dst/v2/utils/__init__.py,sha256=6H4cvhqTiFufnFPETBF0f8beVVMpfJfvUs6Ne0TQZNY,58
77
+ sibi_dst/v2/utils/log_utils.py,sha256=rfk5VsLAt-FKpv6aPTC1FToIPiyrnHAFFBAkHme24po,4123
78
+ sibi_dst-0.3.46.dist-info/METADATA,sha256=Z9QXdfU6JmUrcR45dFKItdGtHrcR7UBlC37adJWrz-A,6552
79
+ sibi_dst-0.3.46.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
80
+ sibi_dst-0.3.46.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from .v1.base_osm_map import BaseOsmMap
4
- from .v1.utils import PBFHandler
5
-
6
- __all__ = [
7
- "BaseOsmMap",
8
- "PBFHandler",
9
- ]
@@ -1,153 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import html
4
- from abc import ABC, abstractmethod
5
- from typing import Optional
6
-
7
- import folium
8
- import geopandas as gpd
9
- import numpy as np
10
- import osmnx as ox
11
- import pandas as pd
12
- from folium.plugins import Fullscreen
13
- from networkx import MultiDiGraph
14
-
15
-
16
- class BaseOsmMap(ABC):
17
- # Define available tile options for the map
18
- tile_options = {
19
- "OpenStreetMap": "OpenStreetMap",
20
- "CartoDB": "cartodbpositron",
21
- "CartoDB Voyager": "cartodbvoyager"
22
- }
23
- # Default geographical bounds (Costa Rica)
24
- bounds = [[8.0340, -85.9417], [11.2192, -82.5566]]
25
-
26
- def __init__(
27
- self,
28
- osmnx_graph: MultiDiGraph,
29
- df: pd.DataFrame,
30
- lat_col: str = "latitude",
31
- lon_col: str = "longitude",
32
- map_html_title: str = "OSM Basemap",
33
- zoom_start: int = 13,
34
- fullscreen: bool = True,
35
- fullscreen_position: str = "topright",
36
- tiles: str = "OpenStreetMap",
37
- verbose: bool = False,
38
- sort_keys: Optional[list[str]] = None,
39
- dt_field: Optional[str] = None,
40
- calc_nearest_nodes: bool = False,
41
- max_bounds: bool = False,
42
- ):
43
- if df.empty:
44
- raise ValueError("df must not be empty")
45
-
46
- # Store attributes
47
- self.df = df.copy()
48
- self.osmnx_graph = osmnx_graph
49
- self.lat_col = lat_col
50
- self.lon_col = lon_col
51
- self.map_html_title = self._sanitize_html(map_html_title)
52
- self.zoom_start = zoom_start
53
- self.fullscreen = fullscreen
54
- self.fullscreen_position = fullscreen_position
55
- self.tiles = tiles
56
- self.verbose = verbose
57
- self.sort_keys = sort_keys
58
- self.dt_field = dt_field
59
- self.calc_nearest_nodes = calc_nearest_nodes
60
- self.max_bounds = max_bounds
61
- self.dt = self.df[self.dt_field].to_list() if self.dt_field else None
62
- self.nearest_nodes = None
63
- self.G = None
64
- self.osm_map = None
65
-
66
- self._prepare_df()
67
- self._initialize_map()
68
-
69
- def _prepare_df(self):
70
- """Sort and preprocess the DataFrame."""
71
- if self.sort_keys:
72
- self.df.sort_values(by=self.sort_keys, inplace=True, ignore_index=True)
73
- self.gps_points = self.df[[self.lat_col, self.lon_col]].to_numpy()
74
-
75
- # Compute nearest nodes if required
76
- if self.calc_nearest_nodes and not self.df.empty:
77
- self.nearest_nodes = ox.distance.nearest_nodes(
78
- self.osmnx_graph, X=self.df[self.lon_col], Y=self.df[self.lat_col]
79
- )
80
-
81
- def _initialize_map(self):
82
- """Initialize the folium map centered around the dataset."""
83
- if self.gps_points.size == 0:
84
- raise ValueError("No valid GPS points available for map initialization")
85
-
86
- center = self.gps_points.mean(axis=0).tolist()
87
- if self.osm_map is None:
88
- self.osm_map = folium.Map(
89
- location=center, zoom_start=self.zoom_start, tiles=self.tiles, max_bounds=self.max_bounds
90
- )
91
- self.G = self._extract_subgraph(*self._get_bounding_box_from_points())
92
-
93
- def _get_bounding_box_from_points(self, margin: float = 0.001) -> tuple[float, float, float, float]:
94
- """Compute bounding box for the dataset with margin."""
95
- latitudes, longitudes = self.gps_points[:, 0], self.gps_points[:, 1]
96
- return max(latitudes) + margin, min(latitudes) - margin, max(longitudes) + margin, min(longitudes) - margin
97
-
98
- def _extract_subgraph(self, north: float, south: float, east: float, west: float) -> MultiDiGraph:
99
- """Extract a subgraph from OSM data within the bounding box."""
100
- bbox_poly = gpd.GeoSeries([ox.utils_geo.bbox_to_poly((west, south, east, north))])
101
- nodes_gdf = ox.graph_to_gdfs(self.osmnx_graph, nodes=True, edges=False)
102
- nodes_within_bbox = gpd.sjoin(nodes_gdf, gpd.GeoDataFrame(geometry=bbox_poly), predicate="within")
103
- return self.osmnx_graph.subgraph(nodes_within_bbox.index)
104
-
105
- def _post_process_map(self):
106
- """Perform final adjustments to the map."""
107
- self._attach_supported_tiles()
108
- self.add_tile_layer()
109
- self._add_fullscreen()
110
- self._add_map_title()
111
- if self.max_bounds and self.bounds:
112
- self.osm_map.fit_bounds(self.bounds)
113
-
114
- def _attach_supported_tiles(self):
115
- """Attach additional tile layers to the map."""
116
- for name, tile in self.tile_options.items():
117
- if tile.lower() != self.tiles.lower():
118
- folium.TileLayer(name=name, tiles=tile, show=False).add_to(self.osm_map)
119
-
120
- def _add_fullscreen(self):
121
- """Enable fullscreen control if required."""
122
- if self.fullscreen:
123
- Fullscreen(position=self.fullscreen_position).add_to(self.osm_map)
124
-
125
- def _add_map_title(self):
126
- """Add a title to the map if provided."""
127
- if self.map_html_title:
128
- self.osm_map.get_root().html.add_child(folium.Element(self.map_html_title))
129
-
130
- @staticmethod
131
- def _sanitize_html(input_html: str) -> str:
132
- """Sanitize HTML input to prevent script injection."""
133
- return html.escape(input_html)
134
-
135
- @abstractmethod
136
- def process_map(self):
137
- """Abstract method to define map processing logic in subclasses."""
138
- pass
139
-
140
- def pre_process_map(self):
141
- """Optional preprocessing step before main processing."""
142
- pass
143
-
144
- def add_tile_layer(self):
145
- """Add a layer control to the map."""
146
- folium.LayerControl().add_to(self.osm_map)
147
-
148
- def generate_map(self) -> folium.Map:
149
- """Generate and return the processed map."""
150
- self.pre_process_map()
151
- self.process_map()
152
- self._post_process_map()
153
- return self.osm_map
File without changes
@@ -1,62 +0,0 @@
1
- sibi_dst/__init__.py,sha256=CLHfzrFNqklNx5uMKAPtbZfkbBbVYR5qsiMro0RTfmA,252
2
- sibi_dst/df_helper/__init__.py,sha256=A-f5cCBy949HHxgiPt0T4MG3qdLAnDpGOpRvP-2dXWc,400
3
- sibi_dst/df_helper/_artifact_updater_multi_wrapper.py,sha256=toH2QvNF-CQNJ4Bc8xreytuWr37G0EWz4ciWVdFMVqU,11646
4
- sibi_dst/df_helper/_df_helper.py,sha256=IS1m9r9U-eJ7EVMBqmITmre6S0JfIl6nJtPIwNI3xKY,29771
5
- sibi_dst/df_helper/_parquet_artifact.py,sha256=JjRPMfKKaTEX2-SUIPu1nShZB1Bl52GgPdDF_UHwd9A,10146
6
- sibi_dst/df_helper/_parquet_reader.py,sha256=L6mr2FeKtTeIn37G9EGpvOx8PwMqXb6qnEECqBaiwxo,3954
7
- sibi_dst/df_helper/backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- sibi_dst/df_helper/backends/django/__init__.py,sha256=uWHi-DtQX5re7b2HcqoXUH3_FZWOw1VTmDf552FAkNs,256
9
- sibi_dst/df_helper/backends/django/_db_connection.py,sha256=AGbqCnmiX4toMaFPE5ne5h7QCkImjnBKvzGtUD6Ge8Q,3698
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=htG9ec4ix371ClEHQVpx4r3mhBdQaSykeHUCCRhN7L4,10637
12
- sibi_dst/df_helper/backends/django/_sql_model_builder.py,sha256=at9J7ecGkZbOOYba85uofe9C-ic4wwOqVgJcHpQNiYQ,21449
13
- sibi_dst/df_helper/backends/http/__init__.py,sha256=d1pfgYxbiYg7E0Iw8RbJ7xfqIfJShqqTBQQGU_S6OOo,105
14
- sibi_dst/df_helper/backends/http/_http_config.py,sha256=eGPFdqZ5M3Tscqx2P93B6XoBEEzlmdt7yNg7PXUQnNQ,4726
15
- sibi_dst/df_helper/backends/parquet/__init__.py,sha256=esWJ9aSuYC26d-T01z9dPrJ1uqJzvdaPNTYRb5qXTlQ,182
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
- sibi_dst/df_helper/backends/sqlalchemy/__init__.py,sha256=TuVp8Ce49dCIIxtyrtFGRblarQUl8QGcS-TDZd515IE,348
19
- sibi_dst/df_helper/backends/sqlalchemy/_db_connection.py,sha256=Kli83IEg5SFVqkhsK4w45cV6PbZnfdGanfsyiW6Xw00,2502
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=BtiRSYA4kFIM-mBCdrwE20vzByfq8_Biv_jPLUCDv58,5466
22
- sibi_dst/df_helper/backends/sqlalchemy/_load_from_db.py,sha256=I2Us3RrxHci561yyZYBuUCrLVOhB0F3KBnae78m_ARw,6259
23
- sibi_dst/df_helper/backends/sqlalchemy/_sql_model_builder.py,sha256=9oOOGrqAj9yL0FNWR1Fm9PdN7GoFi03ktCOyMjxAKLY,8402
24
- sibi_dst/df_helper/core/__init__.py,sha256=o4zDwgVmaijde3oix0ezb6KLxI5QFy-SGUhFTDVFLT4,569
25
- sibi_dst/df_helper/core/_defaults.py,sha256=eNpHD2sZxir-2xO0b3_V16ryw8YP_5FfpIKK0HNuiN4,7011
26
- sibi_dst/df_helper/core/_filter_handler.py,sha256=Pmbzygry2mpkNPVS7DBMulHpAb1yYZNFqUU0bJTWJF0,11214
27
- sibi_dst/df_helper/core/_params_config.py,sha256=DYx2drDz3uF-lSPzizPkchhy-kxRrQKE5FQRxcEWsac,6736
28
- sibi_dst/df_helper/core/_query_config.py,sha256=Y8LVSyaKuVkrPluRDkQoOwuXHQxner1pFWG3HPfnDHM,441
29
- sibi_dst/df_helper/data_cleaner.py,sha256=lkxQoXLvGzXCicFUimnA5nen5qkrO1oxgl_p2Be2o8w,5183
30
- sibi_dst/geopy_helper/__init__.py,sha256=Q1RJiUZIOlV0QNNLjxZ_2IZS5LqIe5jRbeQkfD1Vm60,112
31
- sibi_dst/geopy_helper/geo_location_service.py,sha256=1ArI980QF_gRw096ZsABHwJt-m55jrfOlB8tPwL1BvY,2959
32
- sibi_dst/geopy_helper/utils.py,sha256=Sb7qfSqIyWh-AZ4GBdB9-z5FrQPWtrdtQLLcNjph0yw,3351
33
- sibi_dst/osmnx_helper/__init__.py,sha256=8061nkUZ-9HzXuGvJvo1e_I9SJXBy1jXAo4rzk-Y-lU,159
34
- sibi_dst/osmnx_helper/v1/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- sibi_dst/osmnx_helper/v1/base_osm_map.py,sha256=L7g3VBiayHX41BcCBTOCS0iJOKzp2ZZYcrp8N-mnU90,19392
36
- sibi_dst/osmnx_helper/v1/basemaps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
- sibi_dst/osmnx_helper/v1/basemaps/calendar_html.py,sha256=UArt6FDgoCgoRte45Xo3IHqd-RNzW0YgitgZYfOFasY,4031
38
- sibi_dst/osmnx_helper/v1/basemaps/router_plotter.py,sha256=SWdDz5XGDSHT6Iyr-EIatSNTvGPR3AVDJ5TTcWm0w4g,10947
39
- sibi_dst/osmnx_helper/v1/utils.py,sha256=BzuY8CtYnBAAO8UAr_M7EOk6CP1zcifNLs8pkdFZEFg,20577
40
- sibi_dst/osmnx_helper/v2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
- sibi_dst/osmnx_helper/v2/base_osm_map.py,sha256=YotJR-OcsQyx2fEem6TtIyHF1FCRzoqnWBPbZpLgH1k,5797
42
- sibi_dst/osmnx_helper/v2/basemaps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
- sibi_dst/osmnx_helper/v2/basemaps/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
- sibi_dst/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
- sibi_dst/tests/test_data_wrapper_class.py,sha256=Nkup5OFH5Cos2fxPaU7g9IEyINJM0uJ5-rOZ-eNtd20,3275
46
- sibi_dst/utils/__init__.py,sha256=2uX4IQN02NeQzR1RRK3d7AV51XC54wg4ieOM7yTSfDs,875
47
- sibi_dst/utils/airflow_manager.py,sha256=-d44EKUZNYJyp4wuNwRvilRQktunArPOB5fZuWdQv10,7526
48
- sibi_dst/utils/clickhouse_writer.py,sha256=syXGN9NG1FS8soHuMj6QNRqTRWi-thuYUF-_BWDc_KI,9883
49
- sibi_dst/utils/credentials.py,sha256=cHJPPsmVyijqbUQIq7WWPe-lIallA-mI5RAy3YUuRME,1724
50
- sibi_dst/utils/data_utils.py,sha256=w07GStEBK6iz6tENTnhngiu1jpRNdo6dTgqP4iAUsTw,10304
51
- sibi_dst/utils/data_wrapper.py,sha256=Fm-YeFj_utLxN2A91z9Y9q8YMwkAfZNTyYiTbczQ1QY,12069
52
- sibi_dst/utils/date_utils.py,sha256=QSsL_O9ZqIdNjhppyiVOjCFLmhJEKH6F2TeiGBZe9m4,18363
53
- sibi_dst/utils/df_utils.py,sha256=GAX0lthULTmGaDvYzuLmo0op7YKaCM5uot403QpztoM,11278
54
- sibi_dst/utils/file_utils.py,sha256=JpsybYj3XvVJisSBeVU6YSaZnYRm4_6YWTI3TLnnY4Y,1257
55
- sibi_dst/utils/filepath_generator.py,sha256=volVm0SSlBrtZp1RpTHxyui5rj5asNcVsWEBRY5FOUQ,6673
56
- sibi_dst/utils/log_utils.py,sha256=eSAbi_jmMpJ8RpycakzT4S4zNkqVZDj3FY8WwnxpdXc,4623
57
- sibi_dst/utils/parquet_saver.py,sha256=_BFeD0HDXceBaBR0Y48t9MR_fY9G1Y8HrZCkj2X1yJs,8173
58
- sibi_dst/utils/phone_formatter.py,sha256=tsVTDamuthFYgy4-5UwmQkPQ-FGTGH7MjZyH8utAkIY,4945
59
- sibi_dst/utils/storage_manager.py,sha256=H_itUFJv9nP0BfXYYQDsw4RzB0YWfgVOAHNWAiMpZ_w,4443
60
- sibi_dst-0.3.44.dist-info/METADATA,sha256=j8kho4OWGcuSb1u78vZBxJSXugeHd_sipJdyLLPz_p0,6514
61
- sibi_dst-0.3.44.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
62
- sibi_dst-0.3.44.dist-info/RECORD,,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes