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

MNT: Modernize export-archive #6745

Merged
merged 3 commits into from
Jun 8, 2022
Merged

Conversation

adswa
Copy link
Member

@adswa adswa commented Jun 4, 2022

This change contains maintenance work on export-archive. This includes
a complete switch from os.path to Pathlib, as well as abandoning old
almost never used and @normalize_path-polluted repo methods
get_indexed_files() and is_under_annex(), and replacing them with
get_content_{annex,}info(). This allows us to simplify the logic in
the for loop over all files further.

Coincidentally, because the switch from normlize_path functions
to get_content_{annex,}info() prevents faulty path handling when
export-archive is called from subdirectories inside of datasets,
this change fixes #6741

Changelog

🐛 Bug Fixes

@adswa adswa added the semver-patch Increment the patch version when merged label Jun 4, 2022
@adswa
Copy link
Member Author

adswa commented Jun 4, 2022

meh, shit, this seems to break something in the metadata code. edit: found the cause.

This change contains maintenance work on export-archive. This includes
a complete switch from os.path to Pathlib, as well as abandoning old
almost never used and @normalize_path-polluted repo methods
get_indexed_files() and is_under_annex(), and replacing them with
get_content_{annex,}info(). This allows us to simplify the logic in
the for loop over all files further.

Coincidentally, because the switch from normlize_path functions
to get_content_{annex,}info() prevents faulty path handling when
export-archive is called from subdirectories inside of datasets,
this change fixes datalad#6741
Copy link
Member

@mih mih left a comment

Choose a reason for hiding this comment

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

Awesome! LGTM!

From my POV this calls for an immediate move of GitRepo.get_indexed_files() into datalad/tests/utils.py only leaving a deprecated shim in GitRepo -- but no TODO for this PR.

Moreover, it seems that there is only a single user for file_has_content()left (in metadata.py) -- an important milestone for #4595.

Likewise time is running out for is_under_annex() only download_url(), add_archive_content() and that same metadata.py line are left TODO.

Wonderful contribution, thx much!

filename = path.join(filename, default_filename) # under given directory
if not filename.endswith(file_extension):
filename += file_extension
filename = Path(default_filename) # in current directory
Copy link
Member

Choose a reason for hiding this comment

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

FTR: Was wondering whether default_filename should become Path already on line 112, but this rest of the logic seems to encourage not making this change.

@codecov
Copy link

codecov bot commented Jun 4, 2022

Codecov Report

Merging #6745 (a289c96) into master (173dc6f) will increase coverage by 1.58%.
The diff coverage is 100.00%.

❗ Current head a289c96 differs from pull request most recent head ff6cef6. Consider uploading reports for the commit ff6cef6 to get more accurate results

@@            Coverage Diff             @@
##           master    #6745      +/-   ##
==========================================
+ Coverage   88.82%   90.41%   +1.58%     
==========================================
  Files         353      353              
  Lines       45761    45747      -14     
==========================================
+ Hits        40647    41360     +713     
+ Misses       5114     4387     -727     
Impacted Files Coverage Δ
datalad/support/gitrepo.py 90.74% <ø> (ø)
datalad/local/export_archive.py 100.00% <100.00%> (ø)
datalad/__init__.py 97.95% <0.00%> (+16.32%) ⬆️
datalad/tests/utils.py 57.11% <0.00%> (+35.48%) ⬆️
datalad/tests/test_tests_utils.py 92.39% <0.00%> (+92.39%) ⬆️

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 173dc6f...ff6cef6. Read the comment docs.

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.

looks good! one notable suggestion to keep behavior consistent and logic "centralized" on "what is basename" when working with archives.

datalad/local/export_archive.py Outdated Show resolved Hide resolved
datalad/local/export_archive.py Outdated Show resolved Hide resolved
Co-authored-by: Yaroslav Halchenko <debian@onerussian.com>
@adswa
Copy link
Member Author

adswa commented Jun 7, 2022

committed your suggestions, @yarikoptic

Co-authored-by: Yaroslav Halchenko <debian@onerussian.com>
@codeclimate
Copy link

codeclimate bot commented Jun 7, 2022

Code Climate has analyzed commit df977b6 and detected 0 issues on this pull request.

View more on Code Climate.

@yarikoptic
Copy link
Member

one appveyor run Failed in 1 hr suggesting that it timed out/exceeded time. hopefully it didn't stall ;)
Let's proceed. Thank you @adswa !

@yarikoptic yarikoptic merged commit 8e49548 into datalad:master Jun 8, 2022
@adswa adswa deleted the mnt-export-archive branch June 8, 2022 13:08
@adswa adswa mentioned this pull request Jul 1, 2022
21 tasks
@mih mih mentioned this pull request Jul 1, 2022
40 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch Increment the patch version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

export-archive fails on dataset with subdatasets, only if run from a subdirectory
3 participants