hopeit.dataframes 0.26.0rc0__tar.gz → 0.26.0rc1__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 (22) hide show
  1. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/PKG-INFO +3 -3
  2. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/pyproject.toml +3 -3
  3. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit/dataframes/__init__.py +1 -1
  4. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit/dataframes/datablocks.py +2 -2
  5. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit/dataframes/dataframe.py +5 -4
  6. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit/dataframes/serialization/files.py +26 -4
  7. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit/dataframes/serialization/settings.py +2 -1
  8. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit/dataframes/setup/dataframes.py +2 -1
  9. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit.dataframes.egg-info/PKG-INFO +3 -3
  10. hopeit_dataframes-0.26.0rc1/src/hopeit.dataframes.egg-info/requires.txt +4 -0
  11. hopeit_dataframes-0.26.0rc0/src/hopeit.dataframes.egg-info/requires.txt +0 -4
  12. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/README.md +0 -0
  13. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/setup.cfg +0 -0
  14. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit/dataframes/py.typed +0 -0
  15. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit/dataframes/serialization/__init__.py +0 -0
  16. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit/dataframes/serialization/dataset.py +0 -0
  17. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit/dataframes/serialization/py.typed +0 -0
  18. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit/dataframes/setup/__init__.py +0 -0
  19. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit/dataframes/setup/py.typed +0 -0
  20. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit.dataframes.egg-info/SOURCES.txt +0 -0
  21. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit.dataframes.egg-info/dependency_links.txt +0 -0
  22. {hopeit_dataframes-0.26.0rc0 → hopeit_dataframes-0.26.0rc1}/src/hopeit.dataframes.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: hopeit.dataframes
3
- Version: 0.26.0rc0
3
+ Version: 0.26.0rc1
4
4
  Summary: Hopeit Engine Dataframes for Pandas
5
5
  Author-email: Leo Smerling & Pablo Canto <contact@hopeit.com.ar>, Leo Smerling <contact@hopeit.com.ar>, Pablo Canto <contact@hopeit.com.ar>
6
6
  License: Apache 2
@@ -24,8 +24,8 @@ Classifier: Topic :: Internet :: WWW/HTTP
24
24
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
25
  Classifier: Framework :: AsyncIO
26
26
  Description-Content-Type: text/markdown
27
- Requires-Dist: hopeit.engine>=0.26.0rc0
28
- Requires-Dist: hopeit.fs-storage>=0.26.0rc0
27
+ Requires-Dist: hopeit.engine>=0.26.0rc1
28
+ Requires-Dist: hopeit.fs-storage>=0.26.0rc1
29
29
  Requires-Dist: pandas>=2.2.3
30
30
  Requires-Dist: numpy>=1.26.4
31
31
 
@@ -4,14 +4,14 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hopeit.dataframes"
7
- version = "0.26.0rc0"
7
+ version = "0.26.0rc1"
8
8
 
9
9
  description = "Hopeit Engine Dataframes for Pandas"
10
10
  dynamic = ["readme"]
11
11
 
12
12
  dependencies = [
13
- "hopeit.engine>=0.26.0rc0",
14
- "hopeit.fs-storage>=0.26.0rc0",
13
+ "hopeit.engine>=0.26.0rc1",
14
+ "hopeit.fs-storage>=0.26.0rc1",
15
15
  "pandas>=2.2.3",
16
16
  "numpy>=1.26.4"
17
17
  ]
@@ -92,7 +92,7 @@ class DataFrames(Generic[DataFrameT, DataObject]):
92
92
  """
93
93
 
94
94
  @staticmethod
95
- def setup(settings: DatasetSerialization):
95
+ def setup(settings: DatasetSerialization) -> None:
96
96
  register_serialization(settings)
97
97
 
98
98
  @staticmethod
@@ -11,7 +11,7 @@ DataFrameType = TypeVar("DataFrameType")
11
11
 
12
12
 
13
13
  class TempDataBlock(Generic[DataBlockType, DataBlockItemType]):
14
- def __init__(self, datatype: Type[DataBlockType], df: pd.DataFrame):
14
+ def __init__(self, datatype: Type[DataBlockType], df: pd.DataFrame) -> None:
15
15
  self.datatype = datatype
16
16
  self.df = df
17
17
 
@@ -132,7 +132,7 @@ class DataBlocks(Generic[DataBlockType, DataFrameType]):
132
132
  ) from e
133
133
 
134
134
  @classmethod
135
- def _adapt_to_schema(cls, datablock: DataBlockType, keys: list[str], df: pd.DataFrame):
135
+ def _adapt_to_schema(cls, datablock: DataBlockType, keys: list[str], df: pd.DataFrame) -> None:
136
136
  for key in keys:
137
137
  datatype = find_dataframe_type(getattr(datablock, key).datatype) # type: ignore[var-annotated]
138
138
  valid_df = datatype._from_df(df)._df
@@ -124,7 +124,7 @@ class DataFrameMixin(Generic[DataFrameT, DataObject]):
124
124
  raise NotImplementedError # must use @dataframe decorator # pragma: no cover
125
125
 
126
126
  @staticmethod
127
- def __init_from_series__(self, **series: pd.Series): # pylint: disable=bad-staticmethod-argument
127
+ def __init_from_series__(self, **series: pd.Series) -> None: # pylint: disable=bad-staticmethod-argument
128
128
  df = pd.DataFrame(series)
129
129
  df.index.name = None # Removes index name to avoid colisions with series name
130
130
  if self.__data_object__["validate"]:
@@ -240,9 +240,10 @@ def dataframe(
240
240
  return amended_class
241
241
  return cls
242
242
 
243
- def add_dataframe_metadata(cls):
243
+ def add_dataframe_metadata(cls) -> None:
244
244
  serialized_fields = {k: (v.annotation, v) for k, v in fields(cls).items()}
245
- dataobject_type = create_model(cls.__name__ + "DataObject", **serialized_fields)
245
+ dataobject_name = str(cls.__name__) + "DataObject"
246
+ dataobject_type = create_model(dataobject_name, **serialized_fields) # type: ignore[call-overload]
246
247
  dataobject_type = dataobject(dataobject_type, unsafe=True)
247
248
 
248
249
  setattr(cls, "DataObject", dataobject_type)
@@ -255,7 +256,7 @@ def dataframe(
255
256
  ),
256
257
  )
257
258
 
258
- def add_dataobject_annotations(cls, unsafe: bool, validate: bool, schema: bool):
259
+ def add_dataobject_annotations(cls, unsafe: bool, validate: bool, schema: bool) -> None:
259
260
  setattr(
260
261
  cls,
261
262
  "__data_object__",
@@ -1,7 +1,7 @@
1
1
  """Support for `@dataframes` serialization to files"""
2
2
 
3
3
  import io
4
- from typing import Generic, Optional, Type, TypeVar
4
+ from typing import Generic, Literal, Optional, Type, TypeVar
5
5
  from uuid import uuid4
6
6
 
7
7
  import pandas as pd
@@ -17,22 +17,42 @@ except ImportError as e:
17
17
 
18
18
  from hopeit.dataframes.dataframe import DataFrameMixin
19
19
  from hopeit.dataframes.serialization.dataset import Dataset
20
- from hopeit.dataobjects import DataObject
20
+ from hopeit.dataobjects import DataObject, dataclass, dataobject
21
+ from hopeit.dataobjects.payload import Payload
21
22
  from hopeit.fs_storage import FileStorage
22
23
 
23
24
  DataFrameT = TypeVar("DataFrameT", bound=DataFrameMixin)
24
25
 
25
26
 
27
+ @dataobject
28
+ @dataclass
29
+ class DatasetFileStorageEngineSettings:
30
+ """Pyarrow settings for parquet file storage"""
31
+
32
+ compression: Literal["snappy", "gzip", "brotli", "lz4", "zstd"] | None = None
33
+ compression_level: int | str | None = None
34
+
35
+
26
36
  class DatasetFileStorage(Generic[DataFrameT]):
27
37
  """Support to store dataframes as files,
28
38
  using pandas parquet format support in combination
29
39
  with `hopeit.engine` file storage plugins
30
40
  """
31
41
 
32
- def __init__(self, *, location: str, partition_dateformat: Optional[str], **kwargs):
42
+ def __init__(
43
+ self,
44
+ *,
45
+ location: str,
46
+ partition_dateformat: Optional[str],
47
+ storage_settings: dict[str, str | int],
48
+ **kwargs,
49
+ ):
33
50
  self.storage: FileStorage = FileStorage(
34
51
  path=location, partition_dateformat=partition_dateformat
35
52
  )
53
+ self.storage_settings: DatasetFileStorageEngineSettings = Payload.from_obj(
54
+ storage_settings, DatasetFileStorageEngineSettings
55
+ )
36
56
 
37
57
  async def save(self, dataframe: DataFrameT) -> Dataset:
38
58
  """Saves @dataframe annotated object as parquet to file system
@@ -42,7 +62,9 @@ class DatasetFileStorage(Generic[DataFrameT]):
42
62
  key = f"{datatype.__qualname__.lower()}_{uuid4()}.parquet"
43
63
  data = io.BytesIO(
44
64
  dataframe._df.to_parquet( # pylint: disable=protected-access
45
- engine="pyarrow"
65
+ engine="pyarrow",
66
+ compression=self.storage_settings.compression,
67
+ compression_level=self.storage_settings.compression_level,
46
68
  )
47
69
  )
48
70
  location = await self.storage.store_file(file_name=key, value=data)
@@ -2,7 +2,7 @@
2
2
 
3
3
  from typing import Optional
4
4
 
5
- from hopeit.dataobjects import dataclass, dataobject
5
+ from hopeit.dataobjects import dataclass, dataobject, field
6
6
 
7
7
 
8
8
  @dataobject
@@ -11,3 +11,4 @@ class DatasetSerialization:
11
11
  protocol: str
12
12
  location: str
13
13
  partition_dateformat: Optional[str] = None
14
+ storage_settings: dict[str, str | int] = field(default_factory=dict)
@@ -26,11 +26,12 @@ def setup(payload: None, context: EventContext) -> None:
26
26
  register_serialization(settings)
27
27
 
28
28
 
29
- def register_serialization(settings: DatasetSerialization):
29
+ def register_serialization(settings: DatasetSerialization) -> None:
30
30
  impl = find_protocol_impl(settings.protocol)
31
31
  storage = impl(
32
32
  protocol=settings.protocol,
33
33
  location=settings.location,
34
34
  partition_dateformat=settings.partition_dateformat,
35
+ storage_settings=settings.storage_settings,
35
36
  )
36
37
  setattr(Dataset, "_Dataset__storage", storage)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: hopeit.dataframes
3
- Version: 0.26.0rc0
3
+ Version: 0.26.0rc1
4
4
  Summary: Hopeit Engine Dataframes for Pandas
5
5
  Author-email: Leo Smerling & Pablo Canto <contact@hopeit.com.ar>, Leo Smerling <contact@hopeit.com.ar>, Pablo Canto <contact@hopeit.com.ar>
6
6
  License: Apache 2
@@ -24,8 +24,8 @@ Classifier: Topic :: Internet :: WWW/HTTP
24
24
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
25
  Classifier: Framework :: AsyncIO
26
26
  Description-Content-Type: text/markdown
27
- Requires-Dist: hopeit.engine>=0.26.0rc0
28
- Requires-Dist: hopeit.fs-storage>=0.26.0rc0
27
+ Requires-Dist: hopeit.engine>=0.26.0rc1
28
+ Requires-Dist: hopeit.fs-storage>=0.26.0rc1
29
29
  Requires-Dist: pandas>=2.2.3
30
30
  Requires-Dist: numpy>=1.26.4
31
31
 
@@ -0,0 +1,4 @@
1
+ hopeit.engine>=0.26.0rc1
2
+ hopeit.fs-storage>=0.26.0rc1
3
+ pandas>=2.2.3
4
+ numpy>=1.26.4
@@ -1,4 +0,0 @@
1
- hopeit.engine>=0.26.0rc0
2
- hopeit.fs-storage>=0.26.0rc0
3
- pandas>=2.2.3
4
- numpy>=1.26.4