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: archives: Fix zip (PY2/PY3) and unzip (PY3) #2702

merged 3 commits into from Jul 16, 2018


Copy link

@kyleam kyleam commented Jul 15, 2018

  • Make compress_files work with zip files so that with_tree can create zip files and we can add a regression test for gh-2695.

  • Fix a PY3-specific failure that occurs when decompress_file (and thus add_archive_content) is called on zip files.

Fixes #2695.

kyleam added 2 commits Jul 15, 2018
patool compresses tar files directly with tar via  We
do a hacky monkey patching of this method with our Runner, and we set
the working directory for the run via Runner.cwd.  However, this
failed to properly set the working directory when compressing zip
files because patool goes through zipfile.ZipFile rather than

Use chpwd instead of setting Runner.cwd to handle all cases.

With this fix, create_tree_archive (and so create_tree and with_tree)
can now generate zip files, allowing us to more easily test
add_archive_content on zip files.
Decompressing a zip under Python 3 fails with

  patoolib.util.PatoolError: error extracting b'/tmp/':
  'bytes' object has no attribute 'seek'

Note that this error is happening in zip-file specific
code (  Unlike tar files, zip files don't
get decompressed via a call to the monkey-patched runner (which, at
least in boring cases, handles a command list that is a mix of byte
and unicode strings).

Confusingly, issue gh-2580 and the fix (gh-2586, 7c8500a) show
add_archive_content calls on a zip file that don't trigger this error.
But trying on the same zip file, I see the above error.  My patool
version matches the one reported in gh-2586, so perhaps it depends on
the specific Python 3 version (3.6.4 there, 3.5.3 on my end).  Anyway,
the new test will indicate whether the fix here causes issues with
other Python 3 versions that we use on Travis.

The most minimal fix would be to add

    archive = assure_unicode(archive)

below `if not PY2`.  However, I don't understand why we shouldn't
unconditionally call assure_unicode.  Unfortunately, the message of
the commit that added the assure_bytes calls (586a3fd) is short on
details.  Let's unconditionally assure_unicode unless Travis tells us

Fixes #2695.
Copy link

@codecov codecov bot commented Jul 15, 2018

Codecov Report

Merging #2702 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2702      +/-   ##
+ Coverage   90.41%   90.41%   +<.01%     
  Files         245      245              
  Lines       30840    30846       +6     
+ Hits        27883    27889       +6     
  Misses       2957     2957
Impacted Files Coverage Δ
datalad/support/ 86.45% <100%> (+0.07%) ⬆️
datalad/tests/ 93.45% <100%> (+0.06%) ⬆️
...atalad/interface/tests/ 100% <100%> (ø) ⬆️
datalad/interface/ 94.26% <0%> (-0.41%) ⬇️
datalad/distribution/ 100% <0%> (ø) ⬆️
datalad/distribution/ 93.7% <0%> (ø) ⬆️

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 cf78c18...932788c. Read the comment docs.

Copy link

@yarikoptic yarikoptic commented Jul 15, 2018

Please ignore awaken Windows bot, but the others might be legit...

This reverts the decompress_file changes from 199f092 and applies
the minimal alternative fix discussed in that commit's message.  This
is in response to failures on the buildbots (all of the Travis runs
passed).  That seems to boil down to a failed git annex get call:

  CommandError: CommandError: command '['git', 'annex', 'get', '--',
  u' "\';a&b&c\u0394\u0419\u05e7\u0645\u0e57\u3042 `| ']' failed with
  exitcode 1

Fixes #2695.
Copy link
Contributor Author

@kyleam kyleam commented Jul 16, 2018

OK, aside from Windows bot, all green.

@yarikoptic yarikoptic merged commit 8540bb2 into datalad:master Jul 16, 2018
9 of 10 checks passed
9 of 10 checks passed
datalad-pr-virtualbox-dl-win7-64 DEV build done.
codecov/patch 100% of diff hit (target 90.41%)
codecov/project 90.41% (+<.01%) compared to cf78c18
continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed
datalad-pr-dl-osx-64 DEV build done.
datalad-pr-docker-dl-nd14_04 DEV build done.
datalad-pr-docker-dl-nd16_04 DEV build done.
datalad-pr-docker-dl-nd80 DEV build done.
datalad-pr-docker-dl-nd90 DEV build done.
@kyleam kyleam deleted the kyleam:bf-archive-zip branch Jul 16, 2018
@yarikoptic yarikoptic added this to the Release 0.10.3 milestone Sep 12, 2018
yarikoptic added a commit that referenced this pull request Sep 13, 2018
0.10.3 (Sep 13, 2018) -- Almost-perfect

This is largely a bugfix release which addressed many (but not yet all)
issues of working with git-annex direct and version 6 modes, and operation
on Windows in general.  Among enhancements you will see the
support of public S3 buckets (even with periods in their names),
ability to configure new providers interactively, and improved `egrep`
search backend.

Although we do not require with this release, it is recommended to make
sure that you are using a recent `git-annex` since it also had a variety
of fixes and enhancements in the past months.


- Parsing of combined short options has been broken since DataLad
  v0.10.0. ([#2710])
- The `datalad save` instructions shown by `datalad run` for a command
  with a non-zero exit were incorrectly formatted. ([#2692])
- Decompression of zip files (e.g., through `datalad
  add-archive-content`) failed on Python 3.  ([#2702])
- Windows:
  - colored log output was not being processed by colorama.  ([#2707])
  - more codepaths now try multiple times when removing a file to deal
    with latency and locking issues on Windows.  ([#2795])
- Internal git fetch calls have been updated to work around a
  GitPython `BadName` issue.  ([#2712]), ([#2794])
- The progess bar for annex file transferring was unable to handle an
  empty file.  ([#2717])
- `datalad add-readme` halted when no aggregated metadata was found
  rather than displaying a warning.  ([#2731])
- `datalad rerun` failed if `--onto` was specified and the history
  contained no run commits.  ([#2761])
- Processing of a command's results failed on a result record with a
  missing value (e.g., absent field or subfield in metadata).  Now the
  missing value is rendered as "N/A".  ([#2725]).
- A couple of documentation links in the "Delineation from related
  solutions" were misformatted.  ([#2773])
- With the latest git-annex, several known V6 failures are no longer
  an issue.  ([#2777])
- In direct mode, commit changes would often commit annexed content as
  regular Git files.  A new approach fixes this and resolves a good
  number of known failures.  ([#2770])
- The reporting of command results failed if the current working
  directory was removed (e.g., after an unsuccessful `install`). ([#2788])
- When installing into an existing empty directory, `datalad install`
  removed the directory after a failed clone.  ([#2788])
- `datalad run` incorrectly handled inputs and outputs for paths with
  spaces and other characters that require shell escaping.  ([#2798])
- Globbing inputs and outputs for `datalad run` didn't work correctly
  if a subdataset wasn't installed.  ([#2796])
- Minor (in)compatibility with git 2.19 - (no) trailing period
  in an error message now. ([#2815])

Enhancements and new features

- Anonymous access is now supported for S3 and other downloaders.  ([#2708])
- A new interface is available to ease setting up new providers.  ([#2708])
- Metadata: changes to egrep mode search  ([#2735])
  - Queries in egrep mode are now case-sensitive when the query
    contains any uppercase letters and are case-insensitive otherwise.
    The new mode egrepcs can be used to perform a case-sensitive query
    with all lower-case letters.
  - Search can now be limited to a specific key.
  - Multiple queries (list of expressions) are evaluated using AND to
    determine whether something is a hit.
  - A single multi-field query (e.g., `pa*:findme`) is a hit, when any
    matching field matches the query.
  - All matching key/value combinations across all (multi-field)
    queries are reported in the query_matched result field.
  - egrep mode now shows all hits rather than limiting the results to
    the top 20 hits.
- The documentation on how to format commands for `datalad run` has
  been improved.  ([#2703])
- The method for determining the current working directory on Windows
  has been improved.  ([#2707])
- `datalad --version` now simply shows the version without the
  license.  ([#2733])
- `datalad export-archive` learned to export under an existing
  directory via its `--filename` option.  ([#2723])
- `datalad export-to-figshare` now generates the zip archive in the
  root of the dataset unless `--filename` is specified.  ([#2723])
- After importing `datalad.api`, `help(datalad.api)` (or
  `datalad.api?` in IPython) now shows a summary of the available
  DataLad commands.  ([#2728])
- Support for using `datalad` from IPython has been improved.  ([#2722])
- `datalad wtf` now returns structured data and reports the version of
  each extension.  ([#2741])
- The internal handling of gitattributes information has been
  improved.  A user-visible consequence is that `datalad create
  --force` no longer duplicates existing attributes.  ([#2744])
- The "annex" metadata extractor can now be used even when no content
  is present.  ([#2724])
- The `add_url_to_file` method (called by commands like `datalad
  download-url` and `datalad add-archive-content`) learned how to
  display a progress bar.  ([#2738])

* tag '0.10.3': (214 commits)
  Changelog entry for 2.19 git compat fix
  DOC: slight tune ups to the ChangeLog
  ENH: link issue/pull #s in CHANGELOG, use tools/link_issues_CHANGELOG
  BF: remove trailing period while matching a mesage from git
  DOC: try_multiple_dec: Add description of `duration` parameter
  CLN: annexrepo: Fix grammar in a recently added comment
  TST: auto: Reformat comment from 900ee08
  DOC: _rmtree: Drop a word from summary line
  DOC: Info on IDs (fixes gh-2801)
  BF: diff -- when reraising - just raise, do not raise that instance of exception from new location
  BF(TST): precommit before removing submodule so there is no batched processes
  ENH+BF(TST): close established ssh sockets upon test finish
  BF(TST): One more "clost all log handlers in the test" Start adding entries for v0.10.3
  BF(TST): close cookies db in the teardown since atexit is later, so cannot assure no open files
  BF(TST): explicitly close created log handlers
  ENH(TST): @known_failure_windows to replace plain @skip_if_on_windows where there is hope
  BF(TST): do not swallow output while testing AutomagicIO to not cause some open files issue
  ENH(TST): Skip a test when cannot remove curent directory
  BF(TST): explicitly precommit a repo used under swallow_outputs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants