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.
Description
Added new
Draft
type andauto_draft_in_config
parameter toregister(...)
function. This is meant for functions that can only be partially be instantiated by a user, because a required parameter will be provided by the library later.For instance:
ScheduledOptimizer
requires the pipeline parameters, which depends on the pipeline being trainedcsv
andjson
) requirelogging_dir
which might be defined in theedsnlp.train
function.If a callable registered with
allow_draft=True
is resolved with missing required parameters, aDraft[ReturnType]
class is returned. This class can then be instantiated via the draft.instantiate method. We don't instantiate a Draft class via the__call__
method to avoid users mistakenly proceeding with a non instantiated class. Instead, whenever a Draft an attribute or a method is requested on Draft class, outside the Draft few specific attrs/methods, a message error is displayed explaining how this object is not instantiated yet.The user can also explicitly instantiate the Draft object via the
Class.draft
method for classes that have been wrapped withvalidate_arguments
.TODO later: allow to specify which parameters will be filled eg.
Draft[int, ["name"]]
declares that the library will fill the "name" parameter.Checklist