def get_cache(key, timeout): fn = get_file_name(key) path = Path(CACHE_DIR, fn) data = open_and_read(path) if data is None: return None try: data = loads(data) except: safe_mkdir(path) return None ret = data["data"] ts = data["time_stamp"] if time() - ts > timeout: safe_remove(Path(CACHE_DIR, ret)) return None if file_size(Path(CACHE_DIR, ret)): return ret return None
from subprocess import call from shutil import copyfile import glob import numpy as np #import h5py import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import pylab as pl sys.path.insert(0, '../script/') sys.path.insert(0, '../script/analysis/') import util import hdf5_to_dict as io TMP_DIR = 'TMP' TMP_BUILD = 'build_tmp.py' util.safe_remove(TMP_DIR) AUTO = False for arg in sys.argv: if arg == '-auto': AUTO = True RES = [16, 32, 64]#, 128] util.make_dir(TMP_DIR) os.chdir('../prob/mhdmodes2d/') copyfile('build.py', TMP_BUILD) # COMPILE CODE AT MULTIPLE RESOLUTIONS USING SEPARATE BUILD FILE for n in xrange(len(RES)):
import sys sys.dont_write_bytecode = True sys.path.insert(0, '../script/') sys.path.insert(0, '../script/analysis') from subprocess import call import glob import numpy as np from scipy import optimize import hdf5_to_dict as io import units cgs = units.get_cgs() import util from bhlight import bcall TMP_DIR = 'TMP' util.safe_remove(TMP_DIR) PROBLEM = 'binning' AUTO = '-auto' in sys.argv MPI = '-mpi' in sys.argv if '-idim' in sys.argv: IDIM = int(sys.argv[sys.argv.index('-idim') + 1]) else: IDIM = 0 os.chdir('../prob/' + PROBLEM) # COMPILE CODE args = [sys.executable, 'build.py', '-dir', TMP_DIR, '-idim', str(IDIM)] if MPI: args += ['-mpi'] call(args)
parser.add_argument('--nproc', dest='nproc', default=None, type=int, help=('Number of parallel processe to use. ' + 'If not set, defaults to all available cores.')) args = parser.parse_args() dfold = util.sanitize_path(args.dumpfolder) if not os.path.exists(dfold): print('ERROR Folder ' + dfnam + ' does not exist!') sys.exit() tmpdir = 'FRAMES' util.safe_remove(tmpdir) os.mkdir(tmpdir) dfnams = io.get_dumps_full(dfold) hdr = io.load_hdr(dfnams[0]) geom = io.load_geom(hdr) num_files = len(dfnams) def make_frame(pair): i, d = pair gc.collect() print("frame %d/%d" % (i, num_files)) make_snap(d, args.variable, args.coords,
def close_lockfile(filename: str) -> str: safe_mkdir(FOLDER) rm_path = lockfile_path(filename) safe_remove(rm_path)
def invalidate(key): info, binary = get_paths(key) safe_remove(info) safe_remove(binary) close_lockfile(info) close_lockfile(binary)