Skip to content

Mypy complaining about transfer_batch_to_device as abstract method #6008

@gianscarpe

Description

@gianscarpe

🐛 Bug

In my projects, mypy complains if I don't override transfer_batch_to_device in DataModule. This is probably due to a design choice, since transfer_batch_to_device is an abstract method. However, it's clear that overriding the method is not mandatory, as the same behavior is obtained (probably somewhere else in lightiningmodule and trainer code, I couldn't find it), and therefore I think it shouldn't be abstractmethod
I believe we can design this a little better, by making clear that it's not mandatory to override transfer_batch_to_device

To Reproduce

Simply implement a subclass of DataModule and use mypy to check your code

Expected behavior

I expect to

Environment

  • PyTorch Version (e.g., 1.7): `.7
  • OS (e.g., Linux): LINUX
  • How you installed PyTorch (conda, pip, source): pip
  • Build command you used (if compiling from source):
  • Python version: 3.8.4
  • CUDA/cuDNN version: 11.0
  • GPU models and configuration:
  • Any other relevant information:

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedOpen to be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions