luxorasap 0.2.6__py3-none-any.whl → 0.2.8__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.
luxorasap/__init__.py CHANGED
@@ -13,7 +13,7 @@ from types import ModuleType
13
13
  try:
14
14
  __version__: str = metadata.version(__name__)
15
15
  except metadata.PackageNotFoundError: # editable install
16
- __version__ = "0.2.6"
16
+ __version__ = "0.2.8"
17
17
 
18
18
  # ─── Lazy loader ─────────────────────────────────────────────────
19
19
  def __getattr__(name: str) -> ModuleType:
@@ -4,9 +4,9 @@ from importlib import import_module
4
4
  from warnings import warn
5
5
 
6
6
  # API moderna (recomendada)
7
- from .cloud import save_table, incremental_load # noqa: F401
7
+ from .cloud import save_table, incremental_load, TableDataLoader # noqa: F401
8
8
 
9
- __all__ = ["save_table", "incremental_load"]
9
+ __all__ = ["save_table", "incremental_load", "TableDataLoader"]
10
10
 
11
11
  # Ponte para o loader antigo -------------------------------------------------
12
12
  try:
@@ -7,6 +7,8 @@ import numpy as np
7
7
  from luxorasap.utils.storage import BlobParquetClient, BlobExcelClient, BlobPickleClient
8
8
  from luxorasap.utils.dataframe import prep_for_save, astype_str_inplace
9
9
  from luxorasap.datareader import LuxorQuery
10
+ from luxorasap.utils.storage import BlobChangeWatcher
11
+
10
12
 
11
13
 
12
14
  __all__ = ["save_table", "incremental_load"]
@@ -86,7 +88,7 @@ def incremental_load(
86
88
  df["Last_Updated"] = dt.datetime.now()
87
89
 
88
90
  if lq.table_exists(table_name):
89
- prev = lq.get_table(table_name)
91
+ prev = lq.get_table(table_name, drop_last_updated_columns=False)
90
92
  if increment_column is not None:
91
93
  if increment_column not in df.columns:
92
94
  raise ValueError(f"Coluna de incremento '{increment_column}' não existe no DataFrame.")
@@ -106,4 +108,58 @@ def incremental_load(
106
108
  normalize_columns=normalize_columns,
107
109
  directory=directory,
108
110
  override=True
109
- )
111
+ )
112
+
113
+
114
+ class TableDataLoader:
115
+
116
+ def __init__(self, update_func: callable, kwargs: dict = {}, adls_connection_string: str = None ):
117
+ """
118
+ Controla o carregamento de tabelas baseado em mudanças de arquivos no ADLS.
119
+ Args:
120
+ update_func (callable): Funcao que sera chamada para atualizar a tabela.
121
+ kwargs (dict): Dicionario com os argumentos para a funcao de update.
122
+ luxordb_path (Path, optional): Caminho para o diretorio raiz do luxorDB.
123
+ Defaults to None.
124
+ """
125
+ self.tracked_files = {}
126
+ self.adls_connection_string = adls_connection_string
127
+ self.update_func = update_func
128
+ self.kwargs = kwargs
129
+
130
+
131
+ def add_load_trigger(self, directory: str, trigger_name: str):
132
+ """ Adiciona tabela na lista para controle de alteracao.
133
+ O load sera disparado quando essa tabela for atualizada.
134
+ Args:
135
+ table_path (Path): Path para a tabela que ira disparar a atualizacao.
136
+ """
137
+
138
+ blob_watcher = BlobChangeWatcher(watcher_id=trigger_name,
139
+ adls_connection_string=self.adls_connection_string)
140
+ self.tracked_files[directory] = blob_watcher
141
+
142
+
143
+ def table_load_triggered(self) -> bool:
144
+ """Verifica se alguma das trigger tables foi atualizada."""
145
+
146
+ load_triggered = False
147
+ # Verificando se alguma das tabelas foi atualizada
148
+ for trigger_path in self.tracked_files.keys():
149
+ blob_watcher = self.tracked_files[trigger_path]
150
+ file_updated, _, _ = blob_watcher.has_changed(blob_path = trigger_path,
151
+ update_snapshot=True,
152
+ treat_missing_as_changed=True
153
+ )
154
+ if file_updated:
155
+ load_triggered = True #load_triggered | True
156
+
157
+ return load_triggered
158
+
159
+
160
+ def load_table(self):
161
+ """Carrega a tabela via funcao de atualização.
162
+ Args:
163
+ kwargs (dict): Dicionario com os argumentos para a funcao de update.
164
+ """
165
+ self.update_func(**self.kwargs)
@@ -292,3 +292,57 @@ class BlobChangeWatcher:
292
292
  self._save_snapshot()
293
293
 
294
294
  return changed_paths
295
+
296
+
297
+ class TableDataLoader:
298
+
299
+ def __init__(self, update_func: callable, kwargs: dict = {}, adls_connection_string: str = None ):
300
+ """
301
+ Controla o carregamento de tabelas baseado em mudanças de arquivos no ADLS.
302
+ Args:
303
+ update_func (callable): Funcao que sera chamada para atualizar a tabela.
304
+ kwargs (dict): Dicionario com os argumentos para a funcao de update.
305
+ luxordb_path (Path, optional): Caminho para o diretorio raiz do luxorDB.
306
+ Defaults to None.
307
+ """
308
+ self.tracked_files = {}
309
+ self.adls_connection_string = adls_connection_string
310
+ self.update_func = update_func
311
+ self.kwargs = kwargs
312
+
313
+
314
+ def add_load_trigger(self, directory: str, trigger_name: str):
315
+ """ Adiciona tabela na lista para controle de alteracao.
316
+ O load sera disparado quando essa tabela for atualizada.
317
+ Args:
318
+ table_path (Path): Path para a tabela que ira disparar a atualizacao.
319
+ """
320
+
321
+ blob_watcher = BlobChangeWatcher(watcher_id=trigger_name,
322
+ adls_connection_string=self.adls_connection_string)
323
+ self.tracked_files[directory] = blob_watcher
324
+
325
+
326
+ def table_load_triggered(self) -> bool:
327
+ """Verifica se alguma das trigger tables foi atualizada."""
328
+
329
+ load_triggered = False
330
+ # Verificando se alguma das tabelas foi atualizada
331
+ for trigger_path in self.tracked_files.keys():
332
+ blob_watcher = self.tracked_files[trigger_path]
333
+ file_updated, _, _ = blob_watcher.has_changed(blob_path = trigger_path,
334
+ update_snapshot=True,
335
+ treat_missing_as_changed=True
336
+ )
337
+ if file_updated:
338
+ load_triggered = True #load_triggered | True
339
+
340
+ return load_triggered
341
+
342
+
343
+ def load_table(self):
344
+ """Carrega a tabela no luxorDB.
345
+ Args:
346
+ kwargs (dict): Dicionario com os argumentos para a funcao de update.
347
+ """
348
+ self.update_func(**self.kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: luxorasap
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
4
  Summary: Toolbox da Luxor para ingestão, análise e automação de dados financeiros.
5
5
  Author-email: Luxor Group <backoffice@luxor.com.br>
6
6
  License: Proprietary – All rights reserved
@@ -1,12 +1,12 @@
1
- luxorasap/__init__.py,sha256=A7wqTrV36UVWM5aelydu8otx8kwkNkDoWweCS8kc6Wo,1355
1
+ luxorasap/__init__.py,sha256=rXkCotxvChyTQ7BUA0jKYHl3xS_6uscTgEUWY6jn5VE,1355
2
2
  luxorasap/btgapi/__init__.py,sha256=QUlfb5oiBY6K1Q5x4-a-x2wECe1At5wc2962I5odOJk,620
3
3
  luxorasap/btgapi/auth.py,sha256=PvyCtbEyBO2B1CIeAlNXWugKW1OgiKfPcVzS6K5FBnQ,1872
4
4
  luxorasap/btgapi/reports.py,sha256=ZVEMLoJPXc0r3XjPJPMsKQN0zZd1Npd7umNpAj1bncs,8040
5
5
  luxorasap/btgapi/trades.py,sha256=956HZ9BvN9C_VQvKTyBLN0x6ZygwVqBZN11F7OnNbDI,5985
6
6
  luxorasap/datareader/__init__.py,sha256=41RAvbrQ4R6oj67S32CrKqolx0CJ2W8cbOF6g5Cqm2g,120
7
7
  luxorasap/datareader/core.py,sha256=6yVxOHTVuauWWIL1s_-cuFfpJjVCRXlzUjg4VIVIQ94,157771
8
- luxorasap/ingest/__init__.py,sha256=XhxDTN2ar-u6UCPhnxNU_to-nWiit-SpQ6cA_N9eMSs,795
9
- luxorasap/ingest/cloud/__init__.py,sha256=HRKLjxqa-COssAPoFrjfOlE_dkvTDcv5tyDhmqcdYOI,3690
8
+ luxorasap/ingest/__init__.py,sha256=gHkw8FU8TuRL5tfHkACxwsLHwLYX8SgX9xHkB8uTjww,831
9
+ luxorasap/ingest/cloud/__init__.py,sha256=F4VQLU2h7z1fwOhoBVM5W-8b3aABjYeyj6UsmpmtWD0,6059
10
10
  luxorasap/ingest/legacy_local/dataloader.py,sha256=DF3CvojDAi0itVDZPsQbmpl5pqMTNwOOpxTz4Ju8mho,12419
11
11
  luxorasap/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  luxorasap/utils/dataframe/__init__.py,sha256=heKpmq58FmX35syzzwrHqlOWKYBkH2Z1jyqaQ_Vg-00,265
@@ -14,11 +14,11 @@ luxorasap/utils/dataframe/reader.py,sha256=Vzjdw-AeS1lnWEHQ8RZNh0kK93NWTp0NWVi_B
14
14
  luxorasap/utils/dataframe/transforms.py,sha256=OIvlTTcjFX6bUhuQp_syEp7ssm4sLzwvgsag6n2Wl3k,2438
15
15
  luxorasap/utils/storage/__init__.py,sha256=461GYJcPMXGjHuJ9y9D3BHOC_oUS9Re32nVu1AwKyIA,334
16
16
  luxorasap/utils/storage/blob.py,sha256=vgCKMOiVgP-V1A2xZRhG3kJhPFU-LA9E9kddOQTxYD8,9443
17
- luxorasap/utils/storage/change_tracker.py,sha256=5URYI18mymcVfUyyb9zi8NeNDVrdYgdOAs8L58GwL5Q,11706
17
+ luxorasap/utils/storage/change_tracker.py,sha256=u0oQxqnc63AQXWJ2_FS-R3Nu4olhOgwsnJVwpxwRAn4,13962
18
18
  luxorasap/utils/tools/__init__.py,sha256=dvK7Z4xnNQAuEiObVN7qjeLWAvP49JeFn2Oq9GdgmXs,76
19
19
  luxorasap/utils/tools/excel.py,sha256=SfeTcbJWsWq3uKruwKSjJ4aWgMovITzlNXjP2bhdMjI,1246
20
- luxorasap-0.2.6.dist-info/METADATA,sha256=L5u-6QarNcsqsNLb9NeRNs6_89Ehf6tIOe1PboKubNQ,3803
21
- luxorasap-0.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
- luxorasap-0.2.6.dist-info/entry_points.txt,sha256=XFh-dOwUhlya9DmGvgookMI0ezyUJjcOvTIHDEYS44g,52
23
- luxorasap-0.2.6.dist-info/top_level.txt,sha256=9YOL6bUIpzY06XFBRkUW1e4rgB32Ds91fQPGwUEjxzU,10
24
- luxorasap-0.2.6.dist-info/RECORD,,
20
+ luxorasap-0.2.8.dist-info/METADATA,sha256=eEw_aU1ok4OirGqqWNy-V5vTlu5k5R-_Ypc08SviZN0,3803
21
+ luxorasap-0.2.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ luxorasap-0.2.8.dist-info/entry_points.txt,sha256=XFh-dOwUhlya9DmGvgookMI0ezyUJjcOvTIHDEYS44g,52
23
+ luxorasap-0.2.8.dist-info/top_level.txt,sha256=9YOL6bUIpzY06XFBRkUW1e4rgB32Ds91fQPGwUEjxzU,10
24
+ luxorasap-0.2.8.dist-info/RECORD,,