Best practices: CLI and Loading DataModule from config.yaml
Hey,
I've been using both, PyTorch Lightning/CLI and jsonargparse for quite a while. Yet, I haven't found a simple method to instantiate a specific DataModule whose parameters are set in a config.yaml that was used during training. I have 2 workarounds which are both unsatisfying:
Workaround 1 - Reuse CLI
Define an instantiate-only CLI and use .datamodule
class InstantiateOnlyLightningCLI(LightningCLI): # probably unnecessary in current RC: run=False
    def fit(self) -> None:
        return None

cli = InstantiateOnlyLightningCLI(
        wave.WaveNet,
        pl.LightningDataModule,
        subclass_mode_model=False,
        subclass_mode_data=True,
    )
cli.datamodule

Downsides

trainer and model are instantiated although not used
--help is populated with many unneeded parameters

Workaround 2 - Load Yaml directly
When the actual datamodule is known then
with open(config, "r") as f:
  plcfg = yaml.safe_load(f.read())
  datamodule = SpecificDataModule(**plcfg["data"]["init_args"])

Downsides

No parameter validation
No class arguments (i.e transformation classes) supported

Does anyone have a better solution?
This is similar to #10363. You can use jsonargparse directly to create a parser and instantiate. You can do the following:
from jsonargparse import ArgumentParser

parser = ArgumentParser()
parser.add_argument('--model', type=dict) # to ignore model
parser.add_argument('--data', type=pl.LightningDataModule)
config = parser.parse_path('config.yaml')
config_init = parser.instantiate_classes(config)
The instantiated data module will be in config_init.data. In the pytorch-lightning source code the add of arguments is done slightly different but this argparse style should be more familiar to more people. Just for reference in lightning for subclass mode it is 
  
    
      pytorch-lightning/pytorch_lightning/utilities/cli.py
    
    
         Line 164
      in
      a7aed2a
    
  
  
    

        
          
           return self.add_subclass_arguments(lightning_class, nested_key, fail_untyped=False, required=required)