本文整理汇总了Python中tvb.interfaces.web.controllers.common.get_from_session函数的典型用法代码示例。如果您正苦于以下问题:Python get_from_session函数的具体用法?Python get_from_session怎么用?Python get_from_session使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_from_session函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: submit_model_parameters
def submit_model_parameters(self, submit_action="cancel_action"):
"""
Collects the model parameters values from all the models used for the surface vertices.
@:param submit_action: a post parameter. It distinguishes if this request is a cancel or a submit
"""
if submit_action == "submit_action":
context_model_parameters = common.get_from_session(KEY_CONTEXT_MPS)
burst_configuration = common.get_from_session(common.KEY_BURST_CONFIG)
for original_param, modified_param in context_model_parameters.prepared_model_parameter_names.items():
full_name = PARAMS_MODEL_PATTERN % (context_model_parameters.model_name, original_param)
param_data = context_model_parameters.get_data_for_model_param(original_param, modified_param)
if isinstance(param_data, dict):
equation = param_data[KEY_EQUATION]
focal_points = param_data[KEY_FOCAL_POINTS]
# if focal points or the equation are missing do not update this model parameter
if not focal_points or not equation:
continue
param_data[KEY_EQUATION] = equation.to_json(equation)
param_data[KEY_FOCAL_POINTS] = json.dumps(focal_points)
param_data = json.dumps(param_data)
burst_configuration.update_simulation_parameter(full_name, param_data)
### Update in session BURST configuration for burst-page.
common.add2session(common.KEY_BURST_CONFIG, burst_configuration.clone())
### Clean from session drawing context
common.remove_from_session(KEY_CONTEXT_MPS)
raise cherrypy.HTTPRedirect("/burst/")
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:27,代码来源:surface_model_parameters_controller.py
示例2: 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 = common.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'
msg, _ = common.get_message_from_session()
template_specification['displayedMessage'] = msg
context = common.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
min_value, max_value = selected_local_conn.get_min_max_values()
template_specification['minValue'] = min_value
template_specification['maxValue'] = max_value
else:
template_specification['no_local_connectivity'] = True
template_specification[common.KEY_PARAMETERS_CONFIG] = False
return self.fill_default_attributes(template_specification)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:29,代码来源:local_connectivity_controller.py
示例3: get_stimulus_chunk
def get_stimulus_chunk(self, chunk_idx):
"""
Get the next chunk of the stimulus data.
"""
stimulus = common.get_from_session(KEY_STIMULUS)
surface_gid = common.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:amitsaroj001,项目名称:tvb-framework,代码行数:14,代码来源:surface_stimulus_controller.py
示例4: launch_burst
def launch_burst(self, launch_mode, burst_name, **data):
"""
Do the actual burst launch, using the configuration saved in current session.
:param launch_mode: new/branch/continue
:param burst_name: user-given burst name. It can be empty (case in which we will fill with simulation_x)
:param data: kwargs for simulation input parameters.
"""
data = json.loads(data['simulator_parameters'])
burst_config = common.get_from_session(common.KEY_BURST_CONFIG)
## Validate new burst-name
if launch_mode == LAUNCH_NEW and burst_name != 'none_undefined':
validation_result = self._is_burst_name_ok(burst_name)
if validation_result is True:
burst_config.name = burst_name
else:
return {'error': validation_result}
## Fill all parameters
user_id = common.get_logged_user().id
data[common.KEY_ADAPTER] = self.cached_simulator_algorithm_id
burst_config.update_simulator_configuration(data)
burst_config.fk_project = common.get_current_project().id
## Do the asynchronous launch
try:
burst_id, burst_name = self.burst_service.launch_burst(burst_config, 0, self.cached_simulator_algorithm_id,
user_id, launch_mode)
return {'id': burst_id, 'name': burst_name}
except BurstServiceException, e:
self.logger.exception("Could not launch burst!")
return {'error': e.message}
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:32,代码来源:burst_controller.py
示例5: submit_model_parameters
def submit_model_parameters(self, node_values):
"""
Collects the model parameters values from all the models used for the connectivity nodes.
Assumes that the array indices are consistent with the node order.
"""
dynamic_ids = json.loads(node_values)
dynamics = [dao.get_dynamic(did) for did in dynamic_ids]
for dynamic in dynamics[1:]:
if dynamic.model_class != dynamics[0].model_class:
raise Exception("All dynamics must have the same model type")
model_name = dynamics[0].model_class
burst_config = common.get_from_session(common.KEY_BURST_CONFIG)
# update model parameters in burst config
des = SerializationManager(burst_config)
model_parameters = [dict(json.loads(d.model_parameters)) for d in dynamics]
des.write_model_parameters(model_name, model_parameters)
# update dynamic ids in burst config
burst_config.dynamic_ids = dynamic_ids
# Update in session BURST configuration for burst-page.
# todo was this needed? as the burst config in session has already been changed
# common.add2session(common.KEY_BURST_CONFIG, burst_config.clone())
raise cherrypy.HTTPRedirect("/burst/")
开发者ID:sdiazpier,项目名称:tvb-framework,代码行数:27,代码来源:region_model_parameters_controller.py
示例6: index
def index(self):
current_user_id = common.get_logged_user().id
# In case the number of dynamics gets big we should add a filter in the ui.
dynamics = dao.get_dynamics_for_user(current_user_id)
if not dynamics:
return self.no_dynamics_page()
burst_config = common.get_from_session(common.KEY_BURST_CONFIG)
des = SerializationManager(burst_config)
connectivity = des.get_connectivity()
params = ConnectivityViewer.get_connectivity_parameters(connectivity)
params.update(
{
"title": "Model parameters",
"mainContent": "burst/model_param_region",
"isSingleMode": True,
"submit_parameters_url": "/burst/modelparameters/regions/submit_model_parameters",
"dynamics": dynamics,
"dynamics_json": self._dynamics_json(dynamics),
"initial_dynamic_ids": json.dumps(burst_config.dynamic_ids),
}
)
return self.fill_default_attributes(params, "regionmodel")
开发者ID:sdiazpier,项目名称:tvb-framework,代码行数:27,代码来源:region_model_parameters_controller.py
示例7: _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 = common.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. "
"Not persisted, used only for visualization."}
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. "
"Not persisted, used only for visualization."}
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:amitsaroj001,项目名称:tvb-framework,代码行数:32,代码来源:surface_stimulus_controller.py
示例8: step_1
def step_1(self, do_reset=0, **kwargs):
"""
Generate the html for the first step of the local connectivity page.
:param do_reset: Boolean telling to start from empty page or not
: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()
common.add2session(KEY_LCONN_CONTEXT, new_context)
context = common.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'
msg, msg_type = common.get_message_from_session()
template_specification['displayedMessage'] = msg
return self.fill_default_attributes(template_specification)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:30,代码来源:local_connectivity_controller.py
示例9: 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 = InputTreeManager.fill_defaults(input_list, default_dict)
context = common.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:LauHoiYanGladys,项目名称:tvb-framework,代码行数:32,代码来源:region_stimulus_controller.py
示例10: 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 = common.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 = InputTreeManager.prepare_param_names(input_list)
return {common.KEY_PARAMETERS_CONFIG: False, 'inputList': input_list,
'applied_equations': context_model_parameters.get_configure_info()}
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:26,代码来源:surface_model_parameters_controller.py
示例11: index
def index(self):
current_user_id = common.get_logged_user().id
# In case the number of dynamics gets big we should add a filter in the ui.
dynamics = dao.get_dynamics_for_user(current_user_id)
if not dynamics:
return self.no_dynamics_page()
burst_config = common.get_from_session(common.KEY_BURST_CONFIG)
des = SerializationManager(burst_config)
connectivity = des.get_connectivity()
if connectivity is None:
msg = 'You have to select a connectivity before setting up the region Model. '
common.set_error_message(msg)
raise ValueError(msg)
params = ConnectivityViewer.get_connectivity_parameters(connectivity)
params.update({
'title': 'Model parameters',
'mainContent': 'burst/model_param_region',
'isSingleMode': True,
'submit_parameters_url': '/burst/modelparameters/regions/submit_model_parameters',
'dynamics': dynamics,
'dynamics_json': self._dynamics_json(dynamics),
'initial_dynamic_ids': json.dumps(burst_config.dynamic_ids)
})
return self.fill_default_attributes(params, 'regionmodel')
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:31,代码来源:region_model_parameters_controller.py
示例12: 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 {"portlet_parameters": json_string} Where json_string is a Jsonified dictionary
{"name": value}, representing the configuration of the current portlet
Having these inputs, current method updated the configuration of the portlet in the
corresponding tab position form the burst configuration in session.
"""
burst_config = common.get_from_session(common.KEY_BURST_CONFIG)
tab_nr = burst_config.selected_tab
old_portlet_config = burst_config.tabs[int(tab_nr)].portlets[int(index_in_tab)]
data = json.loads(data['portlet_parameters'])
# 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)
common.add2session(common.KEY_BURST_CONFIG, burst_config.clone())
return "relaunchView"
else:
self.workflow_service.store_workflow_step(old_portlet_config.visualizer)
return "noRelaunch"
开发者ID:maedoc,项目名称:tvb-framework,代码行数:30,代码来源:burst_controller.py
示例13: 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.
"""
exclude_ranges = string2bool(str(exclude_ranges))
burst_config = common.get_from_session(common.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:maedoc,项目名称:tvb-framework,代码行数:27,代码来源:burst_controller.py
示例14: 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 = common.get_from_session(common.KEY_BURST_CONFIG)
if current_burst and current_burst.id == operation.burst.id:
common.remove_from_session(common.KEY_BURST_CONFIG)
result = burst_service.cancel_or_remove_burst(operation.burst.id) or result
return result
except Exception, ex:
self.logger.exception(ex)
return False
开发者ID:transpersonify,项目名称:tvb-framework,代码行数:26,代码来源:flow_controller.py
示例15: 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 = common.get_from_session(common.KEY_BURST_CONFIG)
selected_tab = burst.selected_tab
visualizer = burst.tabs[selected_tab].portlets[int(index_in_tab)].visualizer
result, input_data = self.burst_service.launch_visualization(visualizer, is_preview=False)
algorithm = self.flow_service.get_algorithm_by_identifier(visualizer.fk_algorithm)
if common.KEY_TITLE not in result:
result[common.KEY_TITLE] = algorithm.displayname
result[common.KEY_ADAPTER] = algorithm.id
result[common.KEY_OPERATION_ID] = None
result[common.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[common.KEY_ADAPTER] = algorithm.id
if common.KEY_PARENT_DIV not in result:
result[common.KEY_PARENT_DIV] = ''
self.context.add_adapter_to_session(algorithm, None, copy.deepcopy(input_data))
self._populate_section(algorithm, result, True)
result[common.KEY_DISPLAY_MENU] = True
result[common.KEY_BACK_PAGE] = "/burst"
result[common.KEY_SUBMIT_LINK] = self.get_url_adapter(algorithm.fk_category,
algorithm.id, 'burst')
if KEY_CONTROLLS not in result:
result[KEY_CONTROLLS] = ''
return self.fill_default_attributes(result)
开发者ID:maedoc,项目名称:tvb-framework,代码行数:32,代码来源:burst_controller.py
示例16: 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 = common.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:LauHoiYanGladys,项目名称:tvb-framework,代码行数:8,代码来源:region_stimulus_controller.py
示例17: 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 = common.get_from_session(common.KEY_BURST_CONFIG)
returned_configuration = burst_entity.update_selected_portlets()
return returned_configuration
开发者ID:maedoc,项目名称:tvb-framework,代码行数:8,代码来源:burst_controller.py
示例18: get_current_input_tree
def get_current_input_tree(self):
"""
Get from session previously selected InputTree.
"""
full_description = common.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:amitsaroj001,项目名称:tvb-framework,代码行数:8,代码来源:context_selected_adapter.py
示例19: 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 = common.get_from_session(common.KEY_BURST_CONFIG)
return {'burst_list': self.burst_service.get_available_bursts(common.get_current_project().id),
'selectedBurst': session_burst.id}
开发者ID:unimauro,项目名称:tvb-framework,代码行数:8,代码来源:burst_controller.py
示例20: 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 = common.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:LauHoiYanGladys,项目名称:tvb-framework,代码行数:8,代码来源:surface_model_parameters_controller.py
注:本文中的tvb.interfaces.web.controllers.common.get_from_session函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论