Search code examples
pythongitjupyter-notebooktraceback

How to fix Traceback to old code version?


I run my code in Jupyter-notebook and it tracesback an error to an older file version (the actual file does not have the error code inside anymore)

I updated ipython, I tried to relaunched Jupyter, I reopened the (previously erroneuos) file, and restarted the whole computer. Nothing works!

This is the traceback error:

TypeError                                 Traceback (most recent call last)

<ipython-input-34-b46c17b92e93> in batchGenerator(self, DG_list, batch_size, output_format)
    233             batches = []
    234             for DG in DG_list:
--> 235                 batches.append(DG.generate(batchIDs,output_format))
    236             yield tuple(batches) # match output type to keras fit_generator generator function
    237 

~\PycharmProjects\MMOP\ADT\DataGeneratorADT.py in generate(self, IDList, outputFormat)
    222                         if header != self._DUF_columns:
    223                             warnings.warn('The DUF header is not consistent with the DG setting. It is now set to:',
--> 224                                           header)
    225                             self._DUF_columns = header
    226                     list_reader = list(reader)

TypeError: category must be a Warning subclass, not 'list'

And this is the actual code in the file (when loaded in Jupyter):

file = open('DataGeneratorADT.py','r')
content  = file.read()
print(content)

the relevant lines of code:

if header != self._DUF_columns:
    print('The DUF header is not consistent with the DG setting. It is now set to:' + header)
    self._DUF_columns = header

I expect to have to error about the Warning since I deleted it and replaced it by print.


Solution

  • Seems that 2 problems caused this error:

    1. The Jupyter code tries to access the code on the master, although I was checked-out on another specific branch. According to this thread it's not suppose to happen but that's still the situation.
    2. The call to the module was linked to a persistent clutter file (that was not affected by any commit or restart). This was solved by using the command : git gc. The above command removes temp and unnecessary files. (Garbage collector)