def main(): # Parse the command-line arguments (requires the argparse module) # args = parse_command_line_arguments() # AJ: change path to intended input file # args = parse_command_line_arguments(["/Users/agnes/Documents/Software/RMG/RMG-Py/examples/rmg/superminimal/input.py"]) args = parse_command_line_arguments( ["./examples/rmg/superminimal/input.py"]) if args.postprocess: print "Postprocessing the profiler statistics (will be appended to RMG.log)" else: # Initialize the logging system (resets the RMG.log file) level = logging.INFO if args.debug: level = 0 elif args.verbose: level = logging.DEBUG elif args.quiet: level = logging.WARNING initializeLog(level, os.path.join(args.output_directory, 'RMG.log')) logging.info(rmgpy.settings.report()) kwargs = { 'restart': args.restart, 'walltime': args.walltime, 'kineticsdatastore': args.kineticsdatastore } if args.profile: import cProfile global_vars = {} local_vars = { 'inputFile': args.file, 'output_dir': args.output_directory, 'kwargs': kwargs, 'RMG': RMG } command = """rmg = RMG(inputFile=inputFile, outputDirectory=output_dir); rmg.execute(**kwargs)""" stats_file = os.path.join(args.output_directory, 'RMG.profile') print("Running under cProfile") if not args.postprocess: # actually run the program! cProfile.runctx(command, global_vars, local_vars, stats_file) # postprocess the stats log_file = os.path.join(args.output_directory, 'RMG.log') processProfileStats(stats_file, log_file) makeProfileGraph(stats_file) else: rmg = RMG(inputFile=args.file, outputDirectory=args.output_directory) rmg.execute(**kwargs)
def main(): # Parse the command-line arguments (requires the argparse module) args = parse_command_line_arguments() if args.postprocess: print "Postprocessing the profiler statistics (will be appended to RMG.log)" else: # Initialize the logging system (resets the RMG.log file) level = logging.INFO if args.debug: level = 0 elif args.verbose: level = logging.DEBUG elif args.quiet: level = logging.WARNING initializeLog(level, os.path.join(args.output_directory, 'RMG.log')) logging.info(rmgpy.settings.report()) kwargs = { 'restart': args.restart, 'walltime': args.walltime, 'kineticsdatastore': args.kineticsdatastore } if args.profile: import cProfile global_vars = {} local_vars = { 'inputFile': args.file, 'output_dir': args.output_directory, 'kwargs': kwargs, 'RMG': RMG } command = """rmg = RMG(inputFile=inputFile, outputDirectory=output_dir); rmg.execute(**kwargs)""" stats_file = os.path.join(args.output_directory, 'RMG.profile') print("Running under cProfile") if not args.postprocess: # actually run the program! cProfile.runctx(command, global_vars, local_vars, stats_file) # postprocess the stats log_file = os.path.join(args.output_directory, 'RMG.log') processProfileStats(stats_file, log_file) makeProfileGraph(stats_file) else: rmg = RMG(inputFile=args.file, outputDirectory=args.output_directory) rmg.execute(**kwargs)
'walltime': args.walltime, } if args.profile: import cProfile, sys, pstats, os global_vars = {} local_vars = { 'inputFile': inputFile, 'output_dir': output_dir, 'kwargs': kwargs, 'RMG': RMG } command = """rmg = RMG(); rmg.execute(inputFile, output_dir, **kwargs)""" stats_file = os.path.join(args.output_directory, 'RMG.profile') print("Running under cProfile") if not args.postprocess: # actually run the program! cProfile.runctx(command, global_vars, local_vars, stats_file) # postprocess the stats log_file = os.path.join(args.output_directory, 'RMG.log') processProfileStats(stats_file, log_file) makeProfileGraph(stats_file) else: rmg = RMG() rmg.execute(inputFile, output_dir, **kwargs)
'restart': args.restart, 'walltime': args.walltime, } if args.profile: import cProfile, sys, pstats, os global_vars = {} local_vars = { 'inputFile': inputFile, 'output_dir': output_dir, 'kwargs': kwargs, 'RMG': RMG } command = """rmg = RMG(inputFile=inputFile, outputDirectory=output_dir); rmg.execute(**kwargs)""" stats_file = os.path.join(args.output_directory,'RMG.profile') print("Running under cProfile") if not args.postprocess: # actually run the program! cProfile.runctx(command, global_vars, local_vars, stats_file) # postprocess the stats log_file = os.path.join(args.output_directory,'RMG.log') processProfileStats(stats_file, log_file) makeProfileGraph(stats_file) else: rmg = RMG(inputFile=inputFile, outputDirectory=output_dir) rmg.execute(**kwargs)