Skip to content

Commit 7bd4c0d

Browse files
author
Ilia Kulikov
committed
_add_ directive removed
1 parent 42f6ee5 commit 7bd4c0d

File tree

1 file changed

+1
-32
lines changed

1 file changed

+1
-32
lines changed

src/fairseq2/utils/merge.py

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -153,30 +153,6 @@ def build_pathname(subpath: str | None = None) -> str:
153153
if k not in ignored_keys:
154154
output[k] = deepcopy(v)
155155

156-
add_keys = source.get("_add_")
157-
if add_keys is not None:
158-
if not isinstance(add_keys, Mapping):
159-
pathname = build_pathname("_add_")
160-
161-
raise MergeError(
162-
f"'{pathname}' at `source` must be of type `{Mapping}`, but is of type `{type(add_keys)}` instead."
163-
)
164-
165-
for idx, (add_key, value) in enumerate(add_keys.items()):
166-
if not isinstance(add_key, str):
167-
pathname = build_pathname("_add_")
168-
169-
raise MergeError(
170-
f"Each key under '{pathname}' at `source` must be of type `str`, but the key at index {idx} is of type `{type(add_key)}` instead."
171-
)
172-
173-
if add_key in output:
174-
pathname = build_pathname(add_key)
175-
176-
raise MergeError(f"`target` already has an item at path '{pathname}'.")
177-
178-
output[add_key] = deepcopy(value)
179-
180156
set_keys = source.get("_set_")
181157
if set_keys is not None:
182158
if not isinstance(set_keys, Mapping):
@@ -194,17 +170,10 @@ def build_pathname(subpath: str | None = None) -> str:
194170
f"Each key under '{pathname}' at `source` must be of type `str`, but the key at index {idx} is of type `{type(set_key)}` instead."
195171
)
196172

197-
if set_key not in output:
198-
pathname = build_pathname(set_key)
199-
200-
raise MergeError(
201-
f"`target` does not have an item at path '{pathname}'."
202-
)
203-
204173
output[set_key] = deepcopy(value)
205174

206175
for key, source_value in source.items():
207-
if key == "_del_" or key == "_add_" or key == "_set_":
176+
if key == "_del_" or key == "_set_":
208177
continue
209178

210179
try:

0 commit comments

Comments
 (0)