Elron commited on
Commit
e4d5cd2
1 Parent(s): c3a1efb

Upload normalizers.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. normalizers.py +7 -3
normalizers.py CHANGED
@@ -1,4 +1,4 @@
1
- from typing import Any, Dict, List
2
 
3
  from .operator import StreamInstanceOperator
4
 
@@ -9,10 +9,14 @@ class NormalizeListFields(StreamInstanceOperator):
9
  empty_value: str = ""
10
  separator: str = ", "
11
 
12
- def process(self, instance: Dict[str, Any], stream_name: str = None) -> Dict[str, Any]:
 
 
13
  for field in self.fields:
14
  assert field in instance, f"Field {field} not found in instance {instance}"
15
- assert isinstance(instance[field], list), f"Field {field} should be a list, got {type(instance[field])}"
 
 
16
 
17
  target_key = self.key_prefix + field
18
 
 
1
+ from typing import Any, Dict, List, Optional
2
 
3
  from .operator import StreamInstanceOperator
4
 
 
9
  empty_value: str = ""
10
  separator: str = ", "
11
 
12
+ def process(
13
+ self, instance: Dict[str, Any], stream_name: Optional[str] = None
14
+ ) -> Dict[str, Any]:
15
  for field in self.fields:
16
  assert field in instance, f"Field {field} not found in instance {instance}"
17
+ assert isinstance(
18
+ instance[field], list
19
+ ), f"Field {field} should be a list, got {type(instance[field])}"
20
 
21
  target_key = self.key_prefix + field
22