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

torchdrug.patch.py breaks use of ConcatDataset #237

Open
bbrier opened this issue Nov 23, 2023 · 1 comment
Open

torchdrug.patch.py breaks use of ConcatDataset #237

bbrier opened this issue Nov 23, 2023 · 1 comment

Comments

@bbrier
Copy link

bbrier commented Nov 23, 2023

Creating a torch ConcatDataset fails after running torchdrug.patch.py, so by extension every torchdrug import.

Minimal example:

from torch.utils.data import Dataset, ConcatDataset
import torchdrug

class DummyDataset(Dataset):
    def __init__(self, size=50):
        self.size=size
        
    def __len__(self):
        return self.size
    
    def __getitem__(self, idx):
        return idx

dummy = ConcatDataset([DummyDataset(), DummyDataset()]) 

The issue appears to be caused by the following code snippet from patch.py

Dataset = dataset.Dataset
for name, cls in inspect.getmembers(dataset):
    if inspect.isclass(cls) and issubclass(cls, Dataset):
        cls = core.make_configurable(cls)
        cls = R.register("dataset.%s" % name)(cls)
        patch(dataset, name, cls)
importlib.reload(torch.utils.data)

Expected behavior: ConcatDataset is correctly initialised
Actual behavior: Initialisation of ConcatDataset raises {TypeError}__init__() missing 1 required positional argument: 'datasets'

python version: 3.9.16
torch version: 1.13.1+cu117
torchdrug version: 0.2.1

@toooooodo
Copy link

I'm encountering the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants