facebookresearch / dora

Dora is an experiment management framework. It expresses grid searches as pure python files as part of your repo. It identifies experiments with a unique hash signature. Scale up to hundreds of experiments without losing your sanity.
MIT License
269 stars 24 forks source link

Callbacks default is None #23

Closed louismartin closed 2 years ago

louismartin commented 2 years ago

https://github.com/facebookresearch/dora/blob/a23ce113d4e85fe1d7d40d82faea8013d2bc44a8/dora/lightning.py#L173

When calling trainer = dora.lightning.get_trainer() I get

Traceback (most recent call last):
  File "/private/home/louismartin/dev/tap/tap/train.py", line 60, in main
    train(cfg=cfg)
  File "/private/home/louismartin/dev/tap/tap/train.py", line 26, in train
    trainer = dora.lightning.get_trainer()
  File "/private/home/louismartin/dev/dora/dora/lightning.py", line 175, in get_trainer
    callbacks.append(DoraCheckpointSync())
AttributeError: 'NoneType' object has no attribute 'append'

This is because the default value for callbacks in the Trainer.__init__ signature (retrieved here kwargs = inspect.getcallargs(init, [None] + list(args), **kwargs)) is None. Hence callbacks = kwargs.pop("callbacks", []) returns None instead of [].

pytorch-lightning==1.5.10

louismartin commented 2 years ago

callbacks = kwargs.pop("callbacks", None) or [] solves the problem for me.

adefossez commented 2 years ago

should be fixed with 4e16e06695927eac7ebea33020ada3b8fcf6e6ad