-
Notifications
You must be signed in to change notification settings - Fork 4
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
Unable to remake file if the command writes to stdout (external remote error) #82
Comments
@mslw Thanks for pointing that out. The reason for the bug is that 1.) Instruct the user not to write anything to stdout To me option 2. makes the most sense. WDYT? |
Oh, I see, the git-annex external speciale remote protocol docs says "Communication is via stdin and stdout. Therefore, the external special remote must avoid doing any prompting, or outputting anything like eg, progress to stdout. (Such stuff can be sent to stderr instead.)". Although in this case it is not the standard remote which writes to stdout, it is the user-provided program that the special remote triggers. Not sure if that distinction matters in practice. Now to your options: (1) seems extremely unattractive to me. In my mind, fMRIPrep is the ideal use case for remake, and fMRIPrep tends to log to both stdin and stderr, depending on the message (I suppose it's far from being the only program which behaves like that). By extension, code which imports workflows from fMRIPrep inherits that behaviour. So if stdout is off limits, it would be impossible to use fMRIPrep as-is. Perhaps I would be able to re-configure the loggers in my fMRIPrep-based code, or wrap the Python code in a Bash script which redirects the outputs (and use that with remake) but things become more involved this way. (2) seems ok. One thing we would loose is the insight into the progress indicated by the log messages gradually appearing. I'm also not sure where the file should be written - my instinct is some throwaway location, maybe configurable? (3) it feels wrong just to throw it away. That being said, in a remake scenario I probably expect the final result to be correct and do not care about the stdout logging... as long as things go well. To be honest, I am not sure how and at which level the data streams can be redirected. I have seen people do things like |
In terms of 4.) one possibility would be to redirect all output to stderr and prefix it with the source, e.g.
That would make all outputs available via stderr |
This PR fixes issue #82 By default it suppresses all output on `stdout` that is created when the commands in a template are executed. The output can be written to a file by specifying the `-s/--stdout` argument in `datalad make`.
@mslw PR #89 should fix the error. It will swallow Let me know what you think. Please feel free to reopen this issue, if the current |
I tried to use datalad-remake with a Python script which uses Nipype workflows imported from fMRIPrep. fMRIPrep tends to log extensively to standard output. This caused the remake special remote to crash ("external special remote protocol error, unexpectedly received (-- content of log message here --)") when getting the file.
It's better to demonstrate this with a simple example - a script with "print debugging".
Dataset setup:
File:
.datalad/make/methods/method
File:
write.py
Initial make (success):
Attempt to remake (external special remote protocol error):
As a side note, if in that script I write to standard error (
sys.stderr.write
) instead of standard output (print
), there is no protocol error and remake succeeds; however on initial make the standard error is not displayed in the terminal.The text was updated successfully, but these errors were encountered: