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


Python TRN.exeucte方法代码示例

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


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

示例1: transfer_job

# 需要导入模块: from qiita_db.sql_connection import TRN [as 别名]
# 或者: from qiita_db.sql_connection.TRN import exeucte [as 别名]
def transfer_job(analysis, command_id, params, input_artifact_id, job_data,
                 cmd_out_id, biom_data, output_artifact_type_id):
    """Transfers the job from the old structure to the plugin structure

    Parameters
    ----------
    analysis : dict
        The analysis information
    command_id : int
        The id of the command executed
    params : str
        The parameters used in the job
    input_artifact_id : int
        The id of the input artifact
    job_data : dict
        The job information
    cmd_out_id : int
        The id of the command's output
    biom_data : dict
        The biom information
    output_artifact_type_id : int
        The type of the output artifact
    """
    with TRN:
        # Create the job
        # Add the row in the processing job table
        # Magic number 3: status -> success
        sql = """INSERT INTO qiita.processing_job
                    (email, command_id, command_parameters,
                     processing_job_status_id)
                 VALUES (%s, %s, %s, %s)
                 RETURNING processing_job_id"""
        TRN.add(sql, [analysis['email'], command_id, params, 3])
        job_id = TRN.execute_fetchlast()

        # Link the job with the input artifact
        sql = """INSERT INTO qiita.artifact_processing_job
                    (artifact_id, processing_job_id)
                 VALUES (rarefied_biom_id, proc_job_id)"""
        TRN.add(sql, [input_artifact_id, job_id])

        # Check if the executed job has results and add them
        sql = """SELECT EXISTS(SELECT *
                               FROM qiita.job_results_filepath
                               WHERE job_id = %s)"""
        TRN.add(sql, [job_data['job_id']])
        if TRN.execute_fetchlast():
            # There are results for the current job.
            # Transfer the job files to a new artifact
            sql = """SELECT filepath_id
                     FROM qiita.job_results_filepath
                     WHERE job_id = %s"""
            TRN.add(sql, job_data['job_id'])
            filepath_id = TRN.execute_fetchlast()
            artifact_id = transfer_file_to_artifact(
                analysis['analysis_id'], analysis['timestamp'], command_id,
                biom_data['data_type_id'], params, output_artifact_type_id,
                filepath_id)

            # Link the artifact with its parent
            sql = """INSERT INTO qiita.parent_artifact (artifact_id, parent_id)
                     VALUES (%s, %s)"""
            TRN.add(sql, [artifact_id, input_artifact_id])
            # Link the artifact as the job output
            sql = """INSERT INTO qiita.artifact_output_processing_job
                        (artifact_id, processing_job_id, command_output_id)
                     VALUES (%s, %s, %s)"""
            TRN.add(sql, [artifact_id, job_id, cmd_out_id])
            TRN.exeucte()
        else:
            # There are no results on the current job, so mark it as
            # error
            if job_data.log_id is None:
                # Magic number 2 - we are not using any other severity
                # level, so keep using number 2
                sql = """INSERT INTO qiita.logging (time, severity_id, msg)
                    VALUES (%s, %s, %s)
                    RETURNING logging_id"""
                TRN.add(sql, [analysis['timestamp'], 2,
                              "Unknown error - patch 47"])
            else:
                log_id = job_data['log_id']

            # Magic number 4 -> status -> error
            sql = """UPDATE qiita.processing_job
                SET processing_job_status_id = 4, logging_id = %s
                WHERE processing_job_id = %s"""
            TRN.add(sql, [log_id, job_id])
开发者ID:tkosciol,项目名称:qiita,代码行数:90,代码来源:54.py


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