htm-community / htm.core

Actively developed Hierarchical Temporal Memory (HTM) community fork (continuation) of NuPIC. Implementation for C++ and Python
http://numenta.org
GNU Affero General Public License v3.0
150 stars 74 forks source link

Validate python nupic is still compatible with our nupic.core c++ bindings #137

Closed breznak closed 5 years ago

breznak commented 5 years ago

c++ provides nupic.bindings; nupic(py) is the main (currently only) user of it, verify we didn't break any API.

Even local test is ok for now. TODO

Relevant: #104 #81

breznak commented 5 years ago

I've installed nupic from pip only (pip install nupic), pulls nupic.bindings with it too. Got some errors? I don't understand if are errors:

================================================================== pytest-warning summary ===================================================================
WC1 /mnt/store/devel/HTM/nupic-source/tests/unit/nupic/engine/network_test.py cannot collect test class 'TestNode' because it has a __init__ constructor
WC1 /mnt/store/devel/HTM/nupic-source/tests/unit/nupic/frameworks/opf/htmpredictionmodel_classifier_helper_test.py cannot collect test class 'TestOptionParser' because it has a __init__ constructor
WC1 /mnt/store/devel/HTM/nupic-source/tests/unit/nupic/regions/knn_anomaly_classifier_region_test.py cannot collect test class 'TestOptionParser' because it has a __init__ constructor
WC1 /mnt/store/devel/HTM/nupic-source/tests/unit/nupic/support/decorators_test.py cannot collect test class 'TestParentException' because it has a __init__ constructor
WC1 /mnt/store/devel/HTM/nupic-source/tests/unit/nupic/support/decorators_test.py cannot collect test class 'TestChildException' because it has a __init__ constructor
========================================== 713 passed, 17 skipped, 8 xfailed, 5 pytest-warnings in 188.62 seconds ===
breznak commented 5 years ago

Replacing binary bindings with ones from our repo:

pip uninstall nupic.bindings
python $NUPIC_CORE/setup.py install

Many PY tests fail due to capnp remains:

capnp
__________________________________________ ERROR collecting tests/unit/nupic/regions/sdr_classifier_region_test.py __________________________________________
tests/unit/nupic/regions/sdr_classifier_region_test.py:27: in <module>
    from nupic.encoders import MultiEncoder
../pyenv/lib/python2.7/site-packages/nupic/encoders/__init__.py:23: in <module>
    from random_distributed_scalar import RandomDistributedScalarEncoder
../pyenv/lib/python2.7/site-packages/nupic/encoders/random_distributed_scalar.py:38: in <module>
    from nupic.encoders.random_distributed_scalar_capnp import (
capnp/lib/capnp.pyx:3947: in capnp.lib.capnp._Loader.load_module (capnp/lib/capnp.cpp:75560)
    ???
capnp/lib/capnp.pyx:3926: in capnp.lib.capnp.load (capnp/lib/capnp.cpp:75048)
    ???
capnp/lib/capnp.pyx:3247: in capnp.lib.capnp.SchemaParser.load (capnp/lib/capnp.cpp:65930)
    ???
E   KjException: src/capnp/compiler/node-translator.c++:2090: context: member.name = random
E   /mnt/store/devel/HTM/pyenv/lib/python2.7/site-packages/nupic/encoders/random_distributed_scalar.capnp:2: failed: Import failed: /nupic/proto/RandomProto.capnp
________________________________________________ ERROR collecting tests/unit/nupic/regions/tm_region_test.py ________________________________________________
ImportError while importing test module '/mnt/store/devel/HTM/nupic-source/tests/unit/nupic/regions/tm_region_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/unit/nupic/regions/tm_region_test.py:33: in <module>
    from nupic.regions.tm_region import TMRegion
../pyenv/lib/python2.7/site-packages/nupic/regions/tm_region.py:32: in <module>
    from nupic.algorithms import (anomaly, backtracking_tm, backtracking_tm_cpp,
../pyenv/lib/python2.7/site-packages/nupic/algorithms/__init__.py:28: in <module>
    from nupic.bindings.algorithms import svm_01, svm_dense
E   ImportError: cannot import name svm_01
================================================================== pytest-warning summary ===================================================================
WC1 /mnt/store/devel/HTM/nupic-source/tests/unit/nupic/support/decorators_test.py cannot collect test class 'TestParentException' because it has a __init__ constructor
WC1 /mnt/store/devel/HTM/nupic-source/tests/unit/nupic/support/decorators_test.py cannot collect test class 'TestChildException' because it has a __init__ constructor
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 47 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================== 2 pytest-warnings, 47 error in 1.65 seconds

This needs to be fixed/aligned in the community py repo.

dkeeney commented 5 years ago

Hmmm, I was hoping that the capnp in nupic .py code would just go away...but we broke the API and now I guess we must pay the consequences.

Not sure what the best fix would be for this. This may be a big job. First, synch the community nupic .py code with the numenta repository. At least get as close to their code as possible.

Then we could go through the community nupic .py code and fix the capnp and at the same time make the modifications so that it could run with both Python2.7 and Python3. When that is finished, our .py code is different from the numenta repository and the possibility of our .py code being absorbed back into numenta becomes less likely. But I don't know what else we could do.

This will be lots of PR's.

On Sat, Dec 1, 2018 at 4:33 AM breznak notifications@github.com wrote:

Replacing binary bindings with ones from our repo:

pip uninstall nupic.bindings python $NUPIC_CORE/setup.py install

Many PY tests fail due to capnp remains:

capnp __ ERROR collecting tests/unit/nupic/regions/sdr_classifier_region_test.py __ tests/unit/nupic/regions/sdr_classifier_region_test.py:27: in from nupic.encoders import MultiEncoder ../pyenv/lib/python2.7/site-packages/nupic/encoders/init.py:23: in from random_distributed_scalar import RandomDistributedScalarEncoder ../pyenv/lib/python2.7/site-packages/nupic/encoders/random_distributed_scalar.py:38: in from nupic.encoders.random_distributed_scalar_capnp import ( capnp/lib/capnp.pyx:3947: in capnp.lib.capnp._Loader.load_module (capnp/lib/capnp.cpp:75560) ??? capnp/lib/capnp.pyx:3926: in capnp.lib.capnp.load (capnp/lib/capnp.cpp:75048) ??? capnp/lib/capnp.pyx:3247: in capnp.lib.capnp.SchemaParser.load (capnp/lib/capnp.cpp:65930) ??? E KjException: src/capnp/compiler/node-translator.c++:2090: context: member.name = random E /mnt/store/devel/HTM/pyenv/lib/python2.7/site-packages/nupic/encoders/random_distributed_scalar.capnp:2: failed: Import failed: /nupic/proto/RandomProto.capnp ____ ERROR collecting tests/unit/nupic/regions/tm_region_test.py ____ ImportError while importing test module '/mnt/store/devel/HTM/nupic-source/tests/unit/nupic/regions/tm_region_test.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: tests/unit/nupic/regions/tm_region_test.py:33: in from nupic.regions.tm_region import TMRegion ../pyenv/lib/python2.7/site-packages/nupic/regions/tm_region.py:32: in from nupic.algorithms import (anomaly, backtracking_tm, backtracking_tm_cpp, ../pyenv/lib/python2.7/site-packages/nupic/algorithms/init.py:28: in from nupic.bindings.algorithms import svm_01, svm_dense E ImportError: cannot import name svm_01 ================================================================== pytest-warning summary =================================================================== WC1 /mnt/store/devel/HTM/nupic-source/tests/unit/nupic/support/decorators_test.py cannot collect test class 'TestParentException' because it has a init constructor WC1 /mnt/store/devel/HTM/nupic-source/tests/unit/nupic/support/decorators_test.py cannot collect test class 'TestChildException' because it has a init constructor !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 47 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ======================================================== 2 pytest-warnings, 47 error in 1.65 seconds

This needs to be fixed/aligned in the community py repo.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/htm-community/nupic.cpp/issues/137#issuecomment-443423033, or mute the thread https://github.com/notifications/unsubscribe-auth/AFBa_yEgOIFnDSt45gHsL6h3lWgcxDWwks5u0ncLgaJpZM4Y81yn .

breznak commented 5 years ago

First, synch the community nupic .py code with the numenta repository. At least get as close to their code as possible.

We made no changes, so that will be simple.

Then we could go through the community nupic .py code and fix the capnp and at the same time make the modifications so that it could run with both Python2.7 and Python3.

I'd do one at a time, just capnp now. It'll be lot of changes but hopefully not too difficult:

When that is finished, our .py code is different from the numenta repository and the possibility of our .py code being absorbed back into numenta becomes less likely.

I see, you're aiming to merge Py3 code to numenta's? Well, 2 ideas here:

TL;DR: same as with capnp removal, I'd keep the burden on numenta, if they want to merge back the Py3 changes.

breznak commented 5 years ago

For anyone interested in helping, please start looking at https://github.com/htm-community/nupic.py/pull/4

ctrl-z-9000-times commented 5 years ago

At this point the answer to the question "is our fork compatible with nupic.py?" is clearly no, we are not compatible. There have been several large API breaking changes, including:

At the time, each of these changes was justified. Now the goal is to deliver a cohesive software package. To this end we should incorporate the contents of nupic.py into this repository by merging it and fixing the compatibility issues. See issue #216.