src/dirbs/metadata.py
def store_job_metadata(conn, job_command, logger, job_subcommand=None):
    """
    Generic method for storing metadata about a job. Returns a run_id.

    Arguments:
        conn: dirbs db connection object
        job_command: job command name currently running
        logger: dirbs logger instance
        job_subcommand: name of the sub command, default is None
    Returns:
        run_id of the job
    """
    # We must be using an autocommit connection. We do not want any job metadata to be rolled back.
    # In general, you want to use a different DB connection for metadata that you use for the rest
    # of your application
    assert conn.autocommit
    with conn.cursor() as cursor:
        cursor.execute("""INSERT INTO job_metadata(command, subcommand, db_user, command_line,
                                                   start_time, status)
                              VALUES(%s, %s, current_user, %s, now(), 'running')
                           RETURNING run_id""",
                       [job_command, job_subcommand, ' '.join(sys.argv)])
        run_id = cursor.fetchone()[0]
        logger.info('Stored metadata about this {0} job with run_id {1:d}'.format(job_command, run_id))
        return run_id

    Generic method for storing metadata about a job. Returns a run_id.

    Arguments:
        conn: dirbs db connection object
        job_command: job command name currently running
        logger: dirbs logger instance
        job_subcommand: name of the sub command, default is None
    Returns:
        run_id of the job
    
Generic method for storing metadata about a job.
Generic method for storing metadata about a job .
def store_job_metadata(conn, job_command, logger, job_subcommand=None):
    assert conn.autocommit
    with conn.cursor() as cursor:
        cursor.execute("""INSERT INTO job_metadata(command, subcommand, db_user, command_line,
                                                   start_time, status)
                              VALUES(%s, %s, current_user, %s, now(), 'running')
                           RETURNING run_id""",
                       [job_command, job_subcommand, ' '.join(sys.argv)])
        run_id = cursor.fetchone()[0]
        logger.info('Stored metadata about this {0} job with run_id {1:d}'.format(job_command, run_id))
        return run_id
def store_job_metadata ( conn , job_command , logger , job_subcommand = None ) : assert conn . autocommit with conn . cursor ( ) as cursor : cursor . execute ( """INSERT INTO job_metadata(command, subcommand, db_user, command_line,
                                                   start_time, status)
                              VALUES(%s, %s, current_user, %s, now(), 'running')
                           RETURNING run_id""" , [ job_command , job_subcommand , ' ' . join ( sys . argv ) ] ) run_id = cursor . fetchone ( ) [ 0 ] logger . info ( 'Stored metadata about this {0} job with run_id {1:d}' . format ( job_command , run_id ) ) return run_id
Generic method for storing metadata about a job.
Generic method for storing metadata about a job .
"""
    Generic method for storing metadata about a job. Returns a run_id.

    Arguments:
        conn: dirbs db connection object
        job_command: job command name currently running
        logger: dirbs logger instance
        job_subcommand: name of the sub command, default is None
    Returns:
        run_id of the job
    """ # We must be using an autocommit connection. We do not want any job metadata to be rolled back. # In general, you want to use a different DB connection for metadata that you use for the rest # of your application
run_id of the job
run_id of the job
conn
dirbs db connection object
dirbs db connection object
job_command
job command name currently running
job command name currently running
logger
dirbs logger instance
dirbs logger instance
job_subcommand
name of the sub command, default is None
name of the sub command default is None