def _fill_param_from_post(all_range_parameters, param_key, **data): # type: (dict, str, dict) -> RangeParameter param_name = data.get( SimulatorPSERangeFragment.NAME_FIELD.format(param_key)) param = all_range_parameters.get(param_name) if param.type is float: param_lo = data.get( SimulatorPSERangeFragment.LO_FIELD.format(param_key)) param_hi = data.get( SimulatorPSERangeFragment.HI_FIELD.format(param_key)) param_step = data.get( SimulatorPSERangeFragment.STEP_FIELD.format(param_key)) param_range = RangeParameter(param_name, param.type, Range(float(param_lo), float(param_hi), float(param_step)), is_array=param.is_array) else: param_range_str = data.get( SimulatorPSERangeFragment.GID_FIELD.format(param_key)) param_range = RangeParameter( param_name, param.type, param.range_definition, False, SimulatorPSERangeFragment._prepare_pse_uuid_list( param_range_str)) return param_range
def handle_range_params_at_loading(burst_config, all_range_parameters): param1, param2 = None, None if burst_config.range1: param1 = RangeParameter.from_json(burst_config.range1) param1.fill_from_default(all_range_parameters[param1.name]) if burst_config.range2 is not None: param2 = RangeParameter.from_json(burst_config.range2) param2.fill_from_default(all_range_parameters[param2.name]) return param1, param2
def _default_range_parameters(self): conduction_speed = RangeParameter(Simulator.conduction_speed.field_name, float, # TODO: Float should support ranges Range(lo=0.01, hi=100.0, step=1.0), isinstance(Simulator.conduction_speed, NArray)) connectivity = RangeParameter(Simulator.connectivity.field_name, Connectivity, self.connectivity_filters) surface = RangeParameter(Simulator.surface.field_name, Surface, self.connectivity_filters) return OrderedDict({Simulator.conduction_speed.field_name: conduction_speed, Simulator.connectivity.field_name: connectivity, Simulator.surface.field_name: surface})
def handle_range_params_at_loading(burst_config, all_range_parameters): param1, param2 = None, None if burst_config.range1: param1 = RangeParameter.from_json(burst_config.range1) param1.fill_from_default( BurstService.get_range_param_by_name(param1.name, all_range_parameters)) if burst_config.range2 is not None: param2 = RangeParameter.from_json(burst_config.range2) param2.fill_from_default( BurstService.get_range_param_by_name( param2.name, all_range_parameters)) return param1, param2
def build(test_user, test_project, simulation_length=10, is_group=False): model = SimulatorAdapterModel() model.connectivity = connectivity_index_factory().gid model.simulation_length = simulation_length burst = BurstConfiguration(test_project.id, name="Sim " + str(datetime.now())) burst.start_time = datetime.now() algorithm = dao.get_algorithm_by_module(SIMULATOR_MODULE, SIMULATOR_CLASS) service = SimulatorService() if is_group: range_param = RangeParameter("conduction_speed", float, Range(lo=50.0, hi=100.0, step=20.0)) burst.range1 = range_param.to_json() burst = BurstService().prepare_burst_for_pse(burst) op = service.async_launch_and_prepare_pse(burst, test_user, test_project, algorithm, range_param, None, model) else: dao.store_entity(burst) op = service.async_launch_and_prepare_simulation(burst, test_user, test_project, algorithm, model) return op
def get_range_parameters(self): ntau_range_param = RangeParameter(NoiseViewModel.ntau.field_name, float, Range(lo=0.0, hi=20.0, step=1.0)) params_with_range_defined = super(NoiseForm, self).get_range_parameters() params_with_range_defined.append(ntau_range_param) return params_with_range_defined
def fill_operationgroup_name(self, entities_in_group): """ Display name for UI. """ new_name = "of " + entities_in_group + " varying " if self.range1 is not None: range_param1 = RangeParameter.from_json(self.range1) new_name += range_param1.name if self.range2 is not None: range_param2 = RangeParameter.from_json(self.range2) new_name += " x " + range_param2.name if self.range3 is not None: range_param3 = RangeParameter.from_json(self.range3) new_name += " x " + range_param3.name new_name += " - " + date2string(datetime.datetime.now(), date_format=LESS_COMPLEX_TIME_FORMAT) self.name = new_name
def get_range_parameters(self): parameters_for_pse = self._gather_parameters_with_range_defined() result = [] for range_param in parameters_for_pse: range_obj = RangeParameter(range_param.field_name, float, range_param.domain, isinstance(range_param, NArray)) result.append(range_obj) return result