Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved opf_helpers module to helpers #3610

Merged
merged 2 commits into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/opf/experiments/params/EnsembleOnline.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import random
import multiprocessing
import numpy as np
from nupic.frameworks.opf import opf_helpers
from nupic.frameworks.opf import helpers
from nupic.frameworks.opf.client import Client
from random import shuffle
from random import randrange, uniform
Expand Down Expand Up @@ -168,7 +168,7 @@ def getFieldPermutations(config, predictedField):


def getModelDescriptionLists(numProcesses, experiment):
config, control = opf_helpers.loadExperiment(experiment)
config, control = helpers.loadExperiment(experiment)
encodersList=getFieldPermutations(config, 'pounds')
ns=range(50, 140, 120)
clAlphas=np.arange(0.01, 0.16, 0.104)
Expand Down
4 changes: 2 additions & 2 deletions examples/opf/experiments/params/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from pprint import pprint
import time

from nupic.frameworks.opf import opf_helpers
from nupic.frameworks.opf import helpers
from nupic.frameworks.opf.client import Client

# Experiment directories relative to "trunk/examples/opf/experiments."
Expand All @@ -38,7 +38,7 @@ def testAll(experiments):
for experiment in experiments:
experimentBase = os.path.join(os.getcwd(), experimentsDir, experiment)

config, control = opf_helpers.loadExperiment(experimentBase)
config, control = helpers.loadExperiment(experimentBase)

if control['environment'] == 'opfExperiment':
experimentTasks = control['tasks']
Expand Down
6 changes: 3 additions & 3 deletions src/nupic/frameworks/opf/experiment_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import numpy

from nupic.data import json_helpers
from nupic.frameworks.opf import opf_basic_environment, opf_helpers
from nupic.frameworks.opf import opf_basic_environment, helpers
from nupic.frameworks.opf.exp_description_api import OpfEnvironment
from nupic.frameworks.opf.model_factory import ModelFactory
from nupic.frameworks.opf.opf_task_driver import OPFTaskDriver
Expand Down Expand Up @@ -401,9 +401,9 @@ def _runExperimentImpl(options, model=None):

# Load the experiment's description.py module
experimentDir = options.experimentDir
descriptionPyModule = opf_helpers.loadExperimentDescriptionScriptFromDir(
descriptionPyModule = helpers.loadExperimentDescriptionScriptFromDir(
experimentDir)
expIface = opf_helpers.getExperimentDescriptionInterfaceFromModule(
expIface = helpers.getExperimentDescriptionInterfaceFromModule(
descriptionPyModule)

# Handle "list checkpoints" request
Expand Down
6 changes: 3 additions & 3 deletions src/nupic/swarming/DummyModelRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import time

from nupic.frameworks.opf.model_factory import ModelFactory
from nupic.frameworks.opf import opf_helpers
from nupic.frameworks.opf import helpers
from nupic.frameworks.opf.opf_utils import ModelResult
from nupic.swarming import utils
from nupic.swarming.ModelRunner import OPFModelRunner
Expand Down Expand Up @@ -560,9 +560,9 @@ def __computeWaitTime(self):
def __createModel(self, expDir):
# -----------------------------------------------------------------------
# Load the experiment's description.py module
descriptionPyModule = opf_helpers.loadExperimentDescriptionScriptFromDir(
descriptionPyModule = helpers.loadExperimentDescriptionScriptFromDir(
expDir)
expIface = opf_helpers.getExperimentDescriptionInterfaceFromModule(
expIface = helpers.getExperimentDescriptionInterfaceFromModule(
descriptionPyModule)


Expand Down
4 changes: 2 additions & 2 deletions src/nupic/swarming/HypersearchV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from nupic.swarming.hypersearch.SwarmTerminator import SwarmTerminator
from nupic.swarming.hypersearch.HsState import HsState, HsSearchType

from nupic.frameworks.opf import opf_helpers
from nupic.frameworks.opf import helpers
from nupic.swarming.experimentutils import InferenceType
from nupic.swarming.utils import sortedJSONDumpS, rApply, rCopy
from nupic.swarming.utils import clippedObj
Expand Down Expand Up @@ -1018,7 +1018,7 @@ def __init__(self, searchParams, workerID=None, cjDAO=None, jobID=None,
self._baseDescriptionHash = hashlib.md5(self._baseDescription).digest()

# Read the model config to figure out the inference type
modelDescription, _ = opf_helpers.loadExperiment(self._basePath)
modelDescription, _ = helpers.loadExperiment(self._basePath)

# Read info from permutations file. This sets up the following member
# variables:
Expand Down
6 changes: 3 additions & 3 deletions src/nupic/swarming/ModelRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from nupic.swarming.hypersearch.errorcodes import ErrorCodes

from nupic.database.client_jobs_dao import ClientJobsDAO
from nupic.frameworks.opf import opf_helpers
from nupic.frameworks.opf import helpers
from nupic.frameworks.opf.model_factory import ModelFactory
from nupic.frameworks.opf.opf_basic_environment import BasicPredictionLogger
from nupic.frameworks.opf.opf_utils import matchPatterns
Expand Down Expand Up @@ -217,9 +217,9 @@ def run(self):
"""
# -----------------------------------------------------------------------
# Load the experiment's description.py module
descriptionPyModule = opf_helpers.loadExperimentDescriptionScriptFromDir(
descriptionPyModule = helpers.loadExperimentDescriptionScriptFromDir(
self._experimentDir)
expIface = opf_helpers.getExperimentDescriptionInterfaceFromModule(
expIface = helpers.getExperimentDescriptionInterfaceFromModule(
descriptionPyModule)
expIface.normalizeStreamSources()

Expand Down
11 changes: 6 additions & 5 deletions src/nupic/swarming/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import shutil
import tempfile

from nupic.frameworks.opf import opf_helpers
from nupic.frameworks.opf import helpers
from nupic.database.client_jobs_dao import ClientJobsDAO
from nupic.support.configuration import Configuration

Expand Down Expand Up @@ -80,7 +80,7 @@ def getSwarmModelParams(modelID):
JSON-encoded string containing Model Params
"""

# TODO: the use of opf_helpers.loadExperimentDescriptionScriptFromDir when
# TODO: the use of nupic.frameworks.opf.helpers.loadExperimentDescriptionScriptFromDir when
# retrieving module params results in a leakage of pf_base_descriptionNN and
# pf_descriptionNN module imports for every call to getSwarmModelParams, so
# the leakage is unlimited when getSwarmModelParams is called by a
Expand All @@ -96,7 +96,8 @@ def getSwarmModelParams(modelID):
(baseDescription,) = cjDAO.jobGetFields(jobID, ["genBaseDescription"])

# Construct a directory with base.py and description.py for loading model
# params, and use opf_helpers to extract model params from those files
# params, and use nupic.frameworks.opf.helpers to extract model params from
# those files
descriptionDirectory = tempfile.mkdtemp()
try:
baseDescriptionFilePath = os.path.join(descriptionDirectory, "base.py")
Expand All @@ -107,8 +108,8 @@ def getSwarmModelParams(modelID):
with open(descriptionFilePath, mode="wb") as f:
f.write(description)

expIface = opf_helpers.getExperimentDescriptionInterfaceFromModule(
opf_helpers.loadExperimentDescriptionScriptFromDir(descriptionDirectory))
expIface = helpers.getExperimentDescriptionInterfaceFromModule(
helpers.loadExperimentDescriptionScriptFromDir(descriptionDirectory))

return json.dumps(
dict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from pkg_resources import resource_filename


from nupic.frameworks.opf.opf_helpers import (
from nupic.frameworks.opf.helpers import (
loadExperimentDescriptionScriptFromDir,
getExperimentDescriptionInterfaceFromModule
)
Expand Down