本文整理汇总了Python中opus_core.session_configuration.SessionConfiguration.has_dataset方法的典型用法代码示例。如果您正苦于以下问题:Python SessionConfiguration.has_dataset方法的具体用法?Python SessionConfiguration.has_dataset怎么用?Python SessionConfiguration.has_dataset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opus_core.session_configuration.SessionConfiguration
的用法示例。
在下文中一共展示了SessionConfiguration.has_dataset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: flush_datasets
# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import has_dataset [as 别名]
def flush_datasets(self, dataset_names, after_model=False):
dataset_pool = SessionConfiguration().get_dataset_pool()
for dataset_name in dataset_names:
if dataset_pool.has_dataset(dataset_name):
self.flush_dataset(dataset_pool.get_dataset(dataset_name), after_model=after_model)
示例2: _run_year
# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import has_dataset [as 别名]
#.........这里部分代码省略.........
# 'model_name_4',
# {'model_name_5': {'group_members': 'all'}}
# ]
# get list of methods to be processed evtl. for each group member
if isinstance(model_entry, dict):
model_name, value = model_entry.items()[0]
if not isinstance(value, dict): # is a model group
processes = value
if not isinstance(processes, list):
processes = [processes]
else: # in the form 'model_name_4' in the comment above
model_name = model_entry
processes = ["run"]
group_member = None
model_group = model_group_members_to_run[model_name][1]
last_member = max(1, len(model_group_members_to_run[model_name][0].keys()))
for imember in range(last_member):
controller_config = models_configuration[model_name]["controller"]
model_configuration = models_configuration[model_name]
if model_group_members_to_run[model_name][0].keys():
group_member_name = model_group_members_to_run[model_name][0].keys()[imember]
group_member = ModelGroupMember(model_group, group_member_name)
processes = model_group_members_to_run[model_name][0][group_member_name]
member_model_name = "%s_%s" % (group_member_name, model_name)
if member_model_name in models_configuration.keys():
model_configuration = models_configuration[member_model_name]
if "controller" in model_configuration.keys():
controller_config = model_configuration["controller"]
datasets_to_preload_for_this_model = controller_config.get(
"_model_structure_dependencies_", {}
).get("dataset", [])
for dataset_name in datasets_to_preload_for_this_model:
try:
if not dataset_pool.has_dataset(dataset_name) or (dataset_name not in datasets.keys()):
ds = dataset_pool.get_dataset(dataset_name)
self.vardict[dataset_name] = ds
datasets[dataset_name] = ds
exec "%s=ds" % dataset_name
except:
logger.log_warning("Failed to load dataset %s." % dataset_name)
# import part
if "import" in controller_config.keys():
import_config = controller_config["import"]
for import_module in import_config.keys():
exec ("from %s import %s" % (import_module, import_config[import_module]))
# gui_import_replacements part
# This is a temporary hack -- replicates the functionality of the "import" section
# for use with the GUI. The contents of this part of the config is a dictionary.
# Keys are names of models (not used here). Values are 2 element pairs.
# The first element is a name and the second is a value. Bind the name to the value.
if "gui_import_replacements" in controller_config.keys():
import_replacement_config = controller_config["gui_import_replacements"]
for model_name in import_replacement_config.keys():
pair = import_replacement_config[model_name]
temp = pair[1]
exec ("%s = temp") % pair[0]
# init part
model = self.do_init(locals())
# estimate and/or run part
for process in processes:
model_number = model_number + 1
# write status file
model.set_model_system_status_parameters(
示例3: range
# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import has_dataset [as 别名]
if refinements is None:
refinements = dataset_pool.get_dataset('refinement')
years = refinements.get_attribute('year')
if start_year is None: start_year = years.min()
if end_year is None: end_year = years.max()
for year in range(start_year, end_year+1):
logger.start_block("Doing refinement for %s" % year )
simulation_state.set_current_time(year)
## reload refinements, from original refinement_directory or dataset_pool, in case it's been changed by refinement model
if refinements_storage is not None:
refinements = DatasetFactory().search_for_dataset('refinement', package_order, arguments={'in_storage':refinements_storage})
else:
refinements = dataset_pool.get_dataset('refinement')
if options.backup:
src_dir = os.path.join(options.cache_directory, str(year))
dst_dir = os.path.join(options.cache_directory, 'backup', str(year))
if os.path.exists(src_dir):
logger.log_status("Backing up %s to %s" % (src_dir, dst_dir))
copytree(src_dir, dst_dir)
RefinementModel().run(refinements, current_year=year, dataset_pool=dataset_pool)
if dataset_pool.has_dataset('refinement'):
#avoid caching refinements
dataset_pool._remove_dataset('refinement')
dataset_pool.flush_loaded_datasets()
dataset_pool.remove_all_datasets()
logger.end_block()