-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor DefaultTrainer.from_checkpoint #53
refactor DefaultTrainer.from_checkpoint #53
Conversation
Only had a brief look at the changes, I think this should work in principle.
Please make sure that they pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, but two minor comments left to address.
*dynamic_args, | ||
optional=False, | ||
only_class=False, | ||
dynamic_kwargs: Optional[Dict[str, Any]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason you're not using **dynamic_kwargs
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, **dynamic_kwargs
would not allow to optional
(or only_class
) as a kwarg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am missing something, but I don't see why this is the case. As far as I can see this is perfectly valid python:
def my_func(
kwarg_name, *args,
optional=False, only_class=False,
**kwargs
):
print(optional)
my_func("x", "y", optional=True, blub="xyz")
(prints True)
torch_em/trainer/default_trainer.py
Outdated
|
||
def __call__( | ||
self, | ||
name: str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly is name
here? I thought it was the name of the trainer, i.e. the checkpoint name. But looks like it's something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I understand now that this is the name
of the kwarg
. But this should be explained a bit better, it's somehow not immediately obvious. I think it would be best if you can just add the "normal usage" in the doc string, i.e. how the deserializer is normally called for a kwarg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea. I suppose we can additionally rename name
to kwarg_name
or attribute
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's go with kwarg_name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't see why we can't use **kwargs
in __call__
. Looks good otherwise.
*dynamic_args, | ||
optional=False, | ||
only_class=False, | ||
dynamic_kwargs: Optional[Dict[str, Any]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am missing something, but I don't see why this is the case. As far as I can see this is perfectly valid python:
def my_func(
kwarg_name, *args,
optional=False, only_class=False,
**kwargs
):
print(optional)
my_func("x", "y", optional=True, blub="xyz")
(prints True)
This would fail in case someone needs a special dynamic_kwarg that happens to also be called |
Ah ok, I see what you mean. Quite a corner case indeed, but good to catch it here.
Cool, I will have a look once you think it's good to go and create it as a PR here, for now I think the changes in this one are good to go and I'll merge. |
No description provided.