def terminateProcess(signalNumber, frame):
    print('checkpointing the model triggered by kill -15 signal')
    for f in glob.glob(save_files):
        os.remove(f)
    model.save((((('/scratch/li.baol/checkpoint_max_param/' + job_name) + '_') + str(current_epoch)) + '.h5'))
    print('(SIGTERM) terminating the process')
    checkpoint_dict = {}
    with open('checkpoint.json', 'r') as fp:
        checkpoint_dict = json.load(fp)
    checkpoint_dict[job_name] = 1
    json_file3 = json.dumps(checkpoint_dict)
    with open('checkpoint.json', 'w') as fp:
        fp.write(json_file3)
    sys.exit()
def terminateProcess(signalNumber, frame):
    print('checkpointing the model triggered by kill -15 signal')
    for f in glob.glob(save_files):
        os.remove(f)
    model.save((((('/scratch/li.baol/checkpoint_max_param/' + job_name) + '_') + str(current_epoch)) + '.h5'))
    print('(SIGTERM) terminating the process')
    checkpoint_dict = {}
    with open('checkpoint.json', 'r') as fp:
        checkpoint_dict = json.load(fp)
    checkpoint_dict[job_name] = 1
    json_file3 = json.dumps(checkpoint_dict)
    with open('checkpoint.json', 'w') as fp:
        fp.write(json_file3)
    sys.exit()