sibi-dst 0.3.31__py3-none-any.whl → 0.3.32__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.
@@ -61,6 +61,11 @@ class ParquetArtifact(DfHelper):
61
61
  dw = DataWrapper(self.data_wrapper_class, **params)
62
62
  dw.process()
63
63
 
64
+ def __exit__(self, exc_type, exc_value, traceback):
65
+ # Ensure resources are cleaned up
66
+ if self.fs:
67
+ self.fs.close()
68
+
64
69
  def update_parquet(self, period: str = 'today', **kwargs) -> None:
65
70
  """Update the Parquet file with data from a specific period."""
66
71
  kwargs.update(self.parse_parquet_period(period=period))
@@ -31,7 +31,10 @@ class ParquetReader(DfHelper):
31
31
  # Filesystem setup
32
32
  self.filesystem_type = filesystem_type
33
33
  self.filesystem_options = filesystem_options or {}
34
- self.fs = fsspec.filesystem(self.filesystem_type, **self.filesystem_options)
34
+ self.fs = self.config.setdefault('fs', None)
35
+ if self.fs is None:
36
+ self.fs = fsspec.filesystem(self.filesystem_type, **self.filesystem_options)
37
+ self.config.setdefault('fs', self.fs)
35
38
 
36
39
  if not self.directory_exists():
37
40
  raise ValueError(f"{self.parquet_storage_path} does not exist")
@@ -48,3 +51,8 @@ class ParquetReader(DfHelper):
48
51
  return info['type'] == 'directory'
49
52
  except FileNotFoundError:
50
53
  return False
54
+
55
+ def __exit__(self, exc_type, exc_value, traceback):
56
+ # Ensure resources are cleaned up
57
+ if self.fs:
58
+ self.fs.close()
@@ -38,6 +38,7 @@ class ParquetSaver:
38
38
  schema = self._define_schema()
39
39
  self._convert_dtypes(schema)
40
40
  self._save_dataframe_to_parquet(full_path, schema)
41
+ self.fs.close()
41
42
 
42
43
  def _define_schema(self) -> pa.Schema:
43
44
  """Define a PyArrow schema dynamically based on df_result column types."""
@@ -90,4 +90,7 @@ class StorageManager:
90
90
  """
91
91
  print("Rebuilding depot structure...")
92
92
  self.rebuild_depot_paths(depots, clear_existing=clear_existing)
93
- print("Rebuild complete.")
93
+ print("Rebuild complete.")
94
+
95
+ def get_fs_instance(self):
96
+ return fsspec.filesystem(self.fs_type, **self.fs_options)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sibi-dst
3
- Version: 0.3.31
3
+ Version: 0.3.32
4
4
  Summary: Data Science Toolkit
5
5
  Author: Luis Valverde
6
6
  Author-email: lvalverdeb@gmail.com
@@ -20,6 +20,7 @@ Requires-Dist: django (>=5.1.4,<6.0.0)
20
20
  Requires-Dist: djangorestframework (>=3.15.2,<4.0.0)
21
21
  Requires-Dist: folium (>=0.19.4,<0.20.0)
22
22
  Requires-Dist: geopandas (>=1.0.1,<2.0.0)
23
+ Requires-Dist: gunicorn (>=23.0.0,<24.0.0)
23
24
  Requires-Dist: httpx (>=0.27.2,<0.28.0)
24
25
  Requires-Dist: ipython (>=8.29.0,<9.0.0)
25
26
  Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
@@ -42,6 +43,7 @@ Requires-Dist: sqlalchemy (>=2.0.36,<3.0.0)
42
43
  Requires-Dist: tornado (>=6.4.1,<7.0.0)
43
44
  Requires-Dist: tqdm (>=4.67.0,<5.0.0)
44
45
  Requires-Dist: uvicorn (>=0.34.0,<0.35.0)
46
+ Requires-Dist: uvicorn-worker (>=0.3.0,<0.4.0)
45
47
  Description-Content-Type: text/markdown
46
48
 
47
49
  # sibi-dst
@@ -1,8 +1,8 @@
1
1
  sibi_dst/__init__.py,sha256=CLHfzrFNqklNx5uMKAPtbZfkbBbVYR5qsiMro0RTfmA,252
2
2
  sibi_dst/df_helper/__init__.py,sha256=5yzslP6zYYOHsTtAzHnNDXHYjf_T6yW7baxwgtduWqQ,292
3
3
  sibi_dst/df_helper/_df_helper.py,sha256=sZaI998N9yd7FuUgZ8Esrz-K0eh2kXky53h9K8-l4cw,23650
4
- sibi_dst/df_helper/_parquet_artifact.py,sha256=CtM0u6Y9I1ZjAOYJouAYv23VO88UMzJxJtd_Ooh7bNg,5144
5
- sibi_dst/df_helper/_parquet_reader.py,sha256=sbe8DsScNT2h6huNsz8mUxVnUGpJeRzbaONZ3u2sQeQ,1685
4
+ sibi_dst/df_helper/_parquet_artifact.py,sha256=HVChP3UBCsEMpY-yyFERLaB76mWaziQXkdu2Qtzm7_s,5291
5
+ sibi_dst/df_helper/_parquet_reader.py,sha256=0qJHMS1PLcODTLMS13UW5iFQLK8b3qjgy7qDzcupgII,1963
6
6
  sibi_dst/df_helper/backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  sibi_dst/df_helper/backends/django/__init__.py,sha256=uWHi-DtQX5re7b2HcqoXUH3_FZWOw1VTmDf552FAkNs,256
8
8
  sibi_dst/df_helper/backends/django/_db_connection.py,sha256=kWITSPqn3286NzPvWSSE_PtJCm1tyfrv2RIuPSThXlQ,1634
@@ -48,8 +48,8 @@ sibi_dst/utils/df_utils.py,sha256=OFEtcwVKIilvf9qVf-IfIOHp4jcFAHX5l2IDGudhPZg,10
48
48
  sibi_dst/utils/file_utils.py,sha256=JpsybYj3XvVJisSBeVU6YSaZnYRm4_6YWTI3TLnnY4Y,1257
49
49
  sibi_dst/utils/filepath_generator.py,sha256=volVm0SSlBrtZp1RpTHxyui5rj5asNcVsWEBRY5FOUQ,6673
50
50
  sibi_dst/utils/log_utils.py,sha256=4eLmoV8VC7wDwPr1mRfDKP24_-laGO6ogE4U0u3DUuA,2315
51
- sibi_dst/utils/parquet_saver.py,sha256=BOXYLLRB2f3YSEwrKzX71Cs7d1BmOBSlcCfUzW2ON68,9716
52
- sibi_dst/utils/storage_manager.py,sha256=3KwPB0q-eGL2TTC7egox5ipvzTsAg1xVsHU8gK6vU3g,4129
53
- sibi_dst-0.3.31.dist-info/METADATA,sha256=QLKalk5RAXPb13dfDtncycmDPvlhr8vjII1cbvnNqjk,2474
54
- sibi_dst-0.3.31.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
55
- sibi_dst-0.3.31.dist-info/RECORD,,
51
+ sibi_dst/utils/parquet_saver.py,sha256=kR4FsjdMurQF46M0jc2Kvze4Ue70lUxefEzS0iszln8,9740
52
+ sibi_dst/utils/storage_manager.py,sha256=qHo5vTv-dr1roRr_mOcprSTdlAfH4Q2Dy5tQUz06Pnk,4228
53
+ sibi_dst-0.3.32.dist-info/METADATA,sha256=8CNqCjmW44vqkrhy-hvVlSmHS3s5jiPr2VDZV5V1Nl0,2564
54
+ sibi_dst-0.3.32.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
55
+ sibi_dst-0.3.32.dist-info/RECORD,,