-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Travis CI fails intermittently due to file not found #210
Comments
I am not sure I get this issue. Can you a bit more explicit ? For me file exists, |
I think this is because one of the test function is badly written and writes twice the same data, which creeps travis out. I tried to address it in next PR |
PR Merged. Closing. |
The issue still persists (moments, a go I've had to rebuild a PR, because is failed thus). Re-opening. |
I can reproduce locally but you have to clean the files in rm -rf /tmp/titi && nosetests pypreprocess/tests/test_subject_data.py -m test_not_uniq Doing that in a loop I get 10-20 failures for 100 attempts: (for i in $(seq 1 100); do
rm -rf /tmp/titi && nosetests pypreprocess/tests/test_subject_data.py -m test_not_uniq
done) 2>&1 | tee test.log In general it is not great that the tests leave files around after finishing, also you should probably use |
I debugged this further, and there is a problem in def _make_sd(func_filenames=None, anat_filename=None, ext=".nii.gz",
n_sessions=1, make_sess_dirs=False, func_ndim=4,
unique_func_names=False, output_dir="/tmp/titi"):
if not func_filenames is None:
n_sessions = len(func_filenames)
func = [create_random_image(ndim=func_ndim) for _ in range(n_sessions)]
anat = create_random_image(ndim=3)
if anat_filename is None:
anat_filename = '%s/anat%s' % (DATA_DIR, ext)
_save_img(anat, anat_filename)
if not func_filenames is None:
for sess_func, filename in zip(func, func_filenames):
if isinstance(filename, _basestring):
_save_img(sess_func, filename)
else:
vols = nibabel.four_to_three(sess_func)
# The problem is that sess_func (a random 4d image)
# can have 1 as the last dimension. If that happens
# vols has one element only. In the test
# func_filename is a list of list of 2 elements
# [['img1', 'img2'], ['img3', 'img4']] so filename has
# 2 elements. That means that the zip on the next line
# is only over 1 element and you only write one file
# out of the two you are supposed to write, hence the
# FileNotFoundError
for x, y in zip(vols, filename):
assert isinstance(y, _basestring), type(y)
_save_img(x, y)
else:
func_filenames = []
for sess in range(n_sessions):
sess_dir = DATA_DIR if not make_sess_dirs else os.path.join(
DATA_DIR, "session%i" % sess)
if not os.path.exists(sess_dir):
os.makedirs(sess_dir)
func_filename = '%s/func%s%s' % (
sess_dir, "_sess_%i_" % sess if (
n_sessions > 1 and unique_func_names) else "", ext)
_save_img(func[sess], func_filename)
func_filenames.append(func_filename)
sd = SubjectData(anat=anat_filename,
func=func_filenames,
output_dir=output_dir)
return sd |
Update on this : @lesteve did the hardwork here and his last comment is right on point. But this bug is still happening randomly sometimes, I will redesign the concerned test to make it deterministic. |
It says,
IOError: [Errno 2] No such file or directory: '/tmp/titi/func/3.hdr'
The text was updated successfully, but these errors were encountered: