Skip to content

Commit

Permalink
fix(abstractions): deepcopy during transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
TianyiQ committed Dec 9, 2024
1 parent c33bfc0 commit 5d40c4d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/abstractions/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import json
import warnings
import copy
from functools import partial
import src.utils.text_utils as tu
from tqdm import tqdm
Expand Down Expand Up @@ -283,6 +284,7 @@ def inv_map_key_fields_fn(sample_dict: Dict) -> Dict:
if max_batch_size == 1:
with tu.JsonListReader(self.data_path) as reader:
for element in reader:
element = copy.deepcopy(element)
if map_key_fields:
element = map_key_fields_fn(element)

Expand All @@ -295,6 +297,7 @@ def inv_map_key_fields_fn(sample_dict: Dict) -> Dict:

with tu.JsonListReader(self.data_path) as reader:
for element in reader:
element = copy.deepcopy(element)
if map_key_fields:
element = map_key_fields_fn(element)

Expand Down

0 comments on commit 5d40c4d

Please sign in to comment.