def get_file_accesses(tid): file_accesses = persistence.load('file_access', trial_id = tid) result = [] for file_access in file_accesses: stack = [] function_activation = persistence.load('function_activation', id = file_access['function_activation_id']).fetchone() while function_activation: function_name = function_activation['name'] function_activation = persistence.load('function_activation', id = function_activation['caller_id']).fetchone() if function_activation: stack.insert(0, function_name) if not stack or stack[-1] != 'open': stack.append(' ... -> open') result.append({ 'name': file_access['name'], 'mode': file_access['mode'], 'buffering': file_access['buffering'], 'content_hash_before': file_access['content_hash_before'], 'content_hash_after': file_access['content_hash_after'], 'timestamp': file_access['timestamp'], 'stack': ' -> '.join(stack), }) return result
def load_trial_activation_tree(tid): stack2 = [] stack = [] min_duration = 1000^10 max_duration = 0 raw_activations = persistence.load('function_activation', trial_id=tid, order='start') for raw_activation in raw_activations: #activation = row_to_dict(raw_activation) single = Single(raw_activation) stack.append(single) if not stack: return TreeElement() stack2.append(stack.pop()) while stack: next = stack2.pop() previous = stack.pop() add_flow(stack, stack2, previous, next) return stack2.pop()
def activation_text(self, activation): values = persistence.load('object_value', function_activation_id=activation['id'], order='id') values = [value for value in values if value['type'] == 'ARGUMENT'] result = [ "", "Activation #{id} from {start} to {finish} ({dur} microseconds)" .format(dur=calculate_duration(activation), **activation), ] if values: result.append("Arguments: {}".format( ", ".join("{}={}".format(value["name"], value["value"]) for value in values))) return result + [ "Returned {}".format(activation['return']) ]
def load_trials(script, execution): result = {'nodes': [], 'edges': []} tid = 0 for trial in persistence.load('trial'): if script != '*' and trial['script'] != script: continue if execution == 'finished' and not trial['finish']: continue if execution == 'unfinished' and trial['finish']: continue result['nodes'].append(row_to_dict(trial)) if tid: result['edges'].append({ 'source': tid, 'target': tid - 1, 'level': 0 }) tid += 1 return result
def get_environment(tid): return { attr['name']: attr['value'] for attr in persistence.load( 'environment_attr', trial_id = tid) }
def load_function_defs(tid): return { function['name']: row_to_dict(function) for function in persistence.load('function_def', trial_id=tid) }