Skip to content
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

dwifslpreproc: a python inconsistancy. #2190

Open
treanus opened this issue Oct 2, 2020 · 1 comment
Open

dwifslpreproc: a python inconsistancy. #2190

treanus opened this issue Oct 2, 2020 · 1 comment

Comments

@treanus
Copy link

treanus commented Oct 2, 2020

Please use this form for bug reports only; for installation problems, and general questions and support, please consult the community forum.

The bug is described at https://community.mrtrix.org/t/dwifslpreproc-error-on-a-cluster/4144/2

A clear and concise description of what the bug is; including if appropriate
how the observed behaviour differs from that expected.

dwifslpreproc does not run with python2.7

Please provide the following information:

OS = Linux on the HPC.

@treanus treanus added the bug label Oct 2, 2020
@Lestropie
Copy link
Member

Thanks for the report @treanus.

There's a few different things conspiring together here:

  • On error, FSL eddy can produce non-Unicode data at the end of its output (source unknown). I have some vague recollection that it can do this when printing its help page also, which caused me issues elsewhere.

  • In run.command(), while the text that is written to the terminal is explicitly Unicode-decoded with replacement of decoding errors, what is returned in the MRtrixCmdError exception is not decoded.

  • The line eddy_output_file.write(str(exception_cuda)) invokes explicit function MRtrixCmdError.__str__(), which just concatenates the stdout and stderr contents and does not perform any decoding.

  • When writing the exception contents to a text file in the scratch directory, the file is opened in 'w' mode. On Python2 this will invoke text decoding, as the file is not opened in binary mode. (String handling is maybe the most awkward part of supporting both Python2 and Python3)

  • Worth noting that we're strongly considering dropping Python2 support and hard-coding all MRtrix3 scripts to explicitly use Python3 (Drop python2 support? #2047).

So one test would be whether or not opening that file in binary mode ('wb') produces the appropriate result in both Python versions.

The other thing I'm looking at is the fact that if run with -info or -debug, the stderr contents returned in MRtrixCmdError are read one byte at a time and not decoded, whereas without these options there is in fact an explicit decode, and the errors='replace' means that your subsequent decoding error shouldn't occur. So it's possible that if you were to not use -info or -debug, then Python2 would in fact work fine...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants