pythonpytorchcallbackhuggingface-transformersneptune

How to disable Neptune callback in transformers trainer runs?


After installing Neptune.ai for occasional ML experiments logging, it became included by default into the list of callbacks in all transformers.trainer runs. As a result, it requires proper initialisation with token or else throws NeptuneMissingConfiguration error, demanding token and project name. This is really annoying, I'd prefer Neptune callback to limit itself to warning or just have it disabled if no token is provided. Unfortunately there is no obvious way to disable this callback, short of uninstalling Neptune.ai altogether. The doc page at https://huggingface.co/docs/transformers/main_classes/callback states that this callback is enabled by default and gives no way to disable it (unlike some other callbacks that can be disabled by environment variable).

Question: how to disable Neptune callback on per run basis?


Solution

  • The reason Neptune is included is because the default value of report_to in TrainingArguments is "all", which implicitly includes all installed loggers from the officially supported list of loggers. You should either uninstall Neptune from the environment you use for the project, or pass report_to="none" to the TrainingArguments instance you use to initialize the Trainer (n.b.: that's the string literal "none", NOT a Python None).

    The other answers here, including the accepted answer, are either poor workarounds for this problem, or simply do not work at all. The proper way to handle this issue is as above.