data: a dict received from nni_manager, which contains:
              - 'parameter_id': id of the trial
              - 'value': metric value reported by nni.report_final_result()
              - 'type': report type, support {'FINAL', 'PERIODICAL'}
512206
def handle_report_metric_data(self, data):
        
        if data['type'] == 'FINAL':
            self._handle_final_metric_data(data)
        elif data['type'] == 'PERIODICAL':
            if self.assessor is not None:
                self._handle_intermediate_metric_data(data)
            else:
                pass
        else:
            raise ValueError('Data type not supported: {}'.format(data['type']))
427681
def data_from_dict(self, data):
        

        nvars = []
        for key, val in data.items():
            self.__dict__[key].extend(val)

            # assure the same parameter matrix size
            if len(nvars) > 1 and len(val) != nvars[-1]:
                raise IndexError(
                    'Model <{}> parameter <{}> must have the same length'.
                    format(self._name, key))
            nvars.append(len(val))

        # assign idx-uid mapping
        for i, idx in zip(range(self.n), self.idx):
            self.uid[idx] = i
1124232
def __get_data_en_intervalo(self, d0=None, df=None):
        

        params = {'date_fmt': self.DATE_FMT,
                  'usar_multithread': self.USAR_MULTITHREAD, 'max_threads_requests': self.MAX_THREADS_REQUESTS,
                  'timeout': self.TIMEOUT, 'num_retries': self.NUM_RETRIES,
                  'func_procesa_data_dia': self.procesa_data_dia, 'func_url_data_dia': self.url_data_dia,
                  'max_act_exec': self.MAX_ACT_EXEC,
                  'data_extra_request': {'headers': self.HEADERS,
                                         'json_req': self.JSON_REQUESTS,
                                         'params_request': self.PARAMS_REQUESTS},
                  'verbose': self.verbose}
        data_get, hay_errores, str_import = get_data_en_intervalo(d0, df, **params)
        if not hay_errores:
            self.integridad_data(data_get)
            self.printif(str_import, 'ok')
            if type(data_get) is pd.DataFrame:
                data_get = {self.masterkey: data_get}
            return data_get
        else:
            return None
671856
def _post_run_hook(self, runtime):
        '''  '''
        outputs = self.aggregate_outputs(runtime=runtime)
        self._anat_file = os.path.join(outputs.subjects_dir,
                                       outputs.subject_id,
                                       'mri', 'brain.mgz')
        self._contour = os.path.join(outputs.subjects_dir,
                                     outputs.subject_id,
                                     'mri', 'ribbon.mgz')
        self._masked = False

        NIWORKFLOWS_LOG.info('Generating report for ReconAll (subject %s)',
                             outputs.subject_id)

        return super(ReconAllRPT, self)._post_run_hook(runtime)
1180784
def get_param_text(self, nid):
        
        r = []
        params = self.parameters.xpath('.//param[@ref-id="{}"]'.format(nid))
        if not params:
            return r
        for param in params:
            vnode = param.find('value')
            s = 'Parameter: {}, type:{}, value: {}'.format(param.attrib.get('name'),
                                                           vnode.attrib.get('type'),
                                                           param.findtext('value', default='No Value'))
            r.append(s)
        return r
551550
def get_data(self):
        ""
        alarm_oids = [netsnmp.Varbind(status_mib[alarm_id]['oid']) for alarm_id in self.models[self.modem_type]['alarms']]
        metric_oids = [netsnmp.Varbind(metric_mib[metric_id]['oid']) for metric_id in self.models[self.modem_type]['metrics']]
        response = self.snmp_session.get(netsnmp.VarList(*alarm_oids + metric_oids))
        return (
            response[0:len(alarm_oids)],
            response[len(alarm_oids):]
        )
1167863
def export_trials_data(args):
    
    nni_config = Config(get_config_filename(args))
    rest_port = nni_config.get_config('restServerPort')
    rest_pid = nni_config.get_config('restServerPid')
    if not detect_process(rest_pid):
        print_error('Experiment is not running...')
        return
    running, response = check_rest_server_quick(rest_port)
    if running:
        response = rest_get(trial_jobs_url(rest_port), 20)
        if response is not None and check_response(response):
            content = json.loads(response.text)
            # dframe = pd.DataFrame.from_records([parse_trial_data(t_data) for t_data in content])
            # dframe.to_csv(args.csv_path, sep='\t')
            records = parse_trial_data(content)
            if args.type == 'json':
                json_records = []
                for trial in records:
                    value = trial.pop('reward', None)
                    trial_id =  trial.pop('id', None)
                    json_records.append({'parameter': trial, 'value': value, 'id': trial_id})
            with open(args.path, 'w') as file:
                if args.type == 'csv':
                    writer = csv.DictWriter(file, set.union(*[set(r.keys()) for r in records]))
                    writer.writeheader()
                    writer.writerows(records)
                else:
                    json.dump(json_records, file)
        else:
            print_error('Export failed...')
    else:
        print_error('Restful server is not Running')
349169
def get_param(self):
        
        cycle_progress = self.event_index / self.cycle_size
        return self.start_value + ((self.end_value - self.start_value) / 2) * (1 - math.cos(math.pi * cycle_progress))
404168
def receive_trial_result(self, parameter_id, parameters, value):
        
        reward = extract_scalar_reward(value)

        if parameter_id not in self.total_data:
            raise RuntimeError("Received parameter_id not in total_data.")

        (_, father_id, model_id) = self.total_data[parameter_id]

        graph = self.bo.searcher.load_model_by_id(model_id)

        # to use the value and graph
        self.add_model(reward, model_id)
        self.update(father_id, graph, reward, model_id)
686787
def receive_trial_result(self, parameter_id, parameters, value):
        
        value = extract_scalar_reward(value)
        if self.optimize_mode == OptimizeMode.Maximize:
            value = -value

        logger.info("Received trial result.")
        logger.info("value is :" + str(value))
        logger.info("parameter is : " + str(parameters))

        # parse parameter to sample_x
        sample_x = [0 for i in range(len(self.key_order))]
        for key in parameters:
            idx = self.key_order.index(key)
            sample_x[idx] = parameters[key]

        # parse value to sample_y
        temp_y = []
        if sample_x in self.samples_x:
            idx = self.samples_x.index(sample_x)
            temp_y = self.samples_y[idx]
            temp_y.append(value)
            self.samples_y[idx] = temp_y

            # calculate y aggregation
            median = get_median(temp_y)
            self.samples_y_aggregation[idx] = [median]
        else:
            self.samples_x.append(sample_x)
            self.samples_y.append([value])

            # calculate y aggregation
            self.samples_y_aggregation.append([value])
308001
def import_data(self, data):
        
        _completed_num = 0
        for trial_info in data:
            logger.info("Importing data, current processing progress %s / %s" %(_completed_num, len(data)))
            _completed_num += 1
            assert "parameter" in trial_info
            _params = trial_info["parameter"]
            assert "value" in trial_info
            _value = trial_info['value']
            if not _value:
                logger.info("Useless trial data, value is %s, skip this trial data." %_value)
                continue
            self.supplement_data_num += 1
            _parameter_id = '_'.join(["ImportData", str(self.supplement_data_num)])
            self.total_data.append(_params)
            self.receive_trial_result(parameter_id=_parameter_id, parameters=_params, value=_value)
        logger.info("Successfully import data to metis tuner.")
900069
def paramsReport(self):
        """"""
        report = {}
        for param in self._REPORTPARAMS:
            pvalue = getattr(self, param)
            if isinstance(pvalue, float):
                report[param] = pvalue
            elif isinstance(pvalue, scipy.ndarray) and pvalue.shape == (3, N_NT):
                for p in range(3):
                    for w in range(N_NT - 1):
                        report['{0}{1}{2}'.format(param, p, INDEX_TO_NT[w])] =\
                                pvalue[p][w]
            else:
                raise ValueError("Unexpected param: {0}".format(param))
        return report
1287792
def get_report(self):
        

        lines = [
            self.name,
            '=' * len(self.name)
        ]

        if self.info is not None:
            lines.append('')
            sorted_info = sorted(self.info.items(), key=lambda x: x[0])
            lines.extend(['--> {}: {}'.format(k, v) for k, v in sorted_info])

        lines.append('')
        lines.append('Result: {}'.format('Passed' if self.passed else 'Failed'))

        return '\n'.join(lines)
311932
def data(self):
        
        data = {}
        data["name"] = self.name
        data["query"] = self.queryd
        data["languages"] = self.languages
        data["countries"] = self.countries if self.countries else ""
        data["sources"] = self.sources if self.sources else ""
        data["blocked_sites"] = self.blocked_sites if self.blocked_sites else ""
        data["noise_detection"] = self.noise_detection if self.noise_detection else ""
        data["reviews_pages"] = self.reviews_pages if self.reviews_pages else ""

        # Deletes parameter if it does not have a value
        for key, value in list(data.items()):
            if value == '':
                del data[key]

        data = json.dumps(data)
        return data
823291
def get_paginated_response(self, data):
        
        metadata = {
            'next': self.get_next_link(),
            'previous': self.get_previous_link(),
            'count': self.get_result_count(),
            'num_pages': self.get_num_pages(),
        }
        if isinstance(data, dict):
            if 'results' not in data:
                raise TypeError(u'Malformed result dict')
            data['pagination'] = metadata
        else:
            data = {
                'results': data,
                'pagination': metadata,
            }
        return Response(data)
1310526
def (self):
        """"""

        status = FAILED
        msg = "not started"

        try:

            msg = "generating request"
            log.info(msg)

            # noqa https://stackoverflow.com/questions/29815129/pandas-dataframe-to-list-of-dictionaries
            publish_req = generate_ai_request(
                predict_rows=self.df.fillna(
                    ANTINEX_MISSING_VALUE).to_dict("records"),
                req_dict=self.request_dict)

            if publish_req["status"] != SUCCESS:
                log.error(("failed generate_ai_request with err={}")
                          .format(
                            publish_req["error"]))
                status = ERROR

            else:

                msg = "publishing as user={} url={} model={}".format(
                    ANTINEX_USER,
                    ANTINEX_URL,
                    ANTINEX_USE_MODEL_NAME)

                log.info(msg)

                response = self.client.run_job(
                    body=publish_req["data"])

                if response["status"] == SUCCESS:
                    log.info("predictions sent")
                    status = SUCCESS
                elif response["status"] == FAILED:
                    log.error(("job failed with error='{}' with response={}")
                              .format(
                                response["error"],
                                response["data"]))
                    status = ERROR
                elif response["status"] == ERROR:
                    log.error(("job had an error='{}' with response={}")
                              .format(
                                response["error"],
                                response["data"]))
                    status = ERROR
                elif response["status"] == LOGIN_FAILED:
                    log.error(("job reported user was not able to log in "
                               "with an error='{}' with response={}")
                              .format(
                                response["error"],
                                response["data"]))
                    status = ERROR
                # logging for good/bad cases during publish
            # if generated a good request
        except Exception as e:
            log.error(("failed generating request last_step='{}' ex={}")
                      .format(
                        msg,
                        e))
        # end of try/ex

        return status
954150
def _sample_type(self, sample=None):
        
        data = {}
        sampletype = sample.getSampleType() if sample else None
        if sampletype:
            data = {'obj': sampletype,
                    'id': sampletype.id,
                    'title': sampletype.Title(),
                    'url': sampletype.absolute_url()}
        return data