Treat default values in function signature the same way as config kwargs#12
Open
JIy3AHKO wants to merge 2 commits intoPositronic-Robotics:mainfrom
Open
Treat default values in function signature the same way as config kwargs#12JIy3AHKO wants to merge 2 commits intoPositronic-Robotics:mainfrom
JIy3AHKO wants to merge 2 commits intoPositronic-Robotics:mainfrom
Conversation
9ad40a1 to
cdaa6c1
Compare
vertix
requested changes
Aug 5, 2025
| def return1(): | ||
| return 1 | ||
|
|
||
| @cfn.config() |
Contributor
There was a problem hiding this comment.
Does this PR mean that there's no need to have cfn.config decorator as a function (aka decorator factory) and we can just make it a usual decorator?
| return 1 | ||
|
|
||
| @cfn.config() | ||
| def add1(a=return1): |
Contributor
There was a problem hiding this comment.
Can we imagine the non-config-decorated functions that take configs as arguments?
What I want to say is that I don't like passing configs as defaults to functions. I would propose to pass configs as defaults only to config decorators. Otherwise, the reader can really be confused, as the real default is not the config, but its instantiation.
| @cfn.config(batch_size=32, lr=0.001) | ||
| def create_optimizer(batch_size: int, lr: float): | ||
| return torch.optim.Adam(lr=lr) | ||
| @cfn.config(lr=1e-3, weight_decay=0) |
Contributor
There was a problem hiding this comment.
I think we need to expand the other sections (particularly resolution and relative resolution) to document this new functionality
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
As mentioned in #10
cfn.Configobjects in function's default value will not be resolved duringinstantiate.After this PR it would be possible to declare every default value in function signature e.g.: