Nojump matrix is now saved in data when trajectory dir is not writable

This commit is contained in:
sebastiankloth 2023-04-20 13:35:10 +02:00
parent 78f0b3d727
commit d89c903e5d
3 changed files with 24 additions and 21 deletions

View File

@ -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,

View File

@ -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')

View File

@ -22,6 +22,6 @@ setup(
'index-xtc = mdevaluate.cli:run'
]
},
version='22.11',
version='23.4',
requires=['numpy', 'scipy'],
)