本文整理匯總了Python中nupic.database.ClientJobsDAO.ClientJobsDAO.get方法的典型用法代碼示例。如果您正苦於以下問題:Python ClientJobsDAO.get方法的具體用法?Python ClientJobsDAO.get怎麽用?Python ClientJobsDAO.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nupic.database.ClientJobsDAO.ClientJobsDAO
的用法示例。
在下文中一共展示了ClientJobsDAO.get方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getSwarmModelParams
# 需要導入模塊: from nupic.database.ClientJobsDAO import ClientJobsDAO [as 別名]
# 或者: from nupic.database.ClientJobsDAO.ClientJobsDAO import get [as 別名]
def getSwarmModelParams(modelID):
"""Retrieve the Engine-level model params from a Swarm model
Args:
modelID - Engine-level model ID of the Swarm model
Returns:
JSON-encoded string containing Model Params
"""
# TODO: the use of opfhelpers.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
# long-running process such as grok-api-server. This issue is presently being
# tracked by the JIRA: https://issues.numenta.org/browse/NPC-225. An
# alternate solution is to execute the guts of this function's logic in a
# seprate process (via multiprocessing module).
cjDAO = ClientJobsDAO.get()
(jobID, description) = cjDAO.modelsGetFields(
modelID,
["jobId", "genDescription"])
(baseDescription,) = cjDAO.jobGetFields(jobID, ["genBaseDescription"])
# Construct a directory with base.py and description.py for loading model
# params, and use opfhelpers to extract model params from those files
descriptionDirectory = tempfile.mkdtemp()
try:
baseDescriptionFilePath = os.path.join(descriptionDirectory, "base.py")
with open(baseDescriptionFilePath, mode="wb") as f:
f.write(baseDescription)
descriptionFilePath = os.path.join(descriptionDirectory, "description.py")
with open(descriptionFilePath, mode="wb") as f:
f.write(description)
expIface = opfhelpers.getExperimentDescriptionInterfaceFromModule(
opfhelpers.loadExperimentDescriptionScriptFromDir(descriptionDirectory))
return json.dumps(
dict(
modelConfig=expIface.getModelDescription(),
inferenceArgs=expIface.getModelControl().get("inferenceArgs", None)))
finally:
shutil.rmtree(descriptionDirectory, ignore_errors=True)