Skip to content

Commit afa1444

Browse files
committed
linting
Signed-off-by: HaoXuAI <sduxuhao@gmail.com>
1 parent 456b97f commit afa1444

File tree

2 files changed

+31
-35
lines changed

2 files changed

+31
-35
lines changed

sdk/python/feast/infra/offline_stores/contrib/spark_offline_store/spark_source.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def from_proto(cls, spark_options_proto: DataSourceProto.SparkOptions):
377377
date_partition_column_format=spark_options_proto.date_partition_column_format,
378378
table_format=table_format_from_dict(
379379
json.loads(spark_options_proto.table_format)
380-
)
380+
),
381381
)
382382

383383
return spark_options
@@ -394,7 +394,9 @@ def to_proto(self) -> DataSourceProto.SparkOptions:
394394
path=self.path,
395395
file_format=self.file_format,
396396
date_partition_column_format=self.date_partition_column_format,
397-
table_format=json.dumps(self.table_format.to_dict()) if self.table_format else "",
397+
table_format=json.dumps(self.table_format.to_dict())
398+
if self.table_format
399+
else "",
398400
)
399401

400402
return spark_options_proto

sdk/python/feast/table_format.py

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
class TableFormatType(Enum):
2222
"""Enum for supported table formats"""
23+
2324
DELTA = "delta"
2425
ICEBERG = "iceberg"
2526
HUDI = "hudi"
@@ -32,9 +33,9 @@ class TableFormat(ABC):
3233
table storage formats like Iceberg, Delta Lake, Hudi, etc.
3334
"""
3435

35-
def __init__(self,
36-
format_type: TableFormatType,
37-
properties: Optional[Dict[str, str]] = None):
36+
def __init__(
37+
self, format_type: TableFormatType, properties: Optional[Dict[str, str]] = None
38+
):
3839
self.format_type = format_type
3940
self.properties = properties or {}
4041

@@ -45,20 +46,15 @@ def to_dict(self) -> Dict:
4546

4647
@classmethod
4748
@abstractmethod
48-
def from_dict(cls,
49-
data: Dict) -> "TableFormat":
49+
def from_dict(cls, data: Dict) -> "TableFormat":
5050
"""Create table format from dictionary representation"""
5151
pass
5252

53-
def get_property(self,
54-
key: str,
55-
default: Optional[str] = None) -> Optional[str]:
53+
def get_property(self, key: str, default: Optional[str] = None) -> Optional[str]:
5654
"""Get a table format property"""
5755
return self.properties.get(key, default)
5856

59-
def set_property(self,
60-
key: str,
61-
value: str) -> None:
57+
def set_property(self, key: str, value: str) -> None:
6258
"""Set a table format property"""
6359
self.properties[key] = value
6460

@@ -71,11 +67,11 @@ class IcebergTableFormat(TableFormat):
7167
"""
7268

7369
def __init__(
74-
self,
75-
catalog: Optional[str] = None,
76-
namespace: Optional[str] = None,
77-
catalog_properties: Optional[Dict[str, str]] = None,
78-
table_properties: Optional[Dict[str, str]] = None,
70+
self,
71+
catalog: Optional[str] = None,
72+
namespace: Optional[str] = None,
73+
catalog_properties: Optional[Dict[str, str]] = None,
74+
table_properties: Optional[Dict[str, str]] = None,
7975
):
8076
super().__init__(TableFormatType.ICEBERG)
8177
self.catalog = catalog
@@ -104,8 +100,7 @@ def to_dict(self) -> Dict:
104100
}
105101

106102
@classmethod
107-
def from_dict(cls,
108-
data: Dict) -> "IcebergTableFormat":
103+
def from_dict(cls, data: Dict) -> "IcebergTableFormat":
109104
return cls(
110105
catalog=data.get("catalog"),
111106
namespace=data.get("namespace"),
@@ -122,9 +117,9 @@ class DeltaTableFormat(TableFormat):
122117
"""
123118

124119
def __init__(
125-
self,
126-
table_properties: Optional[Dict[str, str]] = None,
127-
checkpoint_location: Optional[str] = None,
120+
self,
121+
table_properties: Optional[Dict[str, str]] = None,
122+
checkpoint_location: Optional[str] = None,
128123
):
129124
super().__init__(TableFormatType.DELTA)
130125
self.table_properties = table_properties or {}
@@ -145,8 +140,7 @@ def to_dict(self) -> Dict:
145140
}
146141

147142
@classmethod
148-
def from_dict(cls,
149-
data: Dict) -> "DeltaTableFormat":
143+
def from_dict(cls, data: Dict) -> "DeltaTableFormat":
150144
return cls(
151145
table_properties=data.get("table_properties", {}),
152146
checkpoint_location=data.get("checkpoint_location"),
@@ -161,11 +155,11 @@ class HudiTableFormat(TableFormat):
161155
"""
162156

163157
def __init__(
164-
self,
165-
table_type: Optional[str] = None, # COPY_ON_WRITE or MERGE_ON_READ
166-
record_key: Optional[str] = None,
167-
precombine_field: Optional[str] = None,
168-
table_properties: Optional[Dict[str, str]] = None,
158+
self,
159+
table_type: Optional[str] = None, # COPY_ON_WRITE or MERGE_ON_READ
160+
record_key: Optional[str] = None,
161+
precombine_field: Optional[str] = None,
162+
table_properties: Optional[Dict[str, str]] = None,
169163
):
170164
super().__init__(TableFormatType.HUDI)
171165
self.table_type = table_type
@@ -180,7 +174,9 @@ def __init__(
180174
if record_key:
181175
all_properties["hoodie.datasource.write.recordkey.field"] = record_key
182176
if precombine_field:
183-
all_properties["hoodie.datasource.write.precombine.field"] = precombine_field
177+
all_properties["hoodie.datasource.write.precombine.field"] = (
178+
precombine_field
179+
)
184180

185181
self.properties = all_properties
186182

@@ -194,8 +190,7 @@ def to_dict(self) -> Dict:
194190
}
195191

196192
@classmethod
197-
def from_dict(cls,
198-
data: Dict) -> "HudiTableFormat":
193+
def from_dict(cls, data: Dict) -> "HudiTableFormat":
199194
return cls(
200195
table_type=data.get("table_type"),
201196
record_key=data.get("record_key"),
@@ -204,8 +199,7 @@ def from_dict(cls,
204199
)
205200

206201

207-
def create_table_format(format_type: TableFormatType,
208-
**kwargs) -> TableFormat:
202+
def create_table_format(format_type: TableFormatType, **kwargs) -> TableFormat:
209203
"""
210204
Factory function to create appropriate TableFormat instance based on type.
211205
"""

0 commit comments

Comments
 (0)