Parse experiment parameters from the data directory name

    Args
    ----
    name_exp: str
        Name of data directory with experiment parameters

    Returns
    -------
    tag_params: dict of str
        Dictionary of parsed experiment parameters
6094
def parse_experiment_params(name_exp):
    '''
    '''
    if ('/' in name_exp) or ('\\' in name_exp):
        raise ValueError("The path {} appears to be a path. Please pass "
                         "only the data directory's name (i.e. the "
                         "experiment name)".format(name_exp))

    tag_params = dict()
    tag_params['experiment'] = name_exp
    tag_params['tag_model'] = (name_exp.split('_')[1]).replace('-','')
    tag_params['tag_id'] = name_exp.split('_')[2]
    tag_params['animal'] = name_exp.split('_')[3]
    tag_params['notes'] = name_exp.split('_')[4]

    return tag_params
1343578
def _label_to_tag(self, name, labels, scraper_config, tag_name=None):
        
        value = labels.get(name)
        if value:
            return self._format_tag(tag_name or name, value, scraper_config)
        else:
            return None
1161734
def persist_experiment(experiment):
    
    from benchbuild.utils.schema import Experiment, Session

    session = Session()

    cfg_exp = experiment.id
    LOG.debug("Using experiment ID stored in config: %s", cfg_exp)
    exps = session.query(Experiment).filter(Experiment.id == cfg_exp)
    desc = str(CFG["experiment_description"])
    name = experiment.name

    if exps.count() == 0:
        newe = Experiment()
        newe.id = cfg_exp
        newe.name = name
        newe.description = desc
        session.add(newe)
        ret = newe
    else:
        exps.update({'name': name, 'description': desc})
        ret = exps.first()

    try:
        session.commit()
    except IntegrityError:
        session.rollback()
        persist_experiment(experiment)

    return (ret, session)
1062884
def getExperiments(uuid: str):
    
    return jsonify([x.deserialize() for x in Experiment.query.all()])
113643
def get_sample_value(self, name, labels=None):
        
        if labels is None:
            labels = {}
        for metric in self.collect():
            for s in metric.samples:
                if s.name == name and s.labels == labels:
                    return s.value
        return None
25307
def _generate_trials(self, experiment_spec, output_path=""):
        
        if "run" not in experiment_spec:
            raise TuneError("Must specify `run` in {}".format(experiment_spec))
        for _ in range(experiment_spec.get("num_samples", 1)):
            trial_id = Trial.generate_id()
            while True:
                suggested_config = self._suggest(trial_id)
                if suggested_config is None:
                    yield None
                else:
                    break
            spec = copy.deepcopy(experiment_spec)
            spec["config"] = merge_dicts(spec["config"], suggested_config)
            flattened_config = resolve_nested_dict(spec["config"])
            self._counter += 1
            tag = "{0}_{1}".format(
                str(self._counter), format_vars(flattened_config))
            yield create_trial_from_spec(
                spec,
                output_path,
                self._parser,
                experiment_tag=tag,
                trial_id=trial_id)
211627
def p_param_arg_exp(self, p):
        ''
        p[0] = ParamArg(p[2], p[4], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
336248
def parse_expmethodcall(self, tup_tree):
        

        self.check_node(tup_tree, 'EXPMETHODCALL', ('NAME',), (),
                        ('EXPPARAMVALUE',))

        params = self.list_of_matching(tup_tree, ('EXPPARAMVALUE',))

        return (name(tup_tree), attrs(tup_tree), params)
618668
def show_experiment_info():
    ''''''
    experiment_config = Experiments()
    experiment_dict = experiment_config.get_all_experiments()
    if not experiment_dict:
        print('There is no experiment running...')
        exit(1)
    update_experiment()
    experiment_id_list = []
    for key in experiment_dict.keys():
        if experiment_dict[key]['status'] != 'STOPPED':
            experiment_id_list.append(key)
    if not experiment_id_list:
        print_warning('There is no experiment running...')
        return
    for key in experiment_id_list:
        print(EXPERIMENT_MONITOR_INFO % (key, experiment_dict[key]['status'], experiment_dict[key]['port'], \
             experiment_dict[key].get('platform'), experiment_dict[key]['startTime'], get_time_interval(experiment_dict[key]['startTime'], experiment_dict[key]['endTime'])))
        print(TRIAL_MONITOR_HEAD)
        running, response = check_rest_server_quick(experiment_dict[key]['port'])
        if running:
            response = rest_get(trial_jobs_url(experiment_dict[key]['port']), REST_TIME_OUT)
            if response and check_response(response):
                content = json.loads(response.text)
                for index, value in enumerate(content):
                    content[index] = convert_time_stamp_to_date(value)
                    print(TRIAL_MONITOR_CONTENT % (content[index].get('id'), content[index].get('startTime'), content[index].get('endTime'), content[index].get('status')))
        print(TRIAL_MONITOR_TAIL)
47479
def parse_sample_data(sample_data, module_name):
    
    samples = {}
    for index, chunk in enumerate(sample_data.split("\n\n")):
        chunk = "{}-{}-{}".format(module_name, index, chunk)
        name, sample = re.split("-?\n", chunk, 1)
        try:
            samples[name] = ast.literal_eval(sample)
        except SyntaxError:
            samples[name] = SAMPLE_DATA_ERROR
    return samples
1144854
def get_parameters(parser, token):
    
    args = token.split_contents()
    if len(args) < 2:
        raise template.TemplateSyntaxError(
            "get_parameters tag takes at least 1 argument"
        )
    return GetParametersNode(args[1].strip())
846684
def exp_files(self):
        
        ret = OrderedDict()
        # restore the order of the experiments
        exp_file = self.exp_file
        if osp.exists(exp_file):
            for key, val in safe_load(exp_file).items():
                ret[key] = val
        for project, d in self.projects.items():
            project_path = d['root']
            config_path = osp.join(project_path, '.project')
            if not osp.exists(config_path):
                continue
            for fname in glob.glob(osp.join(config_path, '*.yml')):
                if fname == '.project.yml':
                    continue
                exp = osp.splitext(osp.basename(fname))[0]
                if not isinstance(ret.get(exp), Archive):
                    ret[exp] = osp.join(config_path, exp + '.yml')
                if exp not in self._project_map[project]:
                    self._project_map[project].append(exp)
        return ret
1016130
def get_params_from_page(path, file_name, method_count):
    
    # open the rendered file.
    file_name = file_name.replace(".rst", "")
    file_path = "{0}/../_build/html/endpoints/{1}/index.html".format(
        path, file_name)
    soup = bs4.BeautifulSoup(open(file_path))

    # Pull out the relevant section
    section = soup.find_all('div', class_='section')[method_count]

    # get the tbody of the params table
    tbody = section.find('tbody')
    params = []
    if tbody is not None:
        for row in tbody.find_all('tr'):
            name, param_type, required, description = row.find_all('td')
            required = required.text == 'Yes'
            param = dict(
                name=name.text,
                type=param_type.text,
                required=required,
                description=description.text
            )
            params.append(param)
    params = sorted(params, key=lambda k: not k['required'])
    return params
1188144
def get_tag(self, name, params=None):
        
        return self.tag(name, action='GET', params=params)
850072
def get_experiment_image_info(experiment: 'Experiment') -> Tuple[str, str]:
    """"""
    project_name = experiment.project.name
    repo_name = project_name

    image_name = '{}/{}'.format(conf.get('REGISTRY_URI'), repo_name)
    image_tag = experiment.code_reference.commit
    return image_name, image_tag
1142558
def getParam(self, name=None):
        
        if 'parameters' in self.keys():
            l = {x['name']: x['value'] for x in self['parameters'].values()}
            if name:
                if name in l.keys():
                    return l[name]
                else:
                    return False
            else:
                return l
381853
def print_experiments(experiments):
    
    headers = ["JOB NAME", "CREATED", "STATUS", "DURATION(s)", "INSTANCE", "DESCRIPTION", "METRICS"]
    expt_list = []
    for experiment in experiments:
        expt_list.append([normalize_job_name(experiment.name),
                          experiment.created_pretty, experiment.state,
                          experiment.duration_rounded, experiment.instance_type_trimmed,
                          experiment.description, format_metrics(experiment.latest_metrics)])
    floyd_logger.info(tabulate(expt_list, headers=headers))