def load_or_run(filepath, fun, *args, **kwargs):
    """
    계산된 결과 파일이 있으면 로딩하고, 없으면 계산후 저장
    ex)
    res = load_or_run('file_loadorsave', funlongtime, ...., force=False)
    :param filepath:
    :param fun:
    :param force:
    :return:
    """
    force = kwargs.pop('force', False)
    compress = kwargs.pop('compress', True)

    if not filepath.startswith('/') or not filepath.startswith('~'):
        filepath = os.path.join('/tmp/snipy/load_or_run/', filepath)

    if not force and os.path.exists(filepath):
        # 저장되어 있는 것 로딩
        mmap_mode = 'r+' if not compress else None
        return loadfile(filepath, mmap_mode=mmap_mode)

    res = fun(*args, **kwargs)
    savefile(res, filepath, compress=compress)

    return res
def load_or_run(filepath, fun, *args, **kwargs):
    
    force = kwargs.pop('force', False)
    compress = kwargs.pop('compress', True)

    if not filepath.startswith('/') or not filepath.startswith('~'):
        filepath = os.path.join('/tmp/snipy/load_or_run/', filepath)

    if not force and os.path.exists(filepath):
        
        mmap_mode = 'r+' if not compress else None
        return loadfile(filepath, mmap_mode=mmap_mode)

    res = fun(*args, **kwargs)
    savefile(res, filepath, compress=compress)

    return res
def load_or_run ( filepath , fun , * args , * * kwargs ) : force = kwargs . pop ( 'force' , False ) compress = kwargs . pop ( 'compress' , True ) if not filepath . startswith ( '/' ) or not filepath . startswith ( '~' ) : filepath = os . path . join ( '/tmp/snipy/load_or_run/' , filepath ) if not force and os . path . exists ( filepath ) : # 저장되어 있는 것 로딩 mmap_mode = 'r+' if not compress else None return loadfile ( filepath , mmap_mode = mmap_mode ) res = fun ( * args , * * kwargs ) savefile ( res , filepath , compress = compress ) return res
계산된 결과 파일이 있으면 로딩하고, 없으면 계산후 저장
    ex)
    res = load_or_run('file_loadorsave', funlongtime, ...., force=False)
    :param filepath:
    :param fun:
    :param force:
    :return:
계산된 결과 파일이 있으면 로딩하고 없으면 계산후 저장 ex ) res = load_or_run ( file_loadorsave funlongtime .... force = False ) : param filepath : : param fun : : param force : : return :