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

BF/RF: Centrlize handling running commands with long files list in _run_command_files_split #3138

Merged
merged 8 commits into from Feb 5, 2019

Conversation

@yarikoptic
Copy link
Member

@yarikoptic yarikoptic commented Feb 4, 2019

Before now we were doing that only in _run_annex_command_json but the problem is present also for other commands (e.g. add) which do not use --json mode of annex, or are pure git commands (e.g. git add). _run_command_files_split(func, files, ...) helper would invoke func multiple times on batches of files, and code is refactored to use it for annex and git commands invocations. I might have missed additional places where it should be used.

Also I am not sure if it would not interfer with custom index file, and most likely would cause multiple commits instead of a single one for commit calls. But imho it would already be better than just crashing

This pull request fixes #1883

  • ran on a real use case datalad add where it was failing before and it worked out nicely!
  • existing tests are green (besides known troublemakers)
  • I think we must adding some unittest operating on some large number of files (>10k) with relatively long names, even though it might take awhile to run it
yarikoptic added 4 commits Feb 4, 2019
…and_files_split

Before now we were doing that only in _run_annex_command_json but
the problem is present also for other commands (e.g. add) which
do not use --json mode of annex, or are pure git commands (e.g. git add).
_run_command_files_split(func, files, ...) helper would invoke func
multiple times on batches of files, and code is refactored to use it
for annex and git commands invocations.  I might have missed additional
places where it should be used.

Also I am not sure if it would not interfer with custom index file, and
most likely would cause multiple commits instead of a single one for
commit calls. But imho it would already be better than just crashing
@codecov
Copy link

@codecov codecov bot commented Feb 4, 2019

Codecov Report

Merging #3138 into master will decrease coverage by 1.29%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #3138     +/-   ##
=========================================
- Coverage   90.57%   89.27%   -1.3%     
=========================================
  Files         248      248             
  Lines       32682    32670     -12     
=========================================
- Hits        29601    29167    -434     
- Misses       3081     3503    +422
Impacted Files Coverage Δ
datalad/support/gitrepo.py 88.37% <100%> (-0.5%) ⬇️
datalad/support/annexrepo.py 81.38% <100%> (-7.03%) ⬇️
datalad/support/tests/test_annexrepo.py 96.4% <100%> (ø) ⬆️
datalad/support/_lru_cache2.py 0% <0%> (-63.47%) ⬇️
datalad/support/third/loris_token_generator.py 42.1% <0%> (-47.37%) ⬇️
datalad/downloaders/tests/test_http.py 59.9% <0%> (-28.97%) ⬇️
datalad/downloaders/http.py 71.03% <0%> (-11.51%) ⬇️
datalad/customremotes/base.py 73.13% <0%> (-11.01%) ⬇️
datalad/support/cookies.py 67.79% <0%> (-8.48%) ⬇️
datalad/customremotes/tests/__init__.py 91.66% <0%> (-8.34%) ⬇️
... and 25 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 a193539...98590ed. Read the comment docs.

@codecov
Copy link

@codecov codecov bot commented Feb 4, 2019

Codecov Report

Merging #3138 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3138      +/-   ##
==========================================
+ Coverage   90.57%   90.58%   +0.01%     
==========================================
  Files         248      248              
  Lines       32682    32714      +32     
==========================================
+ Hits        29601    29634      +33     
+ Misses       3081     3080       -1
Impacted Files Coverage Δ
datalad/support/gitrepo.py 89.14% <100%> (+0.27%) ⬆️
datalad/support/annexrepo.py 88.28% <100%> (-0.12%) ⬇️
datalad/support/tests/test_annexrepo.py 96.48% <100%> (+0.08%) ⬆️

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 a193539...0310c6b. Read the comment docs.

@mih
Copy link
Member

@mih mih commented Feb 4, 2019

This is needed! Thx.

@yarikoptic
Copy link
Member Author

@yarikoptic yarikoptic commented Feb 4, 2019

Ok, added a fast and slowish tests which trigger on master but there must be all green. If pass and do not bring travis down, should be merged asap unless there are comments/recommendations

@yarikoptic
Copy link
Member Author

@yarikoptic yarikoptic commented Feb 4, 2019

ok, no new failures, but on appveyor that one which fails ATM is not the last in the sequence of independent runs of tests -- so it was not ran, and might be that it would be failing this or some other test...
so either we merge as is, or resolve #3130, or move that failing one last in the chain (easiest) and see what happens, but it might bring up some other failures which are unrelated. Since we aren't too busy, I will proceed with the latter so we know where we stand.

currently fail (datalad#3130) and mask all other used to be good ones
kyleam
kyleam approved these changes Feb 4, 2019
datalad/support/tests/test_annexrepo.py Show resolved Hide resolved
@yarikoptic
Copy link
Member Author

@yarikoptic yarikoptic commented Feb 5, 2019

I am still intrigued how windows would behave but oh well -- we can deal with it later ;-) since otherwise everyone is onboard - merging

@yarikoptic yarikoptic merged commit f74de73 into datalad:master Feb 5, 2019
1 of 3 checks passed
@yarikoptic yarikoptic deleted the bf-files branch Feb 5, 2019
yarikoptic added a commit that referenced this issue Feb 8, 2019
 A variety of bugfixes and enhancements

 ### Major refactoring and deprecations

 - All extracted metadata is now placed under git-annex by default.
   Previously files smaller than 20 kb were stored in git. ([#3109])
 - TODO: get_runner #3104 and pending #3131

 ### Fixes

 - Improved handling of long commands:
   - The code that inspected `SC_ARG_MAX` didn't check that the
     reported value was a sensible, positive number. ([#3025])
   - More commands that invoke `git` and `git-annex` with file
     arguments learned to split up the command calls when it is likely
     that the command would fail due to exceeding the maximum supported
     length. ([#3138])
 - The `setup_yoda_dataset` procedure created a malformed
   .gitattributes line. ([#3057])
 - [download-url] unnecessarily tried to infer the dataset when
   `--no-save` was given. ([#3029])
 - [rerun] aborted too late and with a confusing message when a ref
   specified via `--onto` didn't exist. ([#3019])
 - [run]:
   - `run` didn't preserve the current directory prefix ("./") on
      inputs and outputs, which is problematic if the caller relies on
      this representation when formatting the command. ([#3037])
   - Fixed a number of unicode py2-compatibility issues. ([#3035]) ([#3046])
   - To proceed with a failed command, the user was confusingly
     instructed to use `save` instead of `add` even though `run` uses
     `add` underneath. ([#3080])
 - Fixed a case where the helper class for checking external modules
   incorrectly reported a module as unknown. ([#3051])
 - [add-archive-content] mishandled the archive path when the leading
   path contained a symlink. ([#3058])
 - Following denied access, the credential code failed to consider a
   scenario, leading to a type error rather than an appropriate error
   message. ([#3091])
 - Some tests failed when executed from a `git worktree` checkout of the
   source repository. ([#3129])
 - During metadata extraction, batched annex processes weren't properly
   terminated, leading to issues on Windows. ([#3137])
 - [add] incorrectly handled an "invalid repository" exception when
   trying to add a submodule. ([#3141])
 - Pass `GIT_SSH_VARIANT=ssh` to git processes to be able to specify
   alternative ports in SSH urls

 ### Enhancements and new features

 - [search] learned to suggest closely matching keys if there are no
   hits. ([#3089])
 - [create-sibling] gained a `--group` option so that the caller can
   specify the file system group for the repository. ([#3098])
 - Interface classes can now override the default renderer for
   summarizing results. ([#3061])
 - [run]:
   - `--input` and `--output` can now be shortened to `-i` and `-o`.
     ([#3066])
   - Placeholders such as "{inputs}" are now expanded in the command
     that is shown in the commit message subject. ([#3065])
   - `interface.run.run_command` gained an `extra_inputs` argument so
     that wrappers like [datalad-container] can specify additional inputs
     that aren't considered when formatting the command string. ([#3038])
   - "--" can now be used to separate options for `run` and those for
     the command in ambiguous cases. ([#3119])
 - The utilities `create_tree` and `ok_file_has_content` now support
   ".gz" files. ([#3049])
 - The Singularity container for 0.11.1 now uses [nd_freeze] to make
   its builds reproducible.
 - A [publications] page has been added to the documentation. ([#3099])
 - `GitRepo.set_gitattributes` now accepts a `mode` argument that
   controls whether the .gitattributes file is appended to (default) or
   overwritten. ([#3115])
 - `datalad --help` now avoids using `man` so that the list of
   subcommands is shown.  ([#3124])

* tag '0.11.2': (124 commits)
  Changelog entry for GIT_SSH_VARIANT change
  ENH: Declare our GIT_SSH_COMMAND as GIT_SSH_VARIANT=ssh
  BF: sshconnector: Don't use ssh's port flag as scp's
  RF: sshconnector: Simplify shlex quote import
  CHANGELOG(0.11.2): Fix some typos
  [DATALAD RUNCMD] CHANGELOG: Linkify 0.11.2 entries
  CHANGELOG: Do first pass for 0.11.2
  CHANGELOG: Add missing link target for download-url
  Start cooking the 0.11.2 release
  RF: appveyor - move test_install tests to be ran the last
  RF: text_type instead of str
  ENH(TST): provide my timing for the slow test
  BF(TST): adjust the test for the fact that AnnexRepo.add does not blow on nonexisting files
  ENH(TST): two tests which test quick or thorough for add failing with too long list of files
  BF: get stderr if present, otherwise just use str(e)
  BF: append out/err only if not empty/None
  Centrlize handling running commands with long files list in _run_command_files_split
  RF: remove minor duplication of -- handling, place all files handling closer to the call
  RF: move unrelated to try/except handling outside
  ENH+DOC: Report actual process handle, not just PID
  ...
@yarikoptic yarikoptic added this to the Release 0.11.2 milestone Feb 10, 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
Linked issues

Successfully merging this pull request may close these issues.

3 participants