示例#1
0
文件: IO.py 项目: nico202/pyNeMo
def read_output(f, path, idx=0, total=0):
    import imp
    #Move import_istory to libs.IO?
    from plugins.importer import import_history
    from os.path import isfile, join

    fail = False
    print "[%s/%s]\tUsing file: %s" % (idx, total, f)
    #_input.bz2 could be used, but is more difficult to extract, and is heavier
    input_file = join(path, f.split("_")[1]) + "_input.py"
    try:
        input_conf = imp.load_source('*', input_file)
    except IOError: #File _input.py missing, save name to file, will try later?
        broken = open('ANALYSIS_FAILED.csv', 'a')
        broken.write("%s,%s\n" % (f.split("_")[0], f.split("_")[1]))
        broken.close()
        cprint("FAILED, SKIPPING", 'fail')
        fail = True
    except SyntaxError:
        broken = open('CONVERT_VUE_TO_PY.csv', 'a')
        broken.write("%s,%s\n" % (f.split("_")[0], f.split("_")[1]))
        broken.close()
        cprint("FAILED, SKIPPING", 'fail')
        fail = True
    input_conf = vars(input_conf)
    remove = ["step_input", "_S", "_N", "_stimuli", "_typicalN"]
    input_conf_clear = {}
    for var in input_conf:
        if var not in remove and not var.startswith("__"):
            input_conf_clear[var] = input_conf[var]
    data = import_history(join(path, f), compressed=True) #FIXME: allow uncompressed

    return data, input_conf_clear if not fail else False
示例#2
0
def main_loop(content, remote, dummy):
    i = 0
    total = len(content)
    for values in content:
        filename = "./%s/%s_%s.png" % (values[1], values[2], values[3])
        cprint("[%s/%s] %s match and is missing, generating image\r" % (i, total, filename), 'info')
        #TODO:allow compressed
        data = import_history("%s/%s_%s_output.gz" % (values[0], values[2], values[3]), compressed=True)
        state = ImageIO.ImageFromSpikes(
            data["NeMo"][1],
            file_path = filename,
            save = True,
            show = False
        )
        del state
        del data #Memory leak again?
        i += 1
示例#3
0
文件: Batch.py 项目: nico202/pyNeMo
cprint ("Saving %s commands to file: %s" % (len(real_commands), commands_file), 'info')
saveKey(commands_file, commands)
# Debug: re-enable in release
# cprint("Running in 5s", "warning")
# time.sleep(5)

#Start
is_folder (output_dir)

cprint("We'll use %s as output dir" % (output_dir), 'info')

#Let's run the simulations (surely not the best way, but does the job)
#TODO: add the loop inside Runner?
start = time.time()
try:
    run = import_history(output_dir + "/" + session_hash + "_batch")
    recover_from_lap = run["cycle"]
    cprint("You already run this sym, recovering from %s"
           % (recover_from_lap), 'okblue')
except IOError:
    print("First time you run this exact sim")
    recover_from_lap = 0
    pass

last_save_time = time.time()
all_start_time = last_save_time
next_sleep = False
forced_quit = False
lap = 0
laps = len(real_commands)
cprint ("We are going to run %s simulations!" % (laps), 'okblue')