-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Defining class_path before init_args does not work, but switching the order does work. #161
Comments
Thank you for reporting. I tried a few things, but unfortunately I am unable to reproduce it. From the description I wrote: from pytorch_lightning import LightningModule
from pytorch_lightning.cli import LightningCLI
class BaseModelClass(LightningModule):
def __init__(self, a: str = '-'):
pass
class SubclassedModelClass(BaseModelClass):
def __init__(self, **kwargs):
super().__init__(**kwargs)
LightningCLI(
model_class=BaseModelClass,
subclass_mode_model=True,
) If I run this with the two config files you posted, both If by mistake |
Thank you for looking into this and setting up a proper reproduction code
snippet. Apologies for not doing this myself, I was short on time. I’ll try
and run your example in our environment and see if we get the same issue.
…On Sat, 24 Sep 2022 at 15:50, Mauricio Villegas ***@***.***> wrote:
Thank you for reporting. I tried a few things, but unfortunately I am
unable to reproduce it. From the description I wrote:
from pytorch_lightning import LightningModulefrom pytorch_lightning.cli import LightningCLI
class BaseModelClass(LightningModule):
def __init__(self, a: str = '-'):
pass
class SubclassedModelClass(BaseModelClass):
def __init__(self, **kwargs):
super().__init__(**kwargs)
LightningCLI(
model_class=BaseModelClass,
subclass_mode_model=True,
)
If I run this with the two config files you posted, both ./cli.py fit -c
a.yaml --print_config and ./cli.py fit -c b.yaml --print_config work
correctly (--print_config added just to stop after parsing).
If by mistake subclass_mode_model=True is missing, it doesn't fail when
it should. This is a bug which I will fix, but it is not the problem you
reported. Please check again and complete the code in the description so
that it can be reproduced.
—
Reply to this email directly, view it on GitHub
<#161 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEDDD2J6W3A5UPLGECQCQ3V74BJHANCNFSM6AAAAAAQT7FFXE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Any update on this? |
I assume you were not able to reproduce the issue. Closing. |
🐛 Bug report
Using LightningCLI, when setting the
model
property in a yaml file, the order of class_path and init_args matters. class_path before init_args causes a ParsingError.To reproduce
Setup a LightingCLI with a base class BaseModelClass(LightningModule)
train.py
would be something along the lines ofConfig file
a.yaml
:Config file
b.yaml
Run it as follows
python train.py fit -c a.yaml
(Notice the missing class_path)
Then run with the alternative order
python train.py fit -c b.yaml
Which runs successfully.
Expected behavior
Both orders should work
Environment
pip install jsonargparse[signatures]
The text was updated successfully, but these errors were encountered: