Skip to content
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

Multiple subclassing levels required to use LightningDataModule in LightningCLI #20024

Open
jasonkena opened this issue Jun 27, 2024 · 2 comments
Labels
bug Something isn't working lightningcli pl.cli.LightningCLI

Comments

@jasonkena
Copy link

jasonkena commented Jun 27, 2024

Bug description

I get the following error message

  Import path data.snemi.SNEMIDataModule does not correspond to a subclass of LightningDataModule

with yaml config

data:
  class_path: data.snemi.SNEMIDataModule

when defining SNEMIDataModule as follows

class SNEMIDataModule(LightningDataModule):
    ...

this problem is solved by creating a dummy subclass:

class DummyDataModule(LightningDataModule):
    pass
class SNEMIDataModule(DummyDataModule):
    ...

Is this intended behavior?

What version are you seeing the problem on?

v2.2

How to reproduce the bug

No response

Error messages and logs

# Error messages and logs here please

Environment

Current environment
#- Lightning Component (e.g. Trainer, LightningModule, LightningApp, LightningWork, LightningFlow):
#- PyTorch Lightning Version (e.g., 1.5.0):
#- Lightning App Version (e.g., 0.5.2):
#- PyTorch Version (e.g., 2.0):
#- Python version (e.g., 3.9):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
#- Running environment of LightningApp (e.g. local, cloud):

More info

No response

cc @carmocca @mauvilsa

@jasonkena jasonkena added bug Something isn't working needs triage Waiting to be triaged by maintainers labels Jun 27, 2024
@jasonkena
Copy link
Author

Hmm, the problem seems to be related to using lightning.LightningDataModule instead of pytorch_lightning.LightningDataModule

@awaelchli
Copy link
Member

awaelchli commented Jun 28, 2024

Hi @jasonkena

Mixing imports would definitely not be good. Can you make sure to use consistently only lightning imports everywhere in your program?

For further help, can I ask you to fill out the section of the bug report with the versions of packages please, including jsonargparse?

@awaelchli awaelchli added lightningcli pl.cli.LightningCLI and removed needs triage Waiting to be triaged by maintainers labels Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lightningcli pl.cli.LightningCLI
Projects
None yet
Development

No branches or pull requests

2 participants