def format_process(process, workflow, report_dir): duration = "" start = "" end = "" if process.start: start = strftime("%a, %d %b %Y %H:%M:%S", localtime(process.start)) if process.end: end = strftime("%a, %d %b %Y %H:%M:%S", localtime(process.end)) duration = nice_duration(process.end - process.start) running = start and not end return { 'id': process.id, 'processor': process.processor.name, 'start': start, 'end': end, 'duration': duration, 'log_stdout': path2url(process.log_stdout, report_dir), 'log_stdout_size': nice_file_size(process.log_stdout, running), 'log_stderr': path2url(process.log_stderr, report_dir), 'log_stderr_size': nice_file_size(process.log_stderr, running), 'outputs': (format_resource(resource, workflow) for resource in process.iter_outputs()), 'inputs': (format_resource(resource, workflow) for resource in process.iter_inputs()), 'code': process.code, 'success': process.success, 'error_message': process.error_message, }
def print_lost_sec(inv_duration): print("{} of processing will be lost".format(nice_duration(inv_duration)))
def test_nice_duration_ms(self): """ A duration must be rounded to seconds""" nice = nice_duration(73.3) assert nice == "1min 13s", nice
def print_abort_on_threshold(inv_duration, threshold): msg = "You were about to loose {} seconds of processing time (which exceeds the {} " \ "threshold). \nAborting... ".format(nice_duration(inv_duration), nice_duration(threshold)) print(msg)
def test_nice_size_hour(self): """ A duration below the day should be expressed in hours and minutes""" nice = nice_duration(10000) assert nice == "2h 46min", nice
def test_nice_size_day(self): """ A duration above the day should be expressed in days and hours""" nice = nice_duration(1000000) assert nice == "11d 13h", nice
def test_nice_duration_s(self): """ A duration below the minute should be expressed in seconds""" nice = nice_duration(12) assert nice == "12s", nice
def test_nice_duration_min(self): """ A duration below the hour should be expressed in minutes and seconds""" nice = nice_duration(64) assert nice == "1min 4s", nice