numenta/NAB

Cannot run numenta detector in python 2

breznak opened this issue · 3 comments

according to Readme in branch #341

I needed a few changes to get nupic (numenta detector) install at all.

Then it seems to be running, but does not at all?

Finished processing dependencies for nab==1.0
(env2) mmm@mmm-U2442:/mnt/store/devel/HTM/NAB$ python nab/detectors/numenta/run.py -d numenta --detect
{'dataDir': 'data',
'detectors': [],
'numCPUs': None,
'profilesFile': 'config/profiles.json',
'resultsDir': 'results',
'skipConfirmation': False,
'windowsFile': 'labels/combined_windows.json'}
Proceed? (y/n): y
Running detection step
(env2) mmm@mmm-U2442:/mnt/store/devel/HTM/NAB$ echo $?
0

Notice the detectors field is empty?

See iandanforth#8 but it does not fix the issue, just makes me able to install nupic.

Fascinating bug. See https://bugs.python.org/issue10981.

  • I had removed --detect as a valid argument (that's all this version of run.py does)
  • Argparse supports abbreviations for long arguments, see: https://docs.python.org/2.7/library/argparse.html#argument-abbreviations-prefix-matching
  • This meant that --detect was being interpreted as an abbreviation of --detectors
  • In the command provided by @breznak there were both the short (-d) and abbreviated long (--detect) versions of this argument and the second one was taking presidence.
  • Because the second argument had no value list the detectors key ended up pointing to an empty list.

The easiest way to fix this is to simply re-add --detect as a no-op argument which will disambiguate it from --detectors and let others who may be used to typing it by habit suffer no ill effects.

Tips had how did you figure this! :) Bugs never cease to amaze us.
Thanks for providing a fix