Exemplo n.º 1
0
def process():
    from looper import build_parser as blp
    actions = get_positional_args(blp(), sort=True)
    try:
        globs.selected_project, globs.selected_project_id, globs.current_subproj = \
            select_project(request.form.get('select_project'))
    except TypeError:
        app.logger.info("No project selected, redirecting to the index page.")
        flash("No project was selected, choose one from the list below.")
        return redirect(url_for('index'))
    config_file = str(os.path.expandvars(os.path.expanduser(globs.selected_project)))
    if globs.p is None:
        globs.p = Project(config_file, subproject=globs.current_subproj)
    try:
        # subproject related logic can be removed with the introduction of direct subproject selection in the index
        subprojects = globs.p.subprojects.keys()
    except AttributeError:
        subprojects = None
    # populating project/subproject metadata and date are treated individually since when the project is activated
    # we want its subprojects data to be populated but not the dates
    with globs.cc as x:
        x.populate_project_metadata(paths=globs.selected_project,
                                           sp=globs.current_subproj if globs.current_subproj else None)
        x.project_date(globs.selected_project, globs.current_subproj)
    get_navbar_summary_links()
    return render_template('process.html', p_info=project_info_dict(globs.p), change=None,
                           selected_subproject=globs.p.subproject, actions=actions, subprojects=subprojects,
                           interval=globs.status_check_interval)
Exemplo n.º 2
0
 def prj(self, tmpdir, prj_data, anns_file, iface_paths):
     """ Provide basic Project. """
     prj_data["pipeline_interfaces"] = iface_paths
     prj_data["metadata"][SAMPLE_ANNOTATIONS_KEY] = anns_file
     prj_file = tmpdir.join("pconf.yaml").strpath
     with open(prj_file, 'w') as f:
         yaml.dump(prj_data, f)
     return Project(prj_file)
Exemplo n.º 3
0
 def prj(self, tmpdir, prj_data, anns_file, iface_paths):
     """ Provide basic Project. """
     prj_data[PIPELINE_INTERFACES_KEY] = iface_paths
     prj_data[METADATA_KEY][SAMPLE_ANNOTATIONS_KEY] = anns_file
     prj_file = tmpdir.join("pconf.yaml").strpath
     with open(prj_file, 'w') as f:
         yaml.dump(prj_data, f)
     return Project(prj_file)
Exemplo n.º 4
0
def interactive(prj_lines=PROJECT_CONFIG_LINES,
                iface_lines=PIPELINE_INTERFACE_CONFIG_LINES,
                merge_table_lines=MERGE_TABLE_LINES,
                annotation_lines=SAMPLE_ANNOTATION_LINES,
                project_kwargs=None,
                logger_kwargs=None):
    """
    Create Project and PipelineInterface instances from default or given data.

    This is intended to provide easy access to instances of fundamental looper
    object for interactive test-authorship-motivated work in an iPython
    interpreter or Notebook. Test authorship is simplified if we provide
    easy access to viable instances of these objects.

    :param Iterable[str] prj_lines: project config lines
    :param Iterable[str] iface_lines: pipeline interface config lines
    :param Iterable[str] merge_table_lines: lines for a merge table file
    :param Iterable[str] annotation_lines: lines for a sample annotations file
    :param str | int loglevel: level at which to attend to log messages
    :param dict project_kwargs: keyword arguments for Project constructor
    :param dict logger_kwargs: keyword arguments for logging configuration
    :param bool devmode: whether logging should be done in development mode;
        this implies a more verbose level setting and a more information-rich
        template for logging message formatting
    :param str logfile: path to file to which to write logging messages
    :return Project, PipelineInterface: one Project and one PipelineInterface,
    """

    # Establish logging for interactive session.
    looper_logger_kwargs = {"level": "DEBUG"}
    looper_logger_kwargs.update(logger_kwargs or {})
    setup_looper_logger(**looper_logger_kwargs)

    # TODO: don't work with tempfiles once ctors tolerate Iterable.
    dirpath = tempfile.mkdtemp()
    path_conf_file = _write_temp(prj_lines,
                                 dirpath=dirpath,
                                 fname=P_CONFIG_FILENAME)
    path_iface_file = _write_temp(iface_lines,
                                  dirpath=dirpath,
                                  fname="pipeline_interface.yaml")
    path_merge_table_file = _write_temp(merge_table_lines,
                                        dirpath=dirpath,
                                        fname=MERGE_TABLE_FILENAME)
    path_sample_annotation_file = _write_temp(annotation_lines,
                                              dirpath=dirpath,
                                              fname=ANNOTATIONS_FILENAME)

    prj = Project(path_conf_file, **(project_kwargs or {}))
    iface = PipelineInterface(path_iface_file)
    for path in [
            path_conf_file, path_iface_file, path_merge_table_file,
            path_sample_annotation_file
    ]:
        os.unlink(path)
    return prj, iface
Exemplo n.º 5
0
 def test_looper_command_templates_hooks(self, prep_temp_pep, cmd):
     tp = prep_temp_pep
     for path in {
             piface["pipe_iface_file"]
             for piface in Project(tp).pipeline_interfaces
     }:
         with mod_yaml_data(path) as piface_data:
             piface_data[PRE_SUBMIT_HOOK_KEY][PRE_SUBMIT_CMD_KEY] = [cmd]
     stdout, stderr, rc = subp_exec(tp, "run")
     sd = os.path.join(get_outdir(tp), "submission")
     print(stderr)
     assert rc == 0
     verify_filecount_in_dir(sd, "test.txt", 3)
Exemplo n.º 6
0
 def test_looper_other_plugins(self, prep_temp_pep, plugin, appendix):
     tp = prep_temp_pep
     for path in {
             piface["pipe_iface_file"]
             for piface in Project(tp).pipeline_interfaces
     }:
         with mod_yaml_data(path) as piface_data:
             piface_data[PRE_SUBMIT_HOOK_KEY][PRE_SUBMIT_PY_FUN_KEY] = [
                 plugin
             ]
     stdout, stderr, rc = subp_exec(tp, "run")
     sd = os.path.join(get_outdir(tp), "submission")
     print(stderr)
     assert rc == 0
     verify_filecount_in_dir(sd, appendix, 3)
Exemplo n.º 7
0
def process():
    from looper import build_parser as blp
    actions = get_positional_args(blp(), sort=True)
    # this try-except block is used to determine whether the user should be redirected to the index page
    # to select the project when they land on the process subpage from the set_comp_env subpage
    if globs.selected_project is None and request.form.get(
            'select_project') is None:
        app.logger.info(
            "The project is not selected, redirecting to the index page.")
        flash("No project was selected, choose one from the list below.")
        return redirect(url_for('index'))
    else:
        new_selected_project = request.form.get('select_project')
        if new_selected_project is not None and globs.selected_project != new_selected_project:
            globs.selected_project = new_selected_project
    config_file = str(
        os.path.expandvars(os.path.expanduser(globs.selected_project)))
    if globs.p is None:
        globs.p = Project(config_file)
    try:
        subprojects = list(globs.p.subprojects.keys())
    except AttributeError:
        subprojects = None
        # TODO: p_info will be removed altogether in the future version
    get_navbar_summary_links()
    p_info = {
        "name": globs.p.name,
        "config_file": globs.p.config_file,
        "sample_count": globs.p.num_samples,
        "output_dir": globs.p.metadata.output_dir,
        "subprojects": ",".join(subprojects)
    }
    globs.reset_btn = True
    return render_template('process.html',
                           p_info=p_info,
                           change=None,
                           selected_subproject=globs.p.subproject,
                           actions=actions,
                           subprojects=subprojects)