Skip to content

Commit

Permalink
rm nested set
Browse files Browse the repository at this point in the history
  • Loading branch information
BeachWang committed Dec 31, 2024
1 parent af9e14d commit f57f454
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions data_juicer/utils/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,6 @@ def nested_access(data, path, digit_allowed=True):
return data


def nested_set(data: dict, path: str, val):
"""
Set the val to the nested data in the dot-separated path.
:param data: A dictionary with nested format.
:param path: A dot-separated string representing the path to set.
:return: The nested data after the val set.
"""
keys = path.split('.')
cur = data
try:
for key in keys[:-1]:
if key not in cur:
cur[key] = {}
cur = cur[key]
if keys[-1] in cur:
logger.warning(f'Overwrite value in {path}!')
cur[keys[-1]] = val
except Exception:
logger.warning(f'Unvalid dot-separated path: {path}!')
return data
return data


def is_string_list(var):
"""
return if the var is list of string.
Expand Down

0 comments on commit f57f454

Please sign in to comment.