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

Ensure that BatchedCommandError is raised if the subprocesses of BatchedCommand fails or raises a CommandError #7068

Conversation

christian-monch
Copy link
Contributor

@christian-monch christian-monch commented Oct 6, 2022

Fixes #6834

This PR ensures that BatchedCommand raises a BatchedCommandError if the subprocesses of BatchedCommand exits with a non-zero value or raises a CommandError.

Changelog

🐛 Bug Fixes

💫 Enhancements and new features

  • Ensure the errors from sub-processes of BatchedCommand are signaled to the caller via BatchedCommandError-exception

This commit modifies the behavior of `BatchedCommand`
to raise an exception of the underlying command exits
with a non-zero return code. Previously any exceptions
were caught within `BatchedCommand` and logged.
This commit introduces code that will catch all CommandErrors
from subprocesses and raise an appropriate BatchedCommandError
that contains in addition to all the CommandError fields also
the last successfully executed request.
@christian-monch christian-monch added the semver-internal Changes only affect the internal API label Oct 6, 2022
This commit adds code to handle the situation
where git-annex in batch-mode does not signal
an error, here: an unknown remote, by returning
a JSON object with the error description, but
by exiting with an error code.

This has become necessary after `BatchedCommand`
was modified so that it reports errors of
subprocesses to its callers.

Remark:
The code added in this commit only fixes
`AnnexRepo.is_available()`. It maps all error
exits of git-annex to "non-availability", which
might be too unspecific. There also might be other
places in the code, where process-exits should
be caught and mapped onto method-results.
@codecov
Copy link

codecov bot commented Oct 7, 2022

Codecov Report

Base: 74.76% // Head: 75.96% // Increases project coverage by +1.19% 🎉

Coverage data is based on head (c541997) compared to base (748e5c6).
Patch coverage: 60.52% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##            maint    #7068      +/-   ##
==========================================
+ Coverage   74.76%   75.96%   +1.19%     
==========================================
  Files         354      355       +1     
  Lines       58945    59105     +160     
  Branches     6310     6318       +8     
==========================================
+ Hits        44072    44897     +825     
+ Misses      14858    14194     -664     
+ Partials       15       14       -1     
Impacted Files Coverage Δ
datalad/cmd.py 66.11% <47.72%> (-9.23%) ⬇️
datalad/support/annexrepo.py 76.85% <50.00%> (+1.34%) ⬆️
datalad/tests/test_cmd.py 69.93% <87.50%> (-22.78%) ⬇️
datalad/runner/coreprotocols.py 94.73% <0.00%> (-5.27%) ⬇️
datalad/support/keyring_.py 90.47% <0.00%> (-4.77%) ⬇️
datalad/runner/protocol.py 92.30% <0.00%> (-3.85%) ⬇️
datalad/support/collections.py 90.62% <0.00%> (-3.13%) ⬇️
datalad/tests/test_base.py 64.81% <0.00%> (-1.86%) ⬇️
... and 29 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

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.

From looking at the code, I have one comment, otherwise looks right to me.

datalad/cmd.py Show resolved Hide resolved
@yarikoptic yarikoptic added the CHANGELOG-missing When a PR's description does not contain a changelog item, yet. label Oct 8, 2022
@github-actions github-actions bot removed the CHANGELOG-missing When a PR's description does not contain a changelog item, yet. label Oct 8, 2022
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.

I agree with @bpoldrack recommendation on raising with preserving "origin". I also have some odd gut feeling that we might see some odd fails in parallel executions, but it might be only for good since we might really need to look into making those batched commands (more) thread-safe. But overall - I approve at this stage of our datalad development ;-) thanks @christian-monch

changelog.d/pr-7068.md Outdated Show resolved Hide resolved
datalad/cmd.py Show resolved Hide resolved
datalad/cmd.py Outdated Show resolved Hide resolved
datalad/support/annexrepo.py Outdated Show resolved Hide resolved
christian-monch and others added 5 commits October 9, 2022 10:50
Co-authored-by: Yaroslav Halchenko <debian@onerussian.com>
Co-authored-by: Yaroslav Halchenko <debian@onerussian.com>
This commit changes the name of `BatchedCommandError.request` to
`BatchedCommandError.last_processed_request`, and adds
documentation for it.
Raising BatchedCommandErorrs `from` the causing
CommandError in order to keep the original context.
Thx @bpoldrack
@yarikoptic
Copy link
Member

yarikoptic commented Oct 11, 2022

@christian-monch please add CHANGELOG-missing label so then workflow would produce a scriv changelog stub (based on title though, not the ones you added to description) -- you would then adjust it to your liking.

scratch that -- we already added a stub, but you might like to adjust it : https://github.com/datalad/datalad/pull/7068/files#diff-602c7a1f3f833aef726d071f72e97d752a35433b7792c2b76f038e5f57644b91R3

@yarikoptic-gitmate
Copy link
Collaborator

PR released in 0.17.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-internal Changes only affect the internal API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants