This repository was archived by the owner on Dec 16, 2022. It is now read-only.
Add support for overriding list elements #2585
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, when lists are popped off
Params
,Params._check_is_dict()
will give each element in the list a history ofold_history.list.
. If this history is later intended to be used to construct an overrides dict (such as inParams.add_file_to_archive()
) this will cause the overridden dict to be constructed incorrectly:Motivation
We use allennlp's config system to compose simple transformations on data, and these transforms occasionally require adding files to the archive.
Example (simplified, but hopefully illustrative):
Suggested fix
Params._check_is_dict()
to give list elements a history ofold_history.{index}.
with_fallback()
: if a key exists in both thepreferred
andfallback
dicts andfallback[key]
is a list, treatpreferred[key]
as a sparsely represented list and use it to override selected indexes infallback[key]
.What do you think?