You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New instantiators parameter of ArgumentParser.instantiate, auto_cli and FromConfigMixin.from_config, to use custom instantiators only within that call, including nested classes and partials for callables that return a class. This is recommended over the global add_instantiator, which affects other libraries that use jsonargparse.
The deprecation message of ArgumentParser.add_instantiator and the v5 migration guide now point to the new parameter.
Fixed custom instantiators with an applied_instantiation_links parameter missing links for classes nested in the init_args of another class, and for the partials that instantiate gives for callables that return a class.
These changes are also applied to the main branch via #995
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4b852f1) to head (50b8b0a).
✅ All tests successful. No failed tests found.
Adds call-scoped custom instantiators to parser instantiation, auto_cli, and from_config, and propagates instantiation-link information into nested and deferred class construction.
Updates documentation, migration guidance, and tests for the new parameter.
Two compatibility and deferred-value defects need correction.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A["instantiate cfg1"] --> B["deferred callable captures link actions"]
B --> C["instantiate cfg2 overwrites action values"]
C --> D["invoke cfg1 callable"]
D --> E["instantiator reads cfg2 link values"]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bugSomething isn't workingenhancementNew feature or requestrefactorImprovements to the quality of the code
1 participant
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.
What does this PR do?
instantiatorsparameter ofArgumentParser.instantiate,auto_cliandFromConfigMixin.from_config, to use custom instantiators only within that call, including nested classes and partials for callables that return a class. This is recommended over the globaladd_instantiator, which affects other libraries that use jsonargparse.ArgumentParser.add_instantiatorand the v5 migration guide now point to the new parameter.applied_instantiation_linksparameter missing links for classes nested in theinit_argsof another class, and for the partials thatinstantiategives for callables that return a class.These changes are also applied to the main branch via #995
Before submitting