# Nupic.core Extraction Plan

**URL:** <https://discourse.numenta.org/t/nupic-core-extraction-plan/2115>\
**Category:** NuPIC\
**Tags:** planning, nupic-wiki\
**Created:** [April 5, 2017, 8:55pm UTC](https://discourse.numenta.org/t/nupic-core-extraction-plan/2115 "2017-04-05T20:55:51Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![rhyolight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/rhyolight/32/3922_2.png) [@rhyolight](https://discourse.numenta.org/u/rhyolight)\
**Post date:** [April 5, 2017, 8:55pm UTC](https://discourse.numenta.org/t/nupic-core-extraction-plan/2115/1 "2017-04-05T20:55:51Z")

</div>

NuPIC is currently undergoing a major refactoring, with the goal of extracting a C++ “core” that contains all CLA algorithms. This will provide a core repository so other language bindings can be created aside from Python. The extraction plan for this refactoring is detailed below and kept up-to-date by [Matt Taylor](http://github.com/rhyolight).

* * *

## NuPIC Today

![NuPIC today](https://canada1.discourse-cdn.com/flex030/uploads/numenta/original/2X/d/d1fe8494a793892b0fbfe9ed94042302f84a3d05.jpg)

- One repo: [`nupic`](https://github.com/numenta/nupic)
- primary interface: python
  - all examples are python
  - all tutorials are python

- underlying C++ interface that no one uses
- C++ is compiled with SWIG with python bindings

## The Goal

 ![NuPIC today](https://canada1.discourse-cdn.com/flex030/uploads/numenta/original/2X/e/e9bb789c1bba851ea781c00b2045e13e7f10e6aa.jpg)

- `nupic.core` contains all C++
  - all algorithms are implemented in C++
  - complete API documentation
  - tutorials for direct usage of C++ API with C++ client
  - tutorial for creating language bindings

- python binding and client created from `nupic` project python code
  - community is responsible for creating bindings and clients in other environments

- undecided whether language bindings and clients will be combined or in different repos
- undecided naming scheme for bindings and clients, but we should provide guidance with python

# ~~Step 1: Initial Split~~

### Summary of initiatives:

1. ~~Split `nupic` into two repositories~~

- `nupic.core`
- `nupic`

1. ~~Update `nupic` build process to accommodate these changes~~

- ~~checkout and build `nupic.core` as a dependency~~
- ~~decide what a passing build means by these new standards~~

1. ~~Establish an independent `nupic.core` build process~~

- ~~have `nupic` start using the `nupic.core` build instead of building it itself~~

![NuPIC today](https://canada1.discourse-cdn.com/flex030/uploads/numenta/original/2X/d/d97a40ba7c236db62d23f5f2e8028d5c0f77e891.jpg)

`nupic.core` will contain only C++ code with minimal dependencies. `nupic` will contain everything else currently within `nupic`.

### Tasks:

- ~~Clean up existing build script [nupic #583](https://github.com/numenta/nupic/issues/583)~~
- ~~Remove all python traces from nupic in preparation for nupic.core [nupic #584](https://github.com/numenta/nupic/issues/584)~~
- ~~Create nupic.core repository in github [nupic #585](https://github.com/numenta/nupic/issues/585)~~
- ~~Remove C++ code from nupic repository and add nupic.core dependency [nupic #587](https://github.com/numenta/nupic/issues/587)~~
- ~~Ensure nupic python tests pass after nupic.core dependency has been added [nupic #588](https://github.com/numenta/nupic/issues/588)~~
- ~~Create a mechanism to update the nupic.core dependency from nupic with every push to nupic.core master [#590](https://github.com/numenta/nupic/issues/590)~~
- ~~Update nupic build to CMake [nupic #647](https://github.com/numenta/nupic/issues/647)~~
  - ~~Travis runs cmake builds in clang & gcc~~
  - ~~Update README build instructions for cmake~~
  - ~~Deprecates `build.sh` process in favor of cmake~~

- ~~Remove old build process and artifacts from nupic [nupic #673](https://github.com/numenta/nupic/issues/673)~~
- ~~Establish independent nupic.core build process [nupic.core #4](https://github.com/numenta/nupic.core/issues/4)~~
  - ~~Document the proposed directory structure for nupic.core and nupic [#591]~~([https://github.com/numenta/nupic/issues/591](https://github.com/numenta/nupic/issues/591))
  - ~~Run nupic.core build and tests in Travis-CI [nupic.core #5](https://github.com/numenta/nupic.core/issues/5)~~
  - ~~Ensure all C++ tests pass within new core c-only project [nupic.core #9](https://github.com/numenta/nupic.core/issues/9)~~
  - ~~Implement new directory structures~~
    - ~~for nupic [nupic #624](https://github.com/numenta/nupic/issues/624) (optional for this step)~~
    - ~~for nupic.core [nupic.core #15](https://github.com/numenta/nupic.core/issues/15)~~

- ~~Switch `nupic` to use the `nupic.core` build system [nupic #625](https://github.com/numenta/nupic/issues/625)~~

# Step 2: Prepare for `nupic.core` release

In order to provide a stable `nupic.core` for developers to program language bindings and clients against, we need to have a stable `v1.0` release. Requirements for a stable release are defined below.

### Requirements

The following requirements do not affect each other and can be worked upon simultaneously.

#### 1. Define API with Tests

To ensure backwards-compatibility, a new test suite must be created for `nupic.core` that exercises all public API endpoints. These tests do not need to be extensive functional tests, but they do need to validate the signatures of the endpoints (both input and output) and assert basic expectations about the structure of the public API. **This test suite MUST cover all classes and functions that are expected to be a part of the API.**

![NuPIC today](https://canada1.discourse-cdn.com/flex030/uploads/numenta/original/2X/e/ef7aa454ef4598954874129bde37ff2cf4e2d581.jpg)

The API tests exist to establish a contract that can be run in the CI pipeline that will identify breaking API changes in future pull requests. It also makes it obvious for reviewers when a PR modifies an API tests that backwards compatibility is intentionally being broken.

#### 2. Consolidate All CLA Algorithms in `nupic.core`

`nupic.core` MUST contain all CLA algorithms before it can be released, simply because it is incomplete otherwise.

![NuPIC today](https://canada1.discourse-cdn.com/flex030/uploads/numenta/original/2X/e/edd215e8f504b12694306a9e4bb7c6d76d723bb8.jpg)

The following necessary components must be translated from Python in `nupic` into C++ in `nupic.core`:

- current “temporal pooler” (sequence memory)

This should not change the `nupic.core` API defined by the API tests.

#### 3. Remove Unused Code From `nupic.core`

Identify and remove unused code.

# Step 3: Release `nupic.core-v1.0`

Creating a stable release fork for `nupic.core` is essential for client programmers to create tools for running NuPIC in different environments.

We’ll discuss options for the mechanics of this work on the nupic-hackers mailing list at the appropriate time and fill this section in with the results.

# Step 4: Create python language binding and client library

Our first official client library will be a conversion of `nupic` into `nupic-py` (bindings) and `nupic-py-client` (OPF client). This will be a functional example of how to create a client for other programmers of bindings and clients.

Work on this step can be done immediately after Step 1 above is complete. Steps 2/3 above are not prerequisites.

### Summary of initiatives:

1. Split `nupic` into two repositories:

- `nupic-py`: contains only Python language bindings
- `nupic-py-client`: contains OPF, encoders, etc. used by Grok

1. Update CI process to accommodate three repositories

- Does a `nupic.core` change trigger builds for all repos synchronously?
- How does the bindings repo include the core?
- How does the python client include the bindings?

![NuPIC today](https://canada1.discourse-cdn.com/flex030/uploads/numenta/original/2X/4/4f4ef58f14b183cf39b8c165aab72a80516ed0bb.jpg)

---

_[View the full topic](https://discourse.numenta.org/t/nupic-core-extraction-plan/2115)._
