src/dirbs/utils.py
def most_recently_run_condition_info(conn, cond_names, successful_only=False):
    """For a list of condition names, return a dict of cond_name -> (run_id, cond_config) for the most recent results.

    If a particular condition has never completed successfully, the value of the dict will be None, unless the
    successful_only parameter is set to True, in which case the key will not exist in the returned dict.

    Arguments:
        conn: dirbs db connection object
        cond_names: list of condition names
        successful_only: bool to return successful only
    Returns:
        dict of conditions config
    """
    conditions_to_find = copy.copy(cond_names)
    rv = {}
    # Get list of metadata for dirbs-classify, sorted in reverse order
    job_metadata_list = metadata.query_for_command_runs(conn, 'dirbs-classify')
    for job_metadata in job_metadata_list:
        # Loop back through recent dirbs-classify runs looking for the last time a classification
        # ran successfully. This is indicates in the metadata by the presence of an entry in the matched_imei_counts.
        # This can happen even though the overall dirbs-classify job failed
        extra_metadata = job_metadata.extra_metadata
        metadata_conditions = extra_metadata.get('conditions', {})
        matched_imei_counts = extra_metadata.get('matched_imei_counts', {})
        conditions_lookup = {c['label']: c for c in metadata_conditions}
        for req_cond_name in copy.copy(conditions_to_find):  # We modify the list in the loop, so take a copy
            if req_cond_name in matched_imei_counts:
                # If the name was in matched_imei_counts, it should always be in conditions as well
                rv[req_cond_name] = {
                    'run_id': job_metadata.run_id,
                    'config': conditions_lookup[req_cond_name],
                    'last_successful_run': job_metadata.start_time
                }
                # Remove this req_cond_name from conditions_to_find since we already found latest metadata
                conditions_to_find.remove(req_cond_name)

    # Any items in conditions_to_find at this point are conditions for which we never ran a successful condition
    # run
    if not successful_only:
        for missing_cond_name in conditions_to_find:
            rv[missing_cond_name] = None

    return rv
For a list of condition names, return a dict of cond_name -> (run_id, cond_config) for the most recent results.

    If a particular condition has never completed successfully, the value of the dict will be None, unless the
    successful_only parameter is set to True, in which case the key will not exist in the returned dict.

    Arguments:
        conn: dirbs db connection object
        cond_names: list of condition names
        successful_only: bool to return successful only
    Returns:
        dict of conditions config
    
For a list of condition names, return a dict of cond_name -> (run_id, cond_config) for the most recent results.
If a particular condition has never completed successfully, the value of the dict will be None, unless the
successful_only parameter is set to True, in which case the key will not exist in the returned dict.
For a list of condition names return a dict of cond_name - > ( run_id cond_config ) for the most recent results . If a particular condition has never completed successfully the value of the dict will be None unless the successful_only parameter is set to True in which case the key will not exist in the returned dict .
def most_recently_run_condition_info(conn, cond_names, successful_only=False):
    conditions_to_find = copy.copy(cond_names)
    rv = {}
    job_metadata_list = metadata.query_for_command_runs(conn, 'dirbs-classify')
    for job_metadata in job_metadata_list:
        extra_metadata = job_metadata.extra_metadata
        metadata_conditions = extra_metadata.get('conditions', {})
        matched_imei_counts = extra_metadata.get('matched_imei_counts', {})
        conditions_lookup = {c['label']: c for c in metadata_conditions}
        for req_cond_name in copy.copy(conditions_to_find):  
            if req_cond_name in matched_imei_counts:
                rv[req_cond_name] = {
                    'run_id': job_metadata.run_id,
                    'config': conditions_lookup[req_cond_name],
                    'last_successful_run': job_metadata.start_time
                }
                conditions_to_find.remove(req_cond_name)
    if not successful_only:
        for missing_cond_name in conditions_to_find:
            rv[missing_cond_name] = None
    return rv
def most_recently_run_condition_info ( conn , cond_names , successful_only = False ) : conditions_to_find = copy . copy ( cond_names ) rv = { } job_metadata_list = metadata . query_for_command_runs ( conn , 'dirbs-classify' ) for job_metadata in job_metadata_list : extra_metadata = job_metadata . extra_metadata metadata_conditions = extra_metadata . get ( 'conditions' , { } ) matched_imei_counts = extra_metadata . get ( 'matched_imei_counts' , { } ) conditions_lookup = { c [ 'label' ] : c for c in metadata_conditions } for req_cond_name in copy . copy ( conditions_to_find ) : if req_cond_name in matched_imei_counts : rv [ req_cond_name ] = { 'run_id' : job_metadata . run_id , 'config' : conditions_lookup [ req_cond_name ] , 'last_successful_run' : job_metadata . start_time } conditions_to_find . remove ( req_cond_name ) if not successful_only : for missing_cond_name in conditions_to_find : rv [ missing_cond_name ] = None return rv
For a list of condition names, return a dict of cond_name -> (run_id, cond_config) for the most recent results.
For a list of condition names return a dict of cond_name - > ( run_id cond_config ) for the most recent results .
"""For a list of condition names, return a dict of cond_name -> (run_id, cond_config) for the most recent results.

    If a particular condition has never completed successfully, the value of the dict will be None, unless the
    successful_only parameter is set to True, in which case the key will not exist in the returned dict.

    Arguments:
        conn: dirbs db connection object
        cond_names: list of condition names
        successful_only: bool to return successful only
    Returns:
        dict of conditions config
    """ # Get list of metadata for dirbs-classify, sorted in reverse order # Loop back through recent dirbs-classify runs looking for the last time a classification # ran successfully. This is indicates in the metadata by the presence of an entry in the matched_imei_counts. # This can happen even though the overall dirbs-classify job failed # We modify the list in the loop, so take a copy # If the name was in matched_imei_counts, it should always be in conditions as well # Remove this req_cond_name from conditions_to_find since we already found latest metadata # Any items in conditions_to_find at this point are conditions for which we never ran a successful condition # run
dict of conditions config
dict of conditions config
conn
dirbs db connection object
dirbs db connection object
cond_names
list of condition names
list of condition names
successful_only
bool to return successful only
bool to return successful only