当前位置: 首页>>代码示例>>Python>>正文


Python Artifact.jobs方法代码示例

本文整理汇总了Python中qiita_db.artifact.Artifact.jobs方法的典型用法代码示例。如果您正苦于以下问题:Python Artifact.jobs方法的具体用法?Python Artifact.jobs怎么用?Python Artifact.jobs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qiita_db.artifact.Artifact的用法示例。


在下文中一共展示了Artifact.jobs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from qiita_db.artifact import Artifact [as 别名]
# 或者: from qiita_db.artifact.Artifact import jobs [as 别名]
    def post(self, preprocessed_data_id):
        user = self.current_user
        # make sure user is admin and can therefore actually submit to VAMPS
        if user.level != 'admin':
            raise HTTPError(403, "User %s cannot submit to VAMPS!" %
                            user.id)
        msg = ''
        msg_level = 'success'

        plugin = Software.from_name_and_version('Qiita', 'alpha')
        cmd = plugin.get_command('submit_to_VAMPS')
        artifact = Artifact(preprocessed_data_id)

        # Check if the artifact is already being submitted to VAMPS
        is_being_submitted = any(
            [j.status in ('queued', 'running')
             for j in artifact.jobs(cmd=cmd)])

        if is_being_submitted == 'submitting':
            msg = "Cannot resubmit! Data is already being submitted"
            msg_level = 'danger'
            self.display_template(preprocessed_data_id, msg, msg_level)
        else:
            params = Parameters.load(
                cmd, values_dict={'artifact': preprocessed_data_id})
            job = ProcessingJob.create(user, params, True)
            job.submit()
            self.redirect('/study/description/%s' % artifact.study.study_id)
开发者ID:josenavas,项目名称:QiiTa,代码行数:30,代码来源:vamps_handlers.py

示例2: artifact_summary_post_request

# 需要导入模块: from qiita_db.artifact import Artifact [as 别名]
# 或者: from qiita_db.artifact.Artifact import jobs [as 别名]
def artifact_summary_post_request(user_id, artifact_id):
    """Launches the HTML summary generation and returns the job information

    Parameters
    ----------
    user_id : str
        The user making the request
    artifact_id : int or str
        The artifact id

    Returns
    -------
    dict of objects
        A dictionary containing the artifact summary information
        {'status': str,
         'message': str,
         'job': list of [str, str, str]}
    """
    artifact_id = int(artifact_id)
    artifact = Artifact(artifact_id)

    access_error = check_access(artifact.study.id, user_id)
    if access_error:
        return access_error

    # Check if the summary is being generated or has been already generated
    command = Command.get_html_generator(artifact.artifact_type)
    jobs = artifact.jobs(cmd=command)
    jobs = [j for j in jobs if j.status in ['queued', 'running', 'success']]
    if jobs:
        # The HTML summary is either being generated or already generated.
        # Return the information of that job so we only generate the HTML
        # once
        job = jobs[0]
    else:
        # Create a new job to generate the HTML summary and return the newly
        # created job information
        job = ProcessingJob.create(
            User(user_id),
            Parameters.load(command, values_dict={'input_data': artifact_id}))
        job.submit()

    return {'status': 'success',
            'message': '',
            'job': [job.id, job.status, job.step]}
开发者ID:yimsea,项目名称:qiita,代码行数:47,代码来源:artifact.py

示例3: artifact_summary_post_request

# 需要导入模块: from qiita_db.artifact import Artifact [as 别名]
# 或者: from qiita_db.artifact.Artifact import jobs [as 别名]
def artifact_summary_post_request(user, artifact_id):
    """Launches the HTML summary generation and returns the job information

    Parameters
    ----------
    user : qiita_db.user.User
        The user making the request
    artifact_id : int or str
        The artifact id

    Returns
    -------
    dict of objects
        A dictionary containing the job summary information
        {'job': [str, str, str]}
    """
    artifact_id = int(artifact_id)
    artifact = Artifact(artifact_id)

    check_artifact_access(user, artifact)

    # Check if the summary is being generated or has been already generated
    command = Command.get_html_generator(artifact.artifact_type)
    jobs = artifact.jobs(cmd=command)
    jobs = [j for j in jobs if j.status in ['queued', 'running', 'success']]
    if jobs:
        # The HTML summary is either being generated or already generated.
        # Return the information of that job so we only generate the HTML
        # once - Magic number 0 -> we are ensuring that there is only one
        # job generating the summary, so we can use the index 0 to access to
        # that job
        job = jobs[0]
    else:
        # Create a new job to generate the HTML summary and return the newly
        # created job information
        job = ProcessingJob.create(user, Parameters.load(
            command, values_dict={'input_data': artifact_id}), True)
        job.submit()

    return {'job': [job.id, job.status, job.step]}
开发者ID:antgonza,项目名称:qiita,代码行数:42,代码来源:base_handlers.py

示例4: artifact_summary_get_request

# 需要导入模块: from qiita_db.artifact import Artifact [as 别名]
# 或者: from qiita_db.artifact.Artifact import jobs [as 别名]
def artifact_summary_get_request(user_id, artifact_id):
    """Returns the information for the artifact summary page

    Parameters
    ----------
    user_id : str
        The user making the request
    artifact_id : int or str
        The artifact id

    Returns
    -------
    dict of objects
        A dictionary containing the artifact summary information
        {'status': str,
         'message': str,
         'name': str,
         'summary': str,
         'job': list of [str, str, str]}
    """
    artifact_id = int(artifact_id)
    artifact = Artifact(artifact_id)

    access_error = check_access(artifact.study.id, user_id)
    if access_error:
        return access_error

    user = User(user_id)
    visibility = artifact.visibility
    summary = artifact.html_summary_fp
    job_info = None
    errored_jobs = []
    processing_jobs = []
    for j in artifact.jobs():
        if j.command.software.type == "artifact transformation":
            status = j.status
            if status == 'success':
                continue
            j_msg = j.log.msg if status == 'error' else None
            processing_jobs.append(
                [j.id, j.command.name, j.status, j.step, j_msg])

    # Check if the HTML summary exists
    if summary:
        with open(summary[1]) as f:
            summary = f.read()
    else:
        # Check if the summary is being generated
        command = Command.get_html_generator(artifact.artifact_type)
        all_jobs = set(artifact.jobs(cmd=command))
        jobs = [j for j in all_jobs if j.status in ['queued', 'running']]
        errored_jobs = [(j.id, j.log.msg)
                        for j in all_jobs if j.status in ['error']]
        if jobs:
            # There is already a job generating the HTML. Also, there should be
            # at most one job, because we are not allowing here to start more
            # than one
            job = jobs[0]
            job_info = [job.id, job.status, job.step]

    buttons = []
    btn_base = (
        '<button onclick="if (confirm(\'Are you sure you want to %s '
        'artifact id: {0}?\')) {{ set_artifact_visibility(\'%s\', {0}) }}" '
        'class="btn btn-primary btn-sm">%s</button>').format(artifact_id)

    if qiita_config.require_approval:
        if visibility == 'sandbox':
            # The request approval button only appears if the artifact is
            # sandboxed and the qiita_config specifies that the approval should
            # be requested
            buttons.append(
                btn_base % ('request approval for', 'awaiting_approval',
                            'Request approval'))

        elif user.level == 'admin' and visibility == 'awaiting_approval':
            # The approve artifact button only appears if the user is an admin
            # the artifact is waiting to be approvaed and the qiita config
            # requires artifact approval
            buttons.append(btn_base % ('approve', 'private',
                                       'Approve artifact'))
    if visibility == 'private':
        # The make public button only appears if the artifact is private
        buttons.append(btn_base % ('make public', 'public', 'Make public'))

    # The revert to sandbox button only appears if the artifact is not
    # sandboxed nor public
    if visibility not in {'sandbox', 'public'}:
        buttons.append(btn_base % ('revert to sandbox', 'sandbox',
                                   'Revert to sandbox'))

    if artifact.can_be_submitted_to_ebi:
        if not artifact.is_submitted_to_ebi:
            buttons.append(
                '<a class="btn btn-primary btn-sm" '
                'href="/ebi_submission/%d">'
                '<span class="glyphicon glyphicon-export"></span>'
                ' Submit to EBI</a>' % artifact_id)
    if artifact.can_be_submitted_to_vamps:
        if not artifact.is_submitted_to_vamps:
#.........这里部分代码省略.........
开发者ID:yimsea,项目名称:qiita,代码行数:103,代码来源:artifact.py

示例5: artifact_summary_get_request

# 需要导入模块: from qiita_db.artifact import Artifact [as 别名]
# 或者: from qiita_db.artifact.Artifact import jobs [as 别名]
def artifact_summary_get_request(user, artifact_id):
    """Returns the information for the artifact summary page

    Parameters
    ----------
    user : qiita_db.user.User
        The user making the request
    artifact_id : int or str
        The artifact id

    Returns
    -------
    dict of objects
        A dictionary containing the artifact summary information
        {'name': str,
         'artifact_id': int,
         'visibility': str,
         'editable': bool,
         'buttons': str,
         'processing_parameters': dict of {str: object},
         'files': list of (int, str),
         'is_from_analysis': bool,
         'summary': str or None,
         'job': [str, str, str],
         'errored_jobs': list of [str, str]}
    """
    artifact_id = int(artifact_id)
    artifact = Artifact(artifact_id)
    artifact_type = artifact.artifact_type

    check_artifact_access(user, artifact)

    visibility = artifact.visibility
    summary = artifact.html_summary_fp
    job_info = None
    errored_summary_jobs = []

    # Check if the HTML summary exists
    if summary:
        # Magic number 1: If the artifact has a summary, the call
        # artifact.html_summary_fp returns a tuple with 2 elements. The first
        # element is the filepath id, while the second one is the actual
        # actual filepath. We are only interested on the actual filepath,
        # hence the 1 value.
        summary = relpath(summary[1], qiita_config.base_data_dir)
    else:
        # Check if the summary is being generated
        command = Command.get_html_generator(artifact_type)
        all_jobs = set(artifact.jobs(cmd=command))
        jobs = []
        errored_summary_jobs = []
        for j in all_jobs:
            if j.status in ['queued', 'running']:
                jobs.append(j)
            elif j.status in ['error']:
                errored_summary_jobs.append(j)
        if jobs:
            # There is already a job generating the HTML. Also, there should be
            # at most one job, because we are not allowing here to start more
            # than one
            job = jobs[0]
            job_info = [job.id, job.status, job.step]

    # Check if the artifact is editable by the given user
    study = artifact.study
    analysis = artifact.analysis
    editable = study.can_edit(user) if study else analysis.can_edit(user)

    buttons = []
    btn_base = (
        '<button onclick="if (confirm(\'Are you sure you want to %s '
        'artifact id: {0}?\')) {{ set_artifact_visibility(\'%s\', {0}) }}" '
        'class="btn btn-primary btn-sm">%s</button>').format(artifact_id)

    if not analysis:
        # If the artifact is part of a study, the buttons shown depend in
        # multiple factors (see each if statement for an explanation of those)
        if qiita_config.require_approval:
            if visibility == 'sandbox' and artifact.parents:
                # The request approval button only appears if the artifact is
                # sandboxed and the qiita_config specifies that the approval
                # should be requested
                buttons.append(
                    btn_base % ('request approval for', 'awaiting_approval',
                                'Request approval'))
            elif user.level == 'admin' and visibility == 'awaiting_approval':
                # The approve artifact button only appears if the user is an
                # admin the artifact is waiting to be approvaed and the qiita
                # config requires artifact approval
                buttons.append(btn_base % ('approve', 'private',
                                           'Approve artifact'))

        if visibility == 'private':
            # The make public button only appears if the artifact is private
            buttons.append(btn_base % ('make public', 'public', 'Make public'))

        # The revert to sandbox button only appears if the artifact is not
        # sandboxed nor public
        if visibility not in {'sandbox', 'public'}:
            buttons.append(btn_base % ('revert to sandbox', 'sandbox',
#.........这里部分代码省略.........
开发者ID:antgonza,项目名称:qiita,代码行数:103,代码来源:base_handlers.py


注:本文中的qiita_db.artifact.Artifact.jobs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。