Fastai version 1.0.54.
I’ve come across this error message a number of times:
AttributeError: 'method-wrapper' object has no attribute '__code__'
which originates from this line of code in callback.py
def __repr__(self):
attrs = func_args(self.__init__) # <---
....
and at that time, self.__init__
does indeed have type 'method-wrapper
It is easy to reproduce this error. It seems to happen with any LearnerCallback:
from fastai import callbacks
learner = # some learner object
cb = callbacks.MixUpCallback(learner)
cb # attempt to print callback invokes __repr__ causing error
I don’t really grok what is happening in the LearnerCallback class, but I suspect that it is the LearnerCallback.__getattr__
method that is causing the wrapping, and hence the error. But this seems like a mainstream code path, so it should work usually, but how?
In any case is there a way to mitigate this issue? It comes up when debugging, if you attempt to print any callback, or anything that includes a callback in its representation.