How do you correctly subclass an Accelerator?
❓ Questions and Help
What is your question?
I am trying to subclass DDPCPUSpawnAccelerator for test purposes.
Trainer now has an accelerator argument for you to pass an accelerator object. On the other hand, the accelerator has a trainer argument. I asume the later can be initialized to None to avoid this chicken and egg issue.
However, the following snippet seems to get stuck.
Code
from pytorch_lightning import Trainer
from pytorch_lightning.accelerators import DDPCPUSpawnAccelerator
from pytorch_lightning.cluster_environments import TorchElasticEnvironment
from tests.base.boring_model import BoringModel


class TestAccelerator(DDPCPUSpawnAccelerator):
    def __init__(self, nprocs):
        super().__init__(None, nprocs, cluster_environment=TorchElasticEnvironment())

def test_accelerator(tmpdir):
    model = BoringModel()
    trainer = Trainer(
        default_root_dir=tmpdir,
        limit_train_batches=2,
        limit_val_batches=2,
        max_epochs=2,
        log_every_n_steps=1,
        weights_summary=None,
        accelerator=TestAccelerator(2)
    )
    trainer.fit(model)

What's your environment?

OS: Linux
Packaging: pip
Version: Master