Beispiel #1
0
def show_exp_cards(project: str = None, experiment: str = None):
    # TODO and FIXME: need a better way to set project and experiment
    # FIXME: only run with one project
    if project is None:
        all_projects = warehouse.get_name_projects()
        if not all_projects:
            return "Sorry. No projects found."
        else:
            prj = all_projects[0]

    if experiment is None:
        all_experiments = warehouse.get_name_experiments(prj)

    exp_run_list = []
    for exp in all_experiments:
        exp_dict = {
            'name': exp,
            'description': warehouse.get_parameter(prj, exp, 'description'),
        }
        setup_files = warehouse.get_all_setup(prj, exp)
        per_dict_list = [{
            'project': prj,
            'experiment': exp,
            'run': os.path.basename(os.path.dirname(filepath))
        } for filepath in setup_files]
        run_setup_list = [parse_yaml(filepath) for filepath in setup_files]
        run_table_list = enumerate(zip(per_dict_list, run_setup_list))
        exp_run_list.append((exp_dict, run_table_list))

    return render_template(
        'exp_cards.html',
        project=prj,
        exp_run_list=exp_run_list,
    )
Beispiel #2
0
 def append_experiment(self, config_file, name=None, typ='SSRF'):
     config = parse_yaml(config_file)
     if name is not None:
         pass
     elif 'name' in config:
         name = config['name']
     elif 'experiment_name' in config:
         name = config['experiment_name']
     else:
         name = os.path.basename(os.path.splitext(config_file)[0])
     self._exp_instance[name] = PrimusExperiment(config, name=name)
Beispiel #3
0
import sys
from sasdash import sasdash_app
from sasdash.datamodel import warehouse
from sasdash.utils import parse_yaml

if __name__ == '__main__':
    if len(sys.argv) > 1:
        for config_file in sys.argv[1:]:
            experiment_config = parse_yaml(config_file)
            project = experiment_config['project_name']
            experiment = experiment_config['experiment_name']

            warehouse.append_project(project)
            warehouse.append_experiment(project, config_file, name=experiment)

    sasdash_app.run(debug=True)
Beispiel #4
0
 def get_setup_parameter(self, run, key):
     setup = self.registered_setup[run]
     setup_dict = parse_yaml(setup)
     return setup_dict.get(key, None)
Beispiel #5
0
 def get_config_parameter(self, run, key):
     # FIXME: undefined method (if config.yml doesn't exist?)
     config_file = os.path.join(self._registered_dir[run], 'config.yml')
     config_dict = parse_yaml(config_file)
     return config_dict.get(key, None)
Beispiel #6
0
def individual_page(project: str, experiment: str, run: str):
    prj_exp_run = {'project': project, 'experiment': experiment, 'run': run}
    dir_path = warehouse.get_dir_path(**prj_exp_run)

    # find and load setup/config file
    setup_file = os.path.join(dir_path, 'setup.yml')
    if os.path.exists(setup_file):
        exp_setup = parse_yaml(setup_file)
    else:
        exp_setup = {}
    setup_prefix = 'setup'
    setup_form = ExperimentSetupForm(exp_setup, prefix=setup_prefix)

    config_file = os.path.join(dir_path, 'config.yml')
    if os.path.exists(config_file):
        run_config = parse_yaml(config_file)
        if 'layouts' not in run_config:
            run_config['layouts'] = ()
    else:
        run_config = {'layouts': ()}
    checkbox_prefix = 'checkbox'
    layouts_checkbox = LayoutConfigCheckbox(run_config['layouts'],
                                            prefix=checkbox_prefix)

    # process submit action
    if setup_form.validate_on_submit():
        for prefix_key, value in request.form.items():
            if setup_prefix:
                key = prefix_key.split('%s-' % setup_prefix)[1]
            if key not in ('csrf_token', 'submit', 'custom_params'):
                key = key.lower().replace(' ', '_')
                exp_setup[key] = to_basic_type(value)
        dump_yaml(exp_setup, setup_file)
        return redirect(url_for('.individual_page', **prj_exp_run))

    if (layouts_checkbox.generate.data
            and layouts_checkbox.validate_on_submit()):
        curr_layouts = []
        for prefix_key in request.form.keys():
            if checkbox_prefix:
                key = prefix_key.split('%s-' % checkbox_prefix)[1]
            if key not in ('csrf_token', 'generate'):
                curr_layouts.append(key)
        curr_layouts.sort(key=sort_seq)  # sort sequence of graphs
        run_config['layouts'] = curr_layouts
        dump_yaml(run_config, config_file)
        # TODO: reset_exp(run)
        return redirect(url_for('.individual_page', **prj_exp_run))

    # create info for rendering
    if run_config['layouts']:
        show_dashboard = True
        selected_graph = run_config['layouts']
    else:
        show_dashboard = False
        dashboard_params = ()
    if show_dashboard:
        dashboard_params = [{
            'graph_type': gtype,
            'graph_name': REGISTERED_LAYOUTS[gtype],
            'downloadable': DOWNLOADABLE.get(gtype, False),
        } for gtype in selected_graph if gtype != 'exp']

    # TODO: pagination
    prev_run, next_run = warehouse.get_prev_next(project, experiment, run)

    return render_template(
        'exp_base.html',
        project=project,
        experiment=experiment,
        run=run,
        setup_form=setup_form,
        layouts_checkbox=layouts_checkbox,
        show_dashboard=show_dashboard,
        dashboard_params=dashboard_params,
        next_run=next_run,
        prev_run=prev_run,
    )