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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
LightningCli: Passing trainer_defaults #8008
Comments
Seems to me like this is a bug upstream. This produces the same error: from typing import Optional
import jsonargparse
print(jsonargparse.__version__)
class A:
...
def fn(arg: Optional[A] = None):
print(arg)
parser = jsonargparse.ArgumentParser()
parser.add_function_arguments(fn)
parser.set_defaults({'arg': A()})
parser.parse_args() cc: @mauvilsa |
Yes, this is an issue that relates to jsonargparse. In general having a class instance as a default is not a good idea because it is mutable. Furthermore, this breaks print_config because there is no way to convert the class instance into a |
So a function like or |
Something more like my_default_factory = default_class_factory(MyClass, init_args={...}) which then could be used to override a default as parser.set_defaults({'my_module.my_class': my_default_factory}) or to use as default in a signature as class MyModule:
def __init__(
self,
my_class: MyClass = my_default_factory,
):
... Something analogous to the field in dataclasses. |
Hey @mauvilsa, Best, |
I agree that if a class instance of the correct type is given then it shouldn't fail like it does now.
The class path can be inferred, but the init args can't be inferred. The file that
I agree we should do this. |
This issue has been automatically marked as stale because it hasn't had any recent activity. This issue will be closed in 7 days if no further activity occurs. Thank you for your contributions, Pytorch Lightning Team! |
Hi, I meet another problem similar to this one for the 1.5.0rc0 version
or
are both not ok to parse the DDPPlugin ( Configuration check failed :: No action for key "find_unused_parameters" to check its value. ) Is this a misconfiguration? Error for the first config file
Error for the second
|
No problem! |
An update on this. jsonargparse was modified such that if a default is an instance of a class, parsing does not fail and when the config is printed it shows the string representation of the default instance. Also the |
The |
馃悰 Bug
Please reproduce using the BoringModel
To Reproduce
It seems that
PyTorchProfiler
can't be passed as profiler argument in:Is it a mis-use of LightningCLI or a bug ? @carmocca
Use following BoringModel and post here
Expected behavior
Environment
Note:
Bugs with code
are solved faster !Colab Notebook
should be madepublic
!IDE
: Please, use our python bug_report_model.py template.Colab Notebook
: Please copy and paste the output from our environment collection script (or fill out the checklist below manually).You can get the script and run it with:
conda
,pip
, source):Additional context
The text was updated successfully, but these errors were encountered: