Skip to content

Allow Using Specific Dataloaders in LightningCLI (Instead of a DataModule) #20673

Open
@stuartthomson

Description

@stuartthomson

Description & Motivation

I would like to configure the LightningCLI to use dataloaders in the test subcommand, similar to this example from the docs

trainer.test(dataloaders=test_dataloaders)

As far as I can tell this impossible using the LightningCLI because you can only pass a datamodule into it. My test set is defined differently from various training sets I have so this becomes annoying to create separate datamodules for each.

You can see that the dataloaders option is specifically ignored in the cli.py subcommands method.

Pitch

I would like to specify dataloaders in the LightningCLI. Perhaps like:

LightningCLI(
  MyModule,
  train_dataloaders=MyTrainDataloader,
  test_dataloaders=MyTestDataloader,
  args=args
)

Alternatives

The alternative is having to create different datamodules for every combination of train/test dataloaders.
Or you have to simply just not use the CLI stuff and call lightning directly.

Additional context

I would be willing to open a PR if this feature is deemed useful.

cc @lantiga @Borda

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureIs an improvement or enhancementneeds triageWaiting to be triaged by maintainerswon't fixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions