本文整理汇总了Python中tvb.interfaces.web.controllers.base_controller.get_from_session函数的典型用法代码示例。如果您正苦于以下问题:Python get_from_session函数的具体用法?Python get_from_session怎么用?Python get_from_session使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_from_session函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: step_2
def step_2(self, **kwargs):
"""
Generate the html for the second step of the local connectivity page.
:param kwargs: not actually used, but parameters are still submitted from UI since we just\
use the same js function for this. TODO: do this in a smarter way
"""
context = base.get_from_session(KEY_LCONN_CONTEXT)
left_side_interface = self.get_select_existent_entities('Load Local Connectivity:', LocalConnectivity,
context.selected_entity)
template_specification = dict(title="Surface - Local Connectivity")
template_specification['mainContent'] = 'spatial/local_connectivity_step2_main'
template_specification['existentEntitiesInputList'] = left_side_interface
template_specification['loadExistentEntityUrl'] = LOAD_EXISTING_URL
template_specification['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
template_specification['next_step_url'] = '/spatial/localconnectivity/step_1'
template_specification['displayedMessage'] = base.get_from_session(base.KEY_MESSAGE)
context = base.get_from_session(KEY_LCONN_CONTEXT)
if context.selected_entity is not None:
selected_local_conn = ABCAdapter.load_entity_by_gid(context.selected_entity)
template_specification.update(self.display_surface(selected_local_conn.surface.gid))
template_specification['no_local_connectivity'] = False
else:
template_specification['no_local_connectivity'] = True
template_specification[base.KEY_PARAMETERS_CONFIG] = False
return self.fill_default_attributes(template_specification)
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:25,代码来源:local_connectivity_controller.py
示例2: step_1
def step_1(self, do_reset=0, **kwargs):
"""
Generate the html for the first step of the local connectivity page.
:param kwargs: not actually used, but parameters are still submitted from UI since we just\
use the same js function for this. TODO: do this in a smarter way
"""
if int(do_reset) == 1:
new_context = ContextLocalConnectivity()
base.add2session(KEY_LCONN_CONTEXT, new_context)
context = base.get_from_session(KEY_LCONN_CONTEXT)
right_side_interface = self._get_lconn_interface()
left_side_interface = self.get_select_existent_entities('Load Local Connectivity', LocalConnectivity,
context.selected_entity)
#add interface to session, needed for filters
self.add_interface_to_session(left_side_interface, right_side_interface['inputList'])
template_specification = dict(title="Surface - Local Connectivity")
template_specification['mainContent'] = 'spatial/local_connectivity_step1_main'
template_specification.update(right_side_interface)
template_specification['displayCreateLocalConnectivityBtn'] = True
template_specification['loadExistentEntityUrl'] = LOAD_EXISTING_URL
template_specification['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
template_specification['existentEntitiesInputList'] = left_side_interface
template_specification['submit_parameters_url'] = '/spatial/localconnectivity/create_local_connectivity'
template_specification['equationViewerUrl'] = '/spatial/localconnectivity/get_equation_chart'
template_specification['equationsPrefixes'] = json.dumps(self.plotted_equations_prefixes)
template_specification['next_step_url'] = '/spatial/localconnectivity/step_2'
template_specification['displayedMessage'] = base.get_from_session(base.KEY_MESSAGE)
return self.fill_default_attributes(template_specification)
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:28,代码来源:local_connectivity_controller.py
示例3: get_stimulus_chunk
def get_stimulus_chunk(self, chunk_idx):
"""
Get the next chunk of the stimulus data.
"""
stimulus = base.get_from_session(KEY_STIMULUS)
surface_gid = base.get_from_session(PARAM_SURFACE)
chunk_idx = int(chunk_idx)
if stimulus.surface.gid != surface_gid:
raise Exception("TODO: Surface changed while visualizing stimulus. See how to handle this.")
data = []
for idx in range(chunk_idx * CHUNK_SIZE,
min((chunk_idx + 1) * CHUNK_SIZE, stimulus.temporal_pattern.shape[1]), 1):
data.append(stimulus(idx).tolist())
return data
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:14,代码来源:surface_stimulus_controller.py
示例4: fill_default_attributes
def fill_default_attributes(self, template_dictionary):
"""
Overwrite base controller to add required parameters for adapter templates.
"""
context = base.get_from_session(KEY_REGION_CONTEXT)
template_dictionary["entitiySavedName"] = [{'name': DataTypeMetaData.KEY_TAG_1,
'label': 'Display name', 'type': 'str',
"disabled": "False",
"default": context.equation_kwargs.get(DataTypeMetaData.KEY_TAG_1, '')}]
template_dictionary['loadExistentEntityUrl'] = LOAD_EXISTING_URL
template_dictionary['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
template_dictionary['displayedMessage'] = base.get_from_session(base.KEY_MESSAGE)
template_dictionary['messageType'] = base.get_from_session(base.KEY_MESSAGE_TYPE)
return SpatioTemporalController.fill_default_attributes(self, template_dictionary, subsection='regionstim')
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:14,代码来源:region_stimulus_controller.py
示例5: fill_default_attributes
def fill_default_attributes(self, template_specification):
"""
Add some entries that are used in both steps then fill the default required attributes.
"""
context = base.get_from_session(KEY_SURFACE_CONTEXT)
template_specification["entitiySavedName"] = [
{'name': DataTypeMetaData.KEY_TAG_1, 'label': 'Display name', 'type': 'str',
"disabled": "False", "default": context.equation_kwargs.get(DataTypeMetaData.KEY_TAG_1, '')}]
template_specification['loadExistentEntityUrl'] = LOAD_EXISTING_URL
template_specification['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
template_specification['displayedMessage'] = base.get_from_session(base.KEY_MESSAGE)
template_specification['messageType'] = base.get_from_session(base.KEY_MESSAGE_TYPE)
return super(SurfaceStimulusController, self).fill_default_attributes(template_specification,
subsection='surfacestim')
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:14,代码来源:surface_stimulus_controller.py
示例6: submit_noise_configuration
def submit_noise_configuration(self):
"""
Collects the model parameters values from all the models used for the connectivity nodes.
"""
context_noise_config = base.get_from_session(KEY_CONTEXT_NC)
burst_configuration = base.get_from_session(base.KEY_BURST_CONFIG)
_, simulator_group = FlowService().get_algorithm_by_module_and_class(SIMULATOR_MODULE, SIMULATOR_CLASS)
simulator_adapter = ABCAdapter.build_adapter(simulator_group)
for param_name in simulator_adapter.noise_configurable_parameters():
burst_configuration.update_simulation_parameter(param_name, str(context_noise_config.noise_values))
### Clean from session drawing context
base.remove_from_session(KEY_CONTEXT_NC)
### Update in session BURST configuration for burst-page.
base.add2session(base.KEY_BURST_CONFIG, burst_configuration.clone())
raise cherrypy.HTTPRedirect("/burst/")
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:15,代码来源:noise_configuration_controller.py
示例7: submit_model_parameters
def submit_model_parameters(self):
"""
Collects the model parameters values from all the models used for the connectivity nodes.
"""
context_model_parameters = base.get_from_session(KEY_CONTEXT_MPR)
burst_configuration = base.get_from_session(base.KEY_BURST_CONFIG)
for param_name in context_model_parameters.model_parameter_names:
full_name = PARAMS_MODEL_PATTERN % (context_model_parameters.model_name, param_name)
full_values = context_model_parameters.get_values_for_parameter(param_name)
burst_configuration.update_simulation_parameter(full_name, full_values)
### Clean from session drawing context
base.remove_from_session(KEY_CONTEXT_MPR)
### Update in session BURST configuration for burst-page.
base.add2session(base.KEY_BURST_CONFIG, burst_configuration.clone())
raise cherrypy.HTTPRedirect("/burst/")
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:15,代码来源:region_model_parameters_controller.py
示例8: launch_full_visualizer
def launch_full_visualizer(self, index_in_tab):
"""
Launch the full scale visualizer from a small preview from the burst cockpit.
"""
burst = base.get_from_session(base.KEY_BURST_CONFIG)
selected_tab = burst.selected_tab
visualizer = burst.tabs[selected_tab].portlets[int(index_in_tab)].visualizer
result, input_data, operation_id = self.burst_service.launch_visualization(visualizer, is_preview=False)
algorithm = self.flow_service.get_algorithm_by_identifier(visualizer.fk_algorithm)
result[base.KEY_TITLE] = algorithm.name
result[base.KEY_ADAPTER] = algorithm.algo_group.id
result[base.KEY_OPERATION_ID] = operation_id
result[base.KEY_INCLUDE_RESOURCES] = 'flow/included_resources'
## Add required field to input dictionary and return it so that it can be used ##
## for top right control. ####
input_data[base.KEY_ADAPTER] = algorithm.algo_group.id
if base.KEY_PARENT_DIV not in result:
result[base.KEY_PARENT_DIV] = ''
self.context.add_adapter_to_session(algorithm.algo_group, None, copy.deepcopy(input_data))
self._populate_section(algorithm.algo_group, result)
result[base.KEY_DISPLAY_MENU] = True
result[base.KEY_BACK_PAGE] = "/burst"
result[base.KEY_SUBMIT_LINK] = self.get_url_adapter(algorithm.algo_group.group_category.id,
algorithm.algo_group.id, 'burst')
if KEY_CONTROLLS not in result:
result[KEY_CONTROLLS] = ''
return self.fill_default_attributes(result)
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:30,代码来源:burst_controller.py
示例9: save_simulator_configuration
def save_simulator_configuration(self, exclude_ranges, **data):
"""
:param exclude_ranges: should be a boolean value. If it is True than the
ranges will be excluded from the simulation parameters.
Data is a dictionary with pairs in one of the forms:
{ 'simulator_parameters' : { $name$ : { 'value' : $value$, 'is_disabled' : true/false } },
'burstName': $burst_name}
The names for the checkboxes next to the parameter with name $name$ is always $name$_checked
Save this dictionary in an easy to process form from which you could
rebuild either only the selected entries, or all of the simulator tree
with the given default values.
"""
#if the method is called from js then the parameter will be set as string
exclude_ranges = eval(str(exclude_ranges))
burst_config = base.get_from_session(base.KEY_BURST_CONFIG)
if BURST_NAME in data:
burst_config.name = data[BURST_NAME]
data = json.loads(data['simulator_parameters'])
for entry in data:
if exclude_ranges and (entry.endswith("_checked") or
entry == RANGE_PARAMETER_1 or entry == RANGE_PARAMETER_2):
continue
burst_config.update_simulation_parameter(entry, data[entry])
checkbox_for_entry = entry + "_checked"
if checkbox_for_entry in data:
burst_config.update_simulation_parameter(entry, data[checkbox_for_entry], KEY_PARAMETER_CHECKED)
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:28,代码来源:burst_controller.py
示例10: _add_extra_fields_to_interface
def _add_extra_fields_to_interface(input_list):
"""
The fields that have to be added to the existent
adapter interface should be added in this method.
"""
context = base.get_from_session(KEY_SURFACE_CONTEXT)
temporal_iface = []
min_tmp_x = {'name': 'min_tmp_x', 'label': 'Temporal Start Time(ms)', 'type': 'str', "disabled": "False",
"default": context.equation_kwargs.get('min_tmp_x', 0),
"description": "The minimum value of the x-axis for temporal equation plot."}
max_tmp_x = {'name': 'max_tmp_x', 'label': 'Temporal End Time(ms)', 'type': 'str', "disabled": "False",
"default": context.equation_kwargs.get('max_tmp_x', 100),
"description": "The maximum value of the x-axis for temporal equation plot."}
temporal_iface.append(min_tmp_x)
temporal_iface.append(max_tmp_x)
spatial_iface = []
min_space_x = {'name': 'min_space_x', 'label': 'Spatial Start Distance(mm)', 'type': 'str', "disabled": "False",
"default": context.equation_kwargs.get('min_space_x', 0),
"description": "The minimum value of the x-axis for spatial equation plot."}
max_space_x = {'name': 'max_space_x', 'label': 'Spatial End Distance(mm)', 'type': 'str', "disabled": "False",
"default": context.equation_kwargs.get('max_space_x', 100),
"description": "The maximum value of the x-axis for spatial equation plot."}
spatial_iface.append(min_space_x)
spatial_iface.append(max_space_x)
input_list['spatialPlotInputList'] = spatial_iface
input_list['temporalPlotInputList'] = temporal_iface
return input_list
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:30,代码来源:surface_stimulus_controller.py
示例11: save_parameters
def save_parameters(self, index_in_tab, **data):
"""
Save parameters
:param tab_nr: the index of the selected tab
:param index_in_tab: the index of the configured portlet in the selected tab
:param data: the {name:value} dictionary configuration of the current portlet
Having these inputs, update the configuration of the portletin the
corresponding tab position form the burst configuration .
"""
burst_config = base.get_from_session(base.KEY_BURST_CONFIG)
tab_nr = burst_config.selected_tab
old_portlet_config = burst_config.tabs[int(tab_nr)].portlets[int(index_in_tab)]
# Replace all void entries with 'None'
for entry in data:
if data[entry] == '':
data[entry] = None
need_relaunch = self.burst_service.update_portlet_configuration(old_portlet_config, data)
if need_relaunch:
#### Reset Burst Configuration into an entity not persisted (id = None for all)
base.add2session(base.KEY_BURST_CONFIG, burst_config.clone())
return "relaunchView"
else:
self.workflow_service.store_workflow_step(old_portlet_config.visualizer)
return "noRelaunch"
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:28,代码来源:burst_controller.py
示例12: load_region_stimulus
def load_region_stimulus(self, region_stimulus_gid, from_step=None):
"""
Loads the interface for the selected region stimulus.
"""
selected_region_stimulus = ABCAdapter.load_entity_by_gid(region_stimulus_gid)
temporal_eq = selected_region_stimulus.temporal
spatial_eq = selected_region_stimulus.spatial
connectivity = selected_region_stimulus.connectivity
weights = selected_region_stimulus.weight
temporal_eq_type = temporal_eq.__class__.__name__
spatial_eq_type = spatial_eq.__class__.__name__
default_dict = {'temporal': temporal_eq_type, 'spatial': spatial_eq_type,
'connectivity': connectivity.gid, 'weight': json.dumps(weights)}
for param in temporal_eq.parameters:
prepared_name = 'temporal_parameters_option_' + str(temporal_eq_type)
prepared_name = prepared_name + '_parameters_parameters_' + str(param)
default_dict[prepared_name] = str(temporal_eq.parameters[param])
for param in spatial_eq.parameters:
prepared_name = 'spatial_parameters_option_' + str(spatial_eq_type) + '_parameters_parameters_' + str(param)
default_dict[prepared_name] = str(spatial_eq.parameters[param])
input_list = self.get_creator_and_interface(REGION_STIMULUS_CREATOR_MODULE,
REGION_STIMULUS_CREATOR_CLASS, StimuliRegion())[1]
input_list = ABCAdapter.fill_defaults(input_list, default_dict)
context = base.get_from_session(KEY_REGION_CONTEXT)
context.reset()
context.update_from_interface(input_list)
context.equation_kwargs[DataTypeMetaData.KEY_TAG_1] = selected_region_stimulus.user_tag_1
context.set_active_stimulus(region_stimulus_gid)
return self.do_step(from_step)
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:32,代码来源:region_stimulus_controller.py
示例13: stop_burst_operation
def stop_burst_operation(self, operation_id, is_group, remove_after_stop=False):
"""
For a given operation id that is part of a burst just stop the given burst.
:returns True when stopped operation was successfully.
"""
operation_id = int(operation_id)
if int(is_group) == 0:
operation = self.flow_service.load_operation(operation_id)
else:
op_group = ProjectService.get_operation_group_by_id(operation_id)
first_op = ProjectService.get_operations_in_group(op_group)[0]
operation = self.flow_service.load_operation(int(first_op.id))
try:
burst_service = BurstService()
result = burst_service.stop_burst(operation.burst)
if remove_after_stop:
current_burst = base.get_from_session(base.KEY_BURST_CONFIG)
if current_burst and current_burst.id == operation.burst.id:
base.remove_from_session(base.KEY_BURST_CONFIG)
burst_service.cancel_or_remove_burst(operation.burst.id)
return result
except Exception, ex:
self.logger.exception(ex)
return False
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:26,代码来源:flow_controller.py
示例14: get_surface_model_parameters_data
def get_surface_model_parameters_data(self, default_selected_model_param=None):
"""
Returns a dictionary which contains all the data needed for drawing the
model parameters.
"""
context_model_parameters = base.get_from_session(KEY_CONTEXT_MPS)
if default_selected_model_param is None:
default_selected_model_param = context_model_parameters.prepared_model_parameter_names.values()[0]
equation_displayer = EquationDisplayer()
equation_displayer.trait.bound = interface.INTERFACE_ATTRIBUTES_ONLY
input_list = equation_displayer.interface[interface.INTERFACE_ATTRIBUTES]
input_list[0] = self._lock_midpoints(input_list[0])
options = []
for original_param, modified_param in context_model_parameters.prepared_model_parameter_names.items():
attributes = deepcopy(input_list)
self._fill_default_values(attributes, modified_param)
option = {'name': original_param, 'value': modified_param, 'attributes': attributes}
options.append(option)
input_list = [{'name': 'model_param', 'type': 'select', 'default': default_selected_model_param,
'label': 'Model param', 'required': True, 'options': options}]
input_list = ABCAdapter.prepare_param_names(input_list)
return {base.KEY_PARAMETERS_CONFIG: False, 'inputList': input_list,
'applied_equations': context_model_parameters.get_configure_info()}
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:26,代码来源:surface_model_parameters_controller.py
示例15: get_current_input_tree
def get_current_input_tree(self):
"""
Get from session previously selected InputTree.
"""
full_description = base.get_from_session(self.KEY_CURRENT_ADAPTER_INFO)
if full_description is not None and self._KEY_INPUT_TREE in full_description:
return full_description[self._KEY_INPUT_TREE]
return None
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:8,代码来源:context_selected_adapter.py
示例16: get_focal_points
def get_focal_points(self, model_param):
"""
Returns the html which displays the list of focal points selected for the
equation used for computing the values for the given model parameter.
"""
context_model_parameters = base.get_from_session(KEY_CONTEXT_MPS)
return {'focal_points': context_model_parameters.get_focal_points_for_parameter(model_param),
'focal_points_json': json.dumps(context_model_parameters.get_focal_points_for_parameter(model_param))}
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:8,代码来源:surface_model_parameters_controller.py
示例17: load_burst_history
def load_burst_history(self):
"""
Load the available burst that are stored in the database at this time.
This is one alternative to 'chrome-back problem'.
"""
session_burst = base.get_from_session(base.KEY_BURST_CONFIG)
return {'burst_list': self.burst_service.get_available_bursts(base.get_current_project().id),
'selectedBurst': session_burst.id}
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:8,代码来源:burst_controller.py
示例18: get_portlet_session_configuration
def get_portlet_session_configuration(self):
"""
Get the current configuration of portlets stored in session for this burst,
as a json.
"""
burst_entity = base.get_from_session(base.KEY_BURST_CONFIG)
returned_configuration = burst_entity.update_selected_portlets()
return returned_configuration
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:8,代码来源:burst_controller.py
示例19: get_current_step
def get_current_step(self):
"""
Get from session previously selected step (category ID).
"""
full_description = base.get_from_session(self.KEY_CURRENT_ADAPTER_INFO)
if full_description is not None and self._KEY_CURRENT_STEP in full_description:
return full_description[self._KEY_CURRENT_STEP]
return None
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:8,代码来源:context_selected_adapter.py
示例20: step_2_submit
def step_2_submit(self, next_step, **kwargs):
"""
Any submit from the second step should be handled here. Update the context and then do
the next step as required.
"""
context = base.get_from_session(KEY_REGION_CONTEXT)
context.equation_kwargs[DataTypeMetaData.KEY_TAG_1] = kwargs[DataTypeMetaData.KEY_TAG_1]
return self.do_step(next_step, 2)
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:8,代码来源:region_stimulus_controller.py
注:本文中的tvb.interfaces.web.controllers.base_controller.get_from_session函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论