TL;DR
=====
PR#763 [2] breaks programmatic swarming as described in the
Predicting Sine Waves with NuPIC video [1]. The Running-Swarms wiki
[4] will be updated with new instructions as soon as the PR is merged.
The `run_swarms.py` CLI interface has not changed.
AMPLIFICATION
=============
When I recorded this tutorial on predicting sine waves with NuPIC [1],
it was a bit hacky to run a swarm from a script, get the resulting
model, and run data through the NuPIC model. A user needed to use a
CLI endpoint and pass fake CLI arguments into it. After that, users
needed to copy a file created by the swarm process into the current
working directory, import it with python, then use the model params to
create a new model.
I've submitted a PR that will simplify this process [2]. It splits the
CLI into a python library that can be used directly within python
scripts and the CLI now uses that library. This makes it easier for
programmers to run swarms within scripts.
Previously, this was required to swarm programmatically:
```
import shutil
import nupic.swarming.permutations_runner
swarm_def = "path/to/swarm_def.json"
# creates a model params in ./model_0/model_params.py
permutations_runner.runPermutations([swarm_def, "--maxWorkers=8",
"--overwrite"])
# must copy the model_params.py file so it can be imported
shutil.copyfile("model_0/model_params.py", "model_params.py")
# pythonistas hate importing in the middle of a module, so this is ugly
import model_params
model = ModelFactory.create(model_params.MODEL_PARAMS)
```
Now the function signature is simpler and it returns a model
parameters object directly:
```
import nupic.swarming.permutations_runner
swarm_config = {} # complete swarm config dictionary here
# notice the function name and signature change
model_params = permutations_runner.runWithConfig(swarm_config,
{'maxWorkers': 8, 'overwrite': True})
model = ModelFactory.create(model_params)
```
This means you can create swarm descriptions [3] easily within scripts
as dictionaries, where before you needed to write them out to JSON
files and specify the JSON file path to the permutations runner.
As soon as this PR is merged, I will update the Running Swarms wiki
page [4] with the new instructions on programmatic swarming and
comment on the video [1] with a warning about this change.
Any current scripts you run that use the old
`permutations_runner.runPermutations()` function will error with the
following message:
DeprecationWarning:
nupic.swarming.permutations_runner.runPermutations() is no longer
implemented. It has been replaced with a simpler function for library
usage: nupic.swarming.permutations_runner.runWithConfig(). See docs at
https://github.com/numenta/nupic/wiki/Running-Swarms#running-a-swarm-programmatically
for details.
[1] https://www.youtube.com/watch?v=KuFfm3ncEwI#t=19m20s
[2] https://github.com/numenta/nupic/pull/763
[3] https://github.com/numenta/nupic/wiki/Running-Swarms#the-swarm-description
[4] https://github.com/numenta/nupic/wiki/Running-Swarms
---------
Matt Taylor
OS Community Flag-Bearer
Numenta
_______________________________________________
nupic mailing list
[email protected]
http://lists.numenta.org/mailman/listinfo/nupic_lists.numenta.org