Exemple #1
0
def main():
    activate_logging()
    parser = arg_parser()
    add_arguments(parser)
    parsed_args = parse_arguments(parser)
    install_tees(parsed_args.stdout, parsed_args.stderr)
    max_ram_megabytes = MemoryParser.parse_to_megabytes(parsed_args.max_ram)
    max_cores = CPUParser.parse(parsed_args.max_cores)
    executor = CalrissianExecutor(max_ram_megabytes, max_cores)
    initialize_reporter(max_ram_megabytes, max_cores)
    runtime_context = CalrissianRuntimeContext(vars(parsed_args))
    runtime_context.select_resources = executor.select_resources
    install_signal_handler()
    try:
        result = cwlmain(args=parsed_args,
                         executor=executor,
                         loadingContext=CalrissianLoadingContext(),
                         runtimeContext=runtime_context,
                         versionfunc=version,
                         )
    finally:
        # Always clean up after cwlmain
        delete_pods()
        if parsed_args.usage_report:
            write_report(parsed_args.usage_report)
        flush_tees()

    return result
Exemple #2
0
 def test_write_report(self, mock_json, mock_open):
     initialize_reporter(128, 4)
     Reporter.add_report(
         TimedResourceReport(cpus=1,
                             ram_megabytes=128,
                             start_time=TIME_1000,
                             finish_time=TIME_1100))
     write_report('output.json')
     self.assertEqual(mock_open.call_args, call('output.json', 'w'))
     self.assertTrue(mock_json.dump.called)
Exemple #3
0
 def test_write_report_raises_if_not_initialized(self, mock_open):
     Reporter.timeline_report = None
     self.assertIsNone(Reporter.get_report())
     with self.assertRaises(AttributeError) as context:
         write_report('filename.out')
     self.assertIn('NoneType', str(context.exception))