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

Runner -- shot of mercy #4996

Merged
merged 11 commits into from Oct 13, 2020
Merged

Runner -- shot of mercy #4996

merged 11 commits into from Oct 13, 2020

Conversation

mih
Copy link
Member

@mih mih commented Oct 8, 2020

All Runner code is now hanging on a thin thread. The remaining connections are:

  • GitRepo._run_git_custom_command is still on life support but already brain dead
  • run still uses Runner -> RF: Stop using old-Runner in run #5002
  • create_sibling has a fancy Runner adaptor class that adds a few functions that partially duplicate functionality in SSHConnection and want to become command abstractions (although that effort NF: Command abstractions #4068 died a lonely death, @bpoldrack )

Significant changes:

  • WitlessRunner now supports shell-based execution df4f782

Copy link
Member

@yarikoptic yarikoptic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only cursory review :

  • requested sh -> /bin/sh
  • FTR: ATM no negative (or positive) impact on benchmarks, so -- good

datalad/core/local/run.py Outdated Show resolved Hide resolved
datalad/core/local/tests/test_diff.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 9, 2020

Codecov Report

Merging #4996 into master will decrease coverage by 0.39%.
The diff coverage is 90.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4996      +/-   ##
==========================================
- Coverage   90.15%   89.75%   -0.40%     
==========================================
  Files         292      292              
  Lines       41002    40993       -9     
==========================================
- Hits        36964    36795     -169     
- Misses       4038     4198     +160     
Impacted Files Coverage Δ
datalad/distributed/ora_remote.py 30.95% <0.00%> (ø)
datalad/support/tests/test_annexrepo.py 96.80% <60.00%> (-0.01%) ⬇️
datalad/support/sshconnector.py 78.73% <70.00%> (-7.12%) ⬇️
datalad/cmd.py 92.68% <100.00%> (-1.07%) ⬇️
datalad/core/distributed/clone.py 88.72% <100.00%> (-0.04%) ⬇️
datalad/core/distributed/tests/test_clone.py 94.20% <100.00%> (-0.01%) ⬇️
datalad/core/local/tests/test_diff.py 97.23% <100.00%> (ø)
datalad/distributed/tests/test_ria_basics.py 98.30% <100.00%> (ø)
datalad/distribution/create_sibling.py 86.11% <100.00%> (+0.52%) ⬆️
datalad/distribution/tests/test_publish.py 100.00% <100.00%> (ø)
... and 34 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 d9f3c17...ceaa127. Read the comment docs.

@mih
Copy link
Member Author

mih commented Oct 9, 2020

Ok, so this works in principle. Playing with the outcome, I think we could delete 2k lines of, now unused, code. However, the Runners are still not dead. The culprit after this PR is now AnnexRepo._run_annex_command() which has a range of complications and compatibility "hacks" hanging off of it.

Copy link
Contributor

@kyleam kyleam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this. It looks like quite the slog. Looking through (at f7af7ec), I didn't spot any problematic conversions, and -core's tests look happy.

I scratched my head at the -container failure (and associated PR) for a bit. If I understand it correctly, the reason that swallow_outputs works for Runner and not WitlessRunner is that Runner explicitly sets the stdout argument of Popen to sys.stdout, which allows the swallow_outputs override to be effective.

Copy link
Member

@bpoldrack bpoldrack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - nothing that smells like a trap to me ;-)

@yarikoptic
Copy link
Member

Thanks @kyleam for the analysis - I think that is indeed what is happening, and probably is a "feature". So datalad/datalad-container#131 should be finalized, merged, and new datalad-container released (we could merge this before but then we would end up closing our eyes on the -container failures in master possibly missing new regressions)

log_stdout=True, log_stderr=True,
expect_fail=True, expect_stderr=True)
toppath = toppath.rstrip('\n\r')
out = GitWitlessRunner(cwd=path).run(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a note: coverage marked this as not-covered for me -- doesn't make sense since it would be the first line in try: and prior lines are covered.

@kyleam
Copy link
Contributor

kyleam commented Oct 9, 2020

I think that is indeed what is happening

Just to lend more concrete support to my explanation:

demo
import subprocess as sp
import sys

from datalad.cmd import Runner
from datalad.cmd import WitlessRunner
from datalad.utils import swallow_outputs

def old_runner():
    Runner().run(["pwd"], log_online=True,
                 log_stdout=False,
                 log_stderr=False)

def new_runner():
    WitlessRunner().run(["pwd"])

def popen():
    p = sp.Popen(["pwd"])
    p.communicate()

def popen_with_sys_stdout():
    p = sp.Popen(["pwd"], stdout=sys.stdout)
    p.communicate()

for fn in [old_runner, new_runner, popen, popen_with_sys_stdout]:
    print(f"===== {fn.__name__}")
    with swallow_outputs() as out:
        fn()
        x = out.out
    print("----- swallowed")
    print(x)
===== old_runner                  
----- swallowed
/tmp

===== new_runner
/tmp
----- swallowed

===== popen
/tmp
----- swallowed

===== popen_with_sys_stdout
----- swallowed
/tmp

@mih
Copy link
Member Author

mih commented Oct 10, 2020

Given that this PR isn't achieving its goal (total removal of Runner) anyways, I am OK with stripping the change to run. I removed it here, and placed it into #5002

datalad/tests/test_utils.py Outdated Show resolved Hide resolved
This now additionally tests that the NoCapture protocol enabled
interactive job execution. This is (or will be) critical for enabling
efforts like dataladgh-4121 (stalled).

Ping dataladgh-3236
@mih mih added the merge-if-ok OP considers this work done, and requests review/merge label Oct 13, 2020
@mih
Copy link
Member Author

mih commented Oct 13, 2020

Thx @kyleam !

@mih mih merged commit f60bc6a into datalad:master Oct 13, 2020
@mih mih deleted the rf-runnerdeath branch October 13, 2020 17:31
kyleam added a commit to mih/datalad-container that referenced this pull request Oct 13, 2020
datalad/datalad#5002 switches `datalad run` over to using
WitlessRunner rather than the old Runner.  swallow_outputs() works for
Runner because it explicitly sets the stdout argument of Popen() to
sys.stdout, which allows the swallow_outputs() override to be
effective.  This is not the case for WitlessRunner.

A few commits back already adjusted
datalad_container/tests/test_run.py for the above change in behavior.
Use the same approach in the remaining spots that swallow and check
the output of a containers_run() call.

datalad/datalad#4996 (review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-if-ok OP considers this work done, and requests review/merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants