本文整理汇总了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)