def main(argv): import getopt OPTS = [ ("h", ""), ("d", ""), ("o", ":") ] USAGE = "[Usage] [-d delete files after merging] [-o merged file] [outfile file1 file2 file3 ... input files]" try: opts, args = op.process_opts( argv[1:], OPTS, USAGE ) except getopt.GetoptError as err: print( err ) if "h" in opts.keys(): print( USAGE ) exit(0) filenames = args outfile = opts.get( "o", "outfile_" + "".join( filenames ) ) filecontents = zip( filenames, map( lambda filename: file( filename ).read(), filenames ) ) if "d" in opts.keys(): cmd = "rm " map( lambda filename: os.system( cmd + filename ), filenames ) with open( outfile, "w" ) as f: f.write( "--------------------\n" ) f.write( "\n".join( map( lambda x: ":\n\n".join( x ) + "\n--------------------", filecontents ) ) )
def main(argv): import getopt OPTS = [("h", ""), ("t", ""), ("n", ":"), ("args", "=")] USAGE = ( "[Usage] [ -t time ] [ -n specified node # ] [ --args 'argv1 argv2 argv3 ...' ] [ file1.c file2.c file3.c ... ]" ) try: opts, args = op.process_opts(argv[1:], OPTS, USAGE) except getopt.GetoptError as err: print(err) if "h" in opts.keys(): print(USAGE) exit(0) if "t" in opts.keys(): run_cmd = "time " else: run_cmd = "" compile_cmd = "mpicc" run_cmd += "mpiexec" remove_cmd = "rm" filenames = args outfilenames = map(lambda x: re.sub("\.c", ".o", x), filenames) # Compiling files cmds = map(_generate_cmd, [compile_cmd] * len(filenames), outfilenames, filenames) map(_print, cmds) map(os.system, cmds) # Executing executables node_opt = opts.get("n", "") if len(node_opt) > 0: node_opt = " -npernode " + node_opt cmds = map( lambda x: run_cmd + node_opt + " " + x + " " + opts.get("args", "") + " > " + re.sub("\.o", ".log", x), outfilenames, ) map(_print, cmds) map(os.system, cmds) # Deleting executables cmds = map(lambda x: remove_cmd + " " + x, outfilenames) map(_print, cmds) map(os.system, cmds)
def main(argv): import getopt OPTS = [ ("h", ""), ("dir", "="), ("config", "=") ] USAGE = "\n".join( map( lambda x: "".join(x), OPTS ) ) try: opts, args = opt_processing.process_opts( argv[1:], OPTS, USAGE ) except getopt.GetoptError as err: print( err ) if "h" in opts.keys() or "config" not in opts.keys(): print( USAGE ) exit(0) out_dir = opts.get( "dir", "run_space" ) if out_dir.endswith( "/" ): out_dir = out_dir[0:-1] config_file = file( opts[ "config" ] ) if os.path.exists( out_dir ) and os.path.isdir( out_dir ): shutil.rmtree( out_dir ) os.makedirs( out_dir ) config = json.load( config_file ) queue_mode = config[ "queue_mode" ] job_name = config[ "job_name" ] rerunnable = config[ "rerunnable" ] exec_cmd = config[ "exec_cmd" ] outpath_prefix = config[ "outpath_prefix" ] x11_forwarding = config.get( "x11_forwarding", False ) res_configs = config[ "res_configs" ] n = len( res_configs ) outpaths = map( lambda x: "/".join( [ out_dir, outpath_prefix + str(x) + ".sh" ] ), np.arange( 0, n ) + 1 ) map( _dummy_gen_job_script, [queue_mode] * n, [job_name] * n, [rerunnable] * n, [exec_cmd] * n, outpaths, x11_forwarding, res_configs ) exit(0)
def main(argv): import getopt OPTS = [ ("h", ""), ("o", ":"), ("d", ""), ("b", ""), ("N", ":"), ("r", ""), ("nodes", "="), ("ppn", "="), ("wt", "=") ] USAGE = "\n".join( map( lambda x: "".join(x), OPTS ) ) try: opts, args = opt_processing.process_opts( argv[1:], OPTS, USAGE ) except getopt.GetoptError as err: print( err ) if "h" in opts.keys(): print( USAGE ) exit(0) queue_mode = "debug" rerunnable = "n" if "b" in opts.keys(): queue_mode = "batch" if "r" in opts.keys(): rerunnable = "y" job_name = opts.get( "N", "MY_JOB" ) nodes_num = opts.get( "nodes", "1" ) ppn_num = opts.get( "ppn", "4" ) tasks = "-l nodes=" + nodes_num + ":ppn=" + ppn_num wt = opts.get( "wt", "00:01:00" ) outpath = opts.get( "o", "job" ) if not outpath.endswith( ".sh" ): outpath += ".sh" gen_job_script( queue_mode, job_name, rerunnable, nodes_num, ppn_num, wt, " ".join( args[0:] ), outpath )