Skip to content

[RF] Detachable run_command process #2787

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

Closed
wants to merge 56 commits into from

Conversation

oesteban
Copy link
Contributor

Summary

Introduction: the current implementation of run_command makes use of Streams to redirect output in a sort of inflexible way, and does not allow running the processes in the background.

Ref #2776.

List of changes proposed in this PR (pull-request)

  • modifies the behavior of run_command opening a new self-control thread, that is in charge of printing to the terminal if the terminal_output is set to 'stream'
  • output streams are redirected to files by default, trying to reduce the amount of data buffered in memory and also to ensure that there is a trace of nipype's execution.
  • a new argument background can be set to True, detaching from the process. This lends itself to important improvements on the MultiProc variants, as all these processes can be launched directly from the main thread and run in the background. I hope this will drastically reduce the memory fingerprint of workers (if we actually need to maintain a Pool, which is probably not the case anymore!).

Tests: I've added a couple of tests, but I'm happy to add more as I am aware that this may be too big of a change to the nipype interfaces.

Extra: removed a couple of deprecated objects that we promised to trash past nipype-1.1.0.

Acknowledgment

  • (Mandatory) I acknowledge that this contribution will be available under the Apache 2 license.

**Introduction**: the current implementation of ``run_command`` makes
use of ``Stream``s to redirect output in a sort of inflexible way, and
does not allow running the processes in the background.

**This PR**: modifies the behavior of ``run_command`` opening a new
self-control thread, that is in charge of printing to the terminal if
the ``terminal_output`` is set to ``'stream'``. Output streams are
redirected to files by default, trying to reduce the amount of data
buffered in memory and also to ensure that there is a trace of nipype's
execution. Additionally, a new argument ``background`` can be set to
``True``, detaching from the process. This lends itself to important
improvements on the ``MultiProc`` variants, as all these processes can
be launched directly from the main thread and run in the background.
I hope this will drastically reduce the memory fingerprint of workers
(if we actually need to maintain a ``Pool``, which is probably not the
case anymore!).

**Tests**: I've added a couple of tests, but I'm happy to add more as I
am aware that this may be too big of a change to the nipype interfaces.

**Extra**: removed a couple of deprecated objects that we promised to
trash past nipype-1.1.0.
@oesteban oesteban requested review from effigies and satra November 21, 2018 20:36
@codecov-io
Copy link

codecov-io commented Nov 21, 2018

Codecov Report

Merging #2787 into master will decrease coverage by 3%.
The diff coverage is 39.25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2787      +/-   ##
==========================================
- Coverage    66.8%   63.79%   -3.01%     
==========================================
  Files         341      339       -2     
  Lines       43295    43334      +39     
  Branches     5369     5357      -12     
==========================================
- Hits        28923    27646    -1277     
- Misses      13623    14616     +993     
- Partials      749     1072     +323
Flag Coverage Δ
#smoketests ?
#unittests 63.79% <39.25%> (-1.14%) ⬇️
Impacted Files Coverage Δ
nipype/pipeline/plugins/pbsgraph.py 94.11% <ø> (ø) ⬆️
nipype/pipeline/plugins/slurmgraph.py 13.04% <ø> (ø) ⬆️
nipype/pipeline/plugins/dagman.py 21.42% <ø> (ø) ⬆️
nipype/interfaces/slicer/generate_classes.py 9.5% <ø> (ø) ⬆️
nipype/pipeline/plugins/sgegraph.py 16.85% <ø> (ø) ⬆️
nipype/pipeline/plugins/slurm.py 14.6% <0%> (-0.69%) ⬇️
nipype/interfaces/afni/preprocess.py 82.26% <0%> (-0.14%) ⬇️
nipype/pipeline/plugins/pbs.py 18.18% <0%> (-1%) ⬇️
nipype/pipeline/plugins/sge.py 18.29% <0%> (-0.16%) ⬇️
nipype/interfaces/dynamic_slicer.py 17.14% <0%> (-0.34%) ⬇️
... and 87 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 11f8eb2...ea44179. Read the comment docs.

@effigies effigies added this to the 1.1.7 milestone Nov 26, 2018
@effigies effigies modified the milestones: 1.1.7, 1.1.8 Dec 14, 2018
@effigies
Copy link
Member

Hi, just a reminder that the 1.1.8 release is targeted for January 28. Please let us know if you'd like to try to finish this up for that release.

@oesteban
Copy link
Contributor Author

I think I will start over, with less broad, smaller PRs to take on this.

@oesteban oesteban closed this Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants