-
Notifications
You must be signed in to change notification settings - Fork 532
cfs checks #2428
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
cfs checks #2428
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. A couple comments.
nipype/utils/filemanip.py
Outdated
>>> filepath = os.path.dirname(os.path.realpath( __file__ )) | ||
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data')) | ||
>>> os.chdir(datadir) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to drop the doctests?
nipype/utils/filemanip.py
Outdated
break | ||
crypto_obj.update(data) | ||
hex = crypto_obj.hexdigest() | ||
return hex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're dropping the raise_notfound
check, I'd prefer to leave it:
if not op.isfile(afile):
return None
crypto_obj = crypto()
...
This checks against bad input, and then runs the function as normal, rather than wrapping the entire behavior in an if block. I don't see a compelling reason to move from this approach.
If we need to move to a big if
statement, you should not use the keyword hex
as a variable name.
nipype/utils/filemanip.py
Outdated
fmlogger.debug('mount file system types not described by fstype') | ||
except: | ||
fmlogger.debug('mount file system type check for CIFS error') | ||
return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just:
cifs_paths = [entry[0] for entry in mount_info if len(entry) > 1 and entry[1] == 'cifs']
Unless there's a case where a CIFS mount would fall into the case where len(entry) == 1
, the warning seems like it'll be noise in the log.
Under what cases were you hitting this error, by the way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the removed lines were just a mistake on my part because I had moved the file from an older version of the nipype source. I think those lines should now be back in. Really the only part I introduced was the cifs table checking. It seems to work with my own mount table which now has about a dozen entries. This seems to be run only on the initial import, so the debug lines shouldn't be too great and should only be for those mount entries that only have a single item length.
The error shows up like this for anyone else who might run into this:
import nipype
...
File "nipype/utils/filemanip.py", line 272, in _generate_cifs_table
cifs_paths = [path for path, fstype in mount_info if fstype == 'cifs']
ValueError: need more than 1 value to unpack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean what does your mount
output look like that doesn't have 5 entries in a given row?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "mount" output and the mount_info in python looks like this:
% mount
/dev/disk2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
map -fstab on /Network/Servers (autofs, automounted, nobrowse)
/dev/disk4s2 on /Volumes/DG TimeMachine (hfs, local, nodev, nosuid, journaled)
/dev/disk3s2 on /Volumes/MyBookData (hfs, local, nodev, nosuid, journaled)
afni:/elrond0 on /Volumes/afni (nfs)
afni:/var/www/INCOMING on /Volumes/INCOMING (nfs)
afni:/fraid on /Volumes/afni (nfs, asynchronous)
boromir:/raid.bot on /Volumes/raid.bot (nfs)
elros:/volume2/AFNI_SHARE on /Volumes/AFNI_SHARE (nfs)
map -static on /Volumes/safni (autofs, automounted, nobrowse)
map -static on /Volumes/raid.top (autofs, automounted, nobrowse)
/dev/disk1s3 on /Volumes/Boot OS X (hfs, local, journaled, nobrowse)
ipdb> mount_info
[['/Volumes/MyBookData', 'local,'], ['/Volumes/AFNI_SHARE'], ['/Volumes/INCOMING'], ['/Volumes/raid.bot'], ['/Volumes/afni'], ['/Volumes/afni', 'asynchronous)'], ['/Volumes/Boot', 'X'], ['/Volumes/DG', '(hfs,'], ['/dev', 'local,'], ['on', '(autofs,'], ['on', '(autofs,'], ['on', '(autofs,'], ['on', '(autofs,'], ['on', '(autofs,'], ['/', 'local,']]
Okay, so the issue seems to be that OSX has different mount output from
Linux. I think we can make another case where we build the (mount point,
filesystem type) pairs for OSX.
…On Feb 8, 2018 18:28, "Daniel Glen" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In nipype/utils/filemanip.py
<#2428 (comment)>:
> + # find which mount points are CIFS
+ # init to empty list
+ cifs_paths = []
+
+ try:
+ for path_and_fstype in mount_info:
+ # need to check for tables that have only path and no fstype
+ if len(path_and_fstype) == 2:
+ # if this entry is cifs, add it to list
+ if path_and_fstype[1] == 'cifs':
+ cifs_paths.append(path_and_fstype[0])
+ else:
+ fmlogger.debug('mount file system types not described by fstype')
+ except:
+ fmlogger.debug('mount file system type check for CIFS error')
+ return []
the "mount" output and the mount_info in python looks like this:
% mount
/dev/disk2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
map -fstab on /Network/Servers (autofs, automounted, nobrowse)
/dev/disk4s2 on /Volumes/DG TimeMachine (hfs, local, nodev, nosuid,
journaled)
/dev/disk3s2 on /Volumes/MyBookData (hfs, local, nodev, nosuid, journaled)
afni:/elrond0 on /Volumes/afni (nfs)
afni:/var/www/INCOMING on /Volumes/INCOMING (nfs)
afni:/fraid on /Volumes/afni (nfs, asynchronous)
boromir:/raid.bot on /Volumes/raid.bot (nfs)
elros:/volume2/AFNI_SHARE on /Volumes/AFNI_SHARE (nfs)
map -static on /Volumes/safni (autofs, automounted, nobrowse)
map -static on /Volumes/raid.top (autofs, automounted, nobrowse)
/dev/disk1s3 on /Volumes/Boot OS X (hfs, local, journaled, nobrowse)
ipdb> mount_info
[['/Volumes/MyBookData', 'local,'], ['/Volumes/AFNI_SHARE'],
['/Volumes/INCOMING'], ['/Volumes/raid.bot'], ['/Volumes/afni'],
['/Volumes/afni', 'asynchronous)'], ['/Volumes/Boot', 'X'], ['/Volumes/DG',
'(hfs,'], ['/dev', 'local,'], ['on', '(autofs,'], ['on', '(autofs,'],
['on', '(autofs,'], ['on', '(autofs,'], ['on', '(autofs,'], ['/', 'local,']]
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2428 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAFF8iLmrf0k9E2jv1eFixPLrkCq08Nrks5tS4M7gaJpZM4R787H>
.
|
Yes, that seems like the case. I have a couple mount points that aren't working properly at the moment, and those are the ones that aren't passing the double string minimum. There are a few problems like spaces in the mounted directory names. The file system strings are probably not the ones you're looking for. The way they are currently parsed gets a parenthesis and a comma. In the end, you're only looking for cifs file systems here. I'm not sure these are used on Macs at all, but I can't say they never exist on Macs. |
So looks like we have two formats: Linux: They're only a little different, so I think we can come up with a regular expression that will match either case: pattern = re.compile(r'.*? on (/.*?) (?:type |\()(\S+)(?:, |\)| )') Now mount_info = sorted((pattern.match(l).groups() for l in output.splitlines()),
key=lambda x: len(x[0]), reverse=True)
cifs_paths = [path for path, fstype in mount_info if fstype.lower() == 'cifs'] (I added in a Running it on your output, I get: >>> mount_info
[('/Volumes/DG TimeMachine ', 'hfs'),
('/Volumes/MyBookData', 'hfs'),
('/Volumes/AFNI_SHARE', 'nfs'),
('/Volumes/Boot OS X', 'hfs'),
('/Volumes/INCOMING', 'nfs'),
('/Volumes/raid.bot', 'nfs'),
('/Volumes/raid.top', 'autofs'),
('/Network/Servers', 'autofs'),
('/Volumes/safni', 'autofs'),
('/Volumes/afni', 'nfs'),
('/Volumes/afni', 'nfs'),
('/home', 'autofs'),
('/dev', 'devfs'),
('/net', 'autofs'),
('/', 'hfs')] On my system I get: >>> mount_info
[('/sys/fs/cgroup/net_cls,net_prio', 'cgroup'),
('/sys/fs/cgroup/cpu,cpuacct', 'cgroup'),
('/sys/firmware/efi/efivars', 'efivarfs'),
('/sys/fs/cgroup/perf_event', 'cgroup'),
('/proc/sys/fs/binfmt_misc', 'autofs'),
('/sys/fs/fuse/connections', 'fusectl'),
('/sys/fs/cgroup/systemd', 'cgroup'),
('/sys/fs/cgroup/hugetlb', 'cgroup'),
('/sys/fs/cgroup/freezer', 'cgroup'),
('/sys/fs/cgroup/devices', 'cgroup'),
('/sys/fs/cgroup/memory', 'cgroup'),
('/sys/fs/cgroup/cpuset', 'cgroup'),
('/sys/kernel/security', 'securityfs'),
('/sys/fs/cgroup/blkio', 'cgroup'),
('/var/lib/docker/aufs', 'ext4'),
('/sys/fs/cgroup/pids', 'cgroup'),
('/run/user/1002/gvfs', 'fuse.gvfsd-fuse'),
('/sys/kernel/debug', 'debugfs'),
('/sys/fs/cgroup', 'tmpfs'),
('/sys/fs/pstore', 'pstore'),
('/dev/hugepages', 'hugetlbfs'),
('/run/user/1002', 'tmpfs'),
('/dev/mqueue', 'mqueue'),
('/run/lock', 'tmpfs'),
('/boot/efi', 'vfat'),
('/dev/pts', 'devpts'),
('/dev/shm', 'tmpfs'),
('/proc', 'proc'),
('/sys', 'sysfs'),
('/dev', 'devtmpfs'),
('/run', 'tmpfs'),
('/', 'ext4')] I suspect if we end up needing to deal with more formats, it won't make sense to keep maintaining the one regex, but for now it's simple enough. |
Hi @afni-dglen any thoughts on the approach I outlined above? (And any time to finish this off?) |
I think this is worth fixing for 1.0.1, so I'll go ahead and make the changes I suggested, and add some tests. I wonder if someone using Windows in Docker (@chrisfilo?) could quickly get a Linux docker run --rm -it -v <some_path>:/data busybox mount And OSX too, for that matter, but I don't know how easy that is. |
Only cool kids can do this
|
Made the cfs checks a little more robust
Fixes # .
Changes proposed in this pull request