Nojump matrix is now saved in data when trajectory dir is not writable
This commit is contained in:
parent
78f0b3d727
commit
d89c903e5d
@ -11,7 +11,7 @@ from . import autosave
|
|||||||
from . import reader
|
from . import reader
|
||||||
from .logging import logger
|
from .logging import logger
|
||||||
|
|
||||||
__version__ = '22.6'
|
__version__ = '23.4'
|
||||||
|
|
||||||
|
|
||||||
def open(directory='', topology='*.tpr', trajectory='*.xtc', cached=False,
|
def open(directory='', topology='*.tpr', trajectory='*.xtc', cached=False,
|
||||||
|
@ -106,44 +106,47 @@ def is_writeable(fname):
|
|||||||
|
|
||||||
def nojump_load_filename(reader):
|
def nojump_load_filename(reader):
|
||||||
directory, fname = path.split(reader.filename)
|
directory, fname = path.split(reader.filename)
|
||||||
fname = path.join(directory, '.{}.nojump.npz'.format(fname))
|
full_path = path.join(directory, '.{}.nojump.npz'.format(fname))
|
||||||
if not is_writeable(directory):
|
if not is_writeable(directory):
|
||||||
fname_fallback = os.path.join(
|
user_data_dir = os.path.join("/data/",
|
||||||
os.path.join(os.environ['HOME'], '.mdevaluate/nojump'),
|
os.environ['HOME'].split("/")[-1])
|
||||||
|
full_path_fallback = os.path.join(
|
||||||
|
os.path.join(user_data_dir, '.mdevaluate/nojump'),
|
||||||
directory.lstrip('/'),
|
directory.lstrip('/'),
|
||||||
'.{}.nojump.npz'.format(fname)
|
'.{}.nojump.npz'.format(fname)
|
||||||
)
|
)
|
||||||
if os.path.exists(fname_fallback):
|
if os.path.exists(full_path_fallback):
|
||||||
return fname_fallback
|
return full_path_fallback
|
||||||
if os.path.exists(fname) or is_writeable(directory):
|
if os.path.exists(fname) or is_writeable(directory):
|
||||||
return fname
|
return full_path
|
||||||
else:
|
else:
|
||||||
fname = os.path.join(
|
user_data_dir = os.path.join("/data/",
|
||||||
os.path.join(os.environ['HOME'], '.mdevaluate/nojump'),
|
os.environ['HOME'].split("/")[-1])
|
||||||
|
full_path_fallback = os.path.join(
|
||||||
|
os.path.join(user_data_dir, '.mdevaluate/nojump'),
|
||||||
directory.lstrip('/'),
|
directory.lstrip('/'),
|
||||||
'.{}.nojump.npz'.format(fname)
|
'.{}.nojump.npz'.format(fname)
|
||||||
)
|
)
|
||||||
logger.info('Saving nojump to {}, since original location is not writeable.'.format(fname))
|
return full_path
|
||||||
os.makedirs(os.path.dirname(fname), exist_ok=True)
|
|
||||||
return fname
|
|
||||||
|
|
||||||
def nojump_save_filename(reader):
|
def nojump_save_filename(reader):
|
||||||
directory, fname = path.split(reader.filename)
|
directory, fname = path.split(reader.filename)
|
||||||
fname = path.join(directory, '.{}.nojump.npz'.format(fname))
|
full_path = path.join(directory, '.{}.nojump.npz'.format(fname))
|
||||||
if is_writeable(directory):
|
if is_writeable(directory):
|
||||||
return fname
|
return full_path
|
||||||
else:
|
else:
|
||||||
fname = os.path.join(
|
user_data_dir = os.path.join("/data/",
|
||||||
os.path.join(os.environ['HOME'], '.mdevaluate/nojump'),
|
os.environ['HOME'].split("/")[-1])
|
||||||
|
full_path_fallback = os.path.join(
|
||||||
|
os.path.join(user_data_dir, '.mdevaluate/nojump'),
|
||||||
directory.lstrip('/'),
|
directory.lstrip('/'),
|
||||||
'.{}.nojump.npz'.format(fname)
|
'.{}.nojump.npz'.format(fname)
|
||||||
)
|
)
|
||||||
logger.info('Saving nojump to {}, since original location is not writeable.'.format(fname))
|
logger.info('Saving nojump to {}, since original location is not writeable.'.format(full_path_fallback))
|
||||||
os.makedirs(os.path.dirname(fname), exist_ok=True)
|
os.makedirs(os.path.dirname(full_path_fallback), exist_ok=True)
|
||||||
return fname
|
return full_path_fallback
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CSR_ATTRS = ('data', 'indices', 'indptr')
|
CSR_ATTRS = ('data', 'indices', 'indptr')
|
||||||
NOJUMP_MAGIC = 2016
|
NOJUMP_MAGIC = 2016
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user