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 .logging import logger
|
||||
|
||||
__version__ = '22.6'
|
||||
__version__ = '23.4'
|
||||
|
||||
|
||||
def open(directory='', topology='*.tpr', trajectory='*.xtc', cached=False,
|
||||
|
@ -106,42 +106,45 @@ def is_writeable(fname):
|
||||
|
||||
def nojump_load_filename(reader):
|
||||
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):
|
||||
fname_fallback = os.path.join(
|
||||
os.path.join(os.environ['HOME'], '.mdevaluate/nojump'),
|
||||
user_data_dir = os.path.join("/data/",
|
||||
os.environ['HOME'].split("/")[-1])
|
||||
full_path_fallback = os.path.join(
|
||||
os.path.join(user_data_dir, '.mdevaluate/nojump'),
|
||||
directory.lstrip('/'),
|
||||
'.{}.nojump.npz'.format(fname)
|
||||
)
|
||||
if os.path.exists(fname_fallback):
|
||||
return fname_fallback
|
||||
if os.path.exists(full_path_fallback):
|
||||
return full_path_fallback
|
||||
if os.path.exists(fname) or is_writeable(directory):
|
||||
return fname
|
||||
return full_path
|
||||
else:
|
||||
fname = os.path.join(
|
||||
os.path.join(os.environ['HOME'], '.mdevaluate/nojump'),
|
||||
user_data_dir = os.path.join("/data/",
|
||||
os.environ['HOME'].split("/")[-1])
|
||||
full_path_fallback = os.path.join(
|
||||
os.path.join(user_data_dir, '.mdevaluate/nojump'),
|
||||
directory.lstrip('/'),
|
||||
'.{}.nojump.npz'.format(fname)
|
||||
)
|
||||
logger.info('Saving nojump to {}, since original location is not writeable.'.format(fname))
|
||||
os.makedirs(os.path.dirname(fname), exist_ok=True)
|
||||
return fname
|
||||
return full_path
|
||||
|
||||
def nojump_save_filename(reader):
|
||||
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):
|
||||
return fname
|
||||
return full_path
|
||||
else:
|
||||
fname = os.path.join(
|
||||
os.path.join(os.environ['HOME'], '.mdevaluate/nojump'),
|
||||
user_data_dir = os.path.join("/data/",
|
||||
os.environ['HOME'].split("/")[-1])
|
||||
full_path_fallback = os.path.join(
|
||||
os.path.join(user_data_dir, '.mdevaluate/nojump'),
|
||||
directory.lstrip('/'),
|
||||
'.{}.nojump.npz'.format(fname)
|
||||
)
|
||||
logger.info('Saving nojump to {}, since original location is not writeable.'.format(fname))
|
||||
os.makedirs(os.path.dirname(fname), exist_ok=True)
|
||||
return fname
|
||||
|
||||
logger.info('Saving nojump to {}, since original location is not writeable.'.format(full_path_fallback))
|
||||
os.makedirs(os.path.dirname(full_path_fallback), exist_ok=True)
|
||||
return full_path_fallback
|
||||
|
||||
|
||||
CSR_ATTRS = ('data', 'indices', 'indptr')
|
||||
|
Loading…
Reference in New Issue
Block a user