src/dirbs/metadata.py
def query_for_command_runs(conn, job_command, subcommand=None, successful_only=False, run_id=None):
    """
    Get all the metadata for all the invocations of a job commands, sorted most recent runs first.

    Arguments:
        conn: dirbs db connection object
        job_command: name of the command for the job
        subcommand: name of the sub-command used, default is None
        successful_only: bool to filter only successful jobs, default is False means it will fetch all of them
        run_id: id of the currently running job
    Returns:
        psycopg2 results object containing all the results based on the argument given
    """
    with conn.cursor() as cursor:
        if successful_only:
            status_filter_sql = sql.SQL("status = \'success\'")
        else:
            status_filter_sql = sql.SQL('TRUE')

        query_params = [job_command]
        if subcommand:
            subcommand_filter_sql = sql.SQL('AND subcommand = %s')
            query_params.append(subcommand)
        else:
            subcommand_filter_sql = sql.SQL('')

        if run_id:
            run_id_filter_sql = sql.SQL('AND run_id = %s')
            query_params.append(run_id)
        else:
            run_id_filter_sql = sql.SQL('')

        cursor.execute(sql.SQL("""SELECT *
                                    FROM job_metadata
                                   WHERE command = %s
                                     AND {status_filter_sql}
                                         {subcommand_filter_sql}
                                         {run_id_filter_sql}
                                ORDER BY start_time DESC""").format(status_filter_sql=status_filter_sql,
                                                                    subcommand_filter_sql=subcommand_filter_sql,
                                                                    run_id_filter_sql=run_id_filter_sql),
                       query_params)
        return cursor.fetchall()

    Get all the metadata for all the invocations of a job commands, sorted most recent runs first.

    Arguments:
        conn: dirbs db connection object
        job_command: name of the command for the job
        subcommand: name of the sub-command used, default is None
        successful_only: bool to filter only successful jobs, default is False means it will fetch all of them
        run_id: id of the currently running job
    Returns:
        psycopg2 results object containing all the results based on the argument given
    
Get all the metadata for all the invocations of a job commands, sorted most recent runs first.
Get all the metadata for all the invocations of a job commands sorted most recent runs first .
def query_for_command_runs(conn, job_command, subcommand=None, successful_only=False, run_id=None):
    with conn.cursor() as cursor:
        if successful_only:
            status_filter_sql = sql.SQL("status = \'success\'")
        else:
            status_filter_sql = sql.SQL('TRUE')
        query_params = [job_command]
        if subcommand:
            subcommand_filter_sql = sql.SQL('AND subcommand = %s')
            query_params.append(subcommand)
        else:
            subcommand_filter_sql = sql.SQL('')
        if run_id:
            run_id_filter_sql = sql.SQL('AND run_id = %s')
            query_params.append(run_id)
        else:
            run_id_filter_sql = sql.SQL('')
        cursor.execute(sql.SQL("""SELECT *
                                    FROM job_metadata
                                   WHERE command = %s
                                     AND {status_filter_sql}
                                         {subcommand_filter_sql}
                                         {run_id_filter_sql}
                                ORDER BY start_time DESC""").format(status_filter_sql=status_filter_sql,
                                                                    subcommand_filter_sql=subcommand_filter_sql,
                                                                    run_id_filter_sql=run_id_filter_sql),
                       query_params)
        return cursor.fetchall()
def query_for_command_runs ( conn , job_command , subcommand = None , successful_only = False , run_id = None ) : with conn . cursor ( ) as cursor : if successful_only : status_filter_sql = sql . SQL ( "status = \'success\'" ) else : status_filter_sql = sql . SQL ( 'TRUE' ) query_params = [ job_command ] if subcommand : subcommand_filter_sql = sql . SQL ( 'AND subcommand = %s' ) query_params . append ( subcommand ) else : subcommand_filter_sql = sql . SQL ( '' ) if run_id : run_id_filter_sql = sql . SQL ( 'AND run_id = %s' ) query_params . append ( run_id ) else : run_id_filter_sql = sql . SQL ( '' ) cursor . execute ( sql . SQL ( """SELECT *
                                    FROM job_metadata
                                   WHERE command = %s
                                     AND {status_filter_sql}
                                         {subcommand_filter_sql}
                                         {run_id_filter_sql}
                                ORDER BY start_time DESC""" ) . format ( status_filter_sql = status_filter_sql , subcommand_filter_sql = subcommand_filter_sql , run_id_filter_sql = run_id_filter_sql ) , query_params ) return cursor . fetchall ( )
Get all the metadata for all the invocations of a job commands, sorted most recent runs first.
Get all the metadata for all the invocations of a job commands sorted most recent runs first .
"""
    Get all the metadata for all the invocations of a job commands, sorted most recent runs first.

    Arguments:
        conn: dirbs db connection object
        job_command: name of the command for the job
        subcommand: name of the sub-command used, default is None
        successful_only: bool to filter only successful jobs, default is False means it will fetch all of them
        run_id: id of the currently running job
    Returns:
        psycopg2 results object containing all the results based on the argument given
    """
psycopg2 results object containing all the results based on the argument given
psycopg2 results object containing all the results based on the argument given
conn
dirbs db connection object
dirbs db connection object
job_command
name of the command for the job
name of the command for the job
subcommand
name of the sub-command used, default is None
name of the sub - command used default is None
successful_only
bool to filter only successful jobs, default is False means it will fetch all of them
bool to filter only successful jobs default is False means it will fetch all of them
run_id
id of the currently running job
id of the currently running job