本文整理汇总了Python中experiment.Experiment.load_from_config方法的典型用法代码示例。如果您正苦于以下问题:Python Experiment.load_from_config方法的具体用法?Python Experiment.load_from_config怎么用?Python Experiment.load_from_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类experiment.Experiment
的用法示例。
在下文中一共展示了Experiment.load_from_config方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from experiment import Experiment [as 别名]
# 或者: from experiment.Experiment import load_from_config [as 别名]
def load(self, dirname):
""" Loads the project from the given directory. The existing state
of the project is completely modified.
"""
# TODO: We should formalize this dependency at some point and move
# this import to the top level
from configobj import ConfigObj
if dirname == "":
raise IOError("Cannot load project from empty path.")
elif not os.path.isdir(dirname):
raise IOError("Cannot find directory: " + dirname)
filename = abspath(join(dirname, self.PROJECT_FILE_NAME))
if not os.path.isfile(filename):
raise IOError('Cannot load %s from project directory "%s".' % \
(self.PROJECT_FILE_NAME, dirname))
# Every project is saved as a text ConfigObj file that describes
# the name and location of the real data files.
configspec = ConfigObj(self.CONFIG_SPEC, list_values=False)
config = ConfigObj(filename, configspec=configspec)
contexts = []
for context_config in config["Contexts"].values():
ctx = DataContext.load(join(dirname, context_config["file"]))
ctx.name = context_config["name"]
contexts.append(ctx)
self.contexts = contexts
experiments = []
if hasattr(scripting, "app"):
app = scripting.app
else:
app = None
for exp_config in config["Experiments"].values():
experiment = Experiment()
exp_dir = join(dirname, exp_config["save_dir"])
experiment.load_from_config(exp_config, exp_dir, project=self)
experiments.append(experiment)
self.experiments = experiments
proj_config = config["Project"]
if proj_config.has_key("active_experiment"):
self.active_experiment = self.find_experiment(proj_config["active_experiment"])
# Update Project Save Path
self.project_save_path = dirname
return