File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 2222#
2323
2424from pathlib import Path
25+ from time import sleep
2526
2627import numpy as np
2728import pandas as pd
3940 plot_volumewise_motion ,
4041)
4142
42- if not (Path .home () / ".dipy" / "stanford_hardi" ).exists ():
43+ # Folders are atomic operations in NFS, therefore, creating folders is a good
44+ # way to implement rudimentary semaphores/locks.
45+ # OE: we are running into race conditions for the way dipy downloads data.
46+ # The delayed creation of the "stanford_hardi" directory makes this test
47+ # for data existence very flaky.
48+ # Replacing with a pure lock based on directory creation.
49+ dipy_datapath = Path .home () / ".dipy"
50+ if not (lock_folder := dipy_datapath / ".lock-stanford_hardi" ).exists ():
51+ lock_folder .mkdir (parents = True )
4352 fetch_stanford_hardi ()
4453
54+ MAX_CHECKS = 20
55+ try_num = 1
56+ while not (dipy_datapath / "stanford_hardi" ).exists ():
57+ sleep (5 * try_num )
58+ try_num += 1
59+
60+ if try_num > MAX_CHECKS :
61+ raise RuntimeError ("Error downloading DIPY's stanford_hardi dataset" )
62+
4563img , _ = read_stanford_hardi ()
4664img_data = img .get_fdata ()
4765
You can’t perform that action at this time.
0 commit comments