-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Kwargs seems to not work with classmethods #146
Comments
…ing #146. - Documented AST resolver support for **kwargs use in property.
With the latest commit c0de99e the error above in now just logged at debug level. You can see the log messages by setting environment variable Is this pattern used in some popular public library? |
@mauvilsa it is! In Because of this I can't use it with BTW |
Thank you @mauvilsa for your super prompt response! Similar to @mahnerak , the original use case that prompted me to open the issue is using from lightning_transformers.core.model import TaskTransformer
from pytorch_lightning.utilities.cli import LightningCLI
cli = LightningCLI(
TaskTransformer
) the following error would be produced.
Can confirm that with the latest commit the code does not error out. |
…146. - AST resolver now supports pop and get from **kwargs. - Added AST resolver unit test using class as attribute of module.
Thank you both for pointing to where this is needed. In recent commits I have added support for import os
os.environ['JSONARGPARSE_DEBUG'] = ''
from jsonargparse import ArgumentParser
from transformers.configuration_utils import PretrainedConfig
parser = ArgumentParser()
parser.add_class_arguments(PretrainedConfig, 'init')
parser.add_method_arguments(PretrainedConfig, 'get_config_dict', 'get_config_dict')
parser.print_help()
|
Yes, I've changed |
Created an issue Lightning-Universe/lightning-transformers#274. Closing this one since anyway the original report has already been fixed and the forward references are out of scope. |
🐛 Bug report
First of all, thanks for the great tool! When saving
**kwargs
in the init of a class which is then used by a classmethod, an assertion error is raised.To reproduce
Running the script produces the error:
Interestingly, if you comment out
parser.add_class_arguments(BaseClassBreaking, "baseclass")
above and uncommentparser.add_class_arguments(BaseClassWorking, "baseclass")
, the code runs without error.Environment
pip install jsonargparse[signatures]
Thank you in advance for taking a look at this :)
The text was updated successfully, but these errors were encountered: