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

FIX: Use copy function that does not preserve atime when creating fsaverage directories #703

Merged
merged 1 commit into from
Mar 31, 2022

Conversation

effigies
Copy link
Member

Closes #702.

@effigies effigies added this to the 1.3.7 milestone Mar 30, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #703 (26873d0) into maint/1.3.x (35b6435) will not change coverage.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##           maint/1.3.x     #703   +/-   ##
============================================
  Coverage        48.06%   48.06%           
============================================
  Files               43       43           
  Lines             5297     5297           
  Branches           776      776           
============================================
  Hits              2546     2546           
  Misses            2663     2663           
  Partials            88       88           
Flag Coverage Δ
reportlettests ∅ <ø> (∅)
unittests 48.06% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
niworkflows/interfaces/bids.py 96.15% <100.00%> (ø)

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 35b6435...26873d0. Read the comment docs.

@effigies
Copy link
Member Author

@mgxd Would appreciate a review to make sure I'm not crazy. I intend to do a release cascade so we can be prepared for the next round of fMRIPrep releases.

Copy link
Contributor

@mgxd mgxd left a comment

Choose a reason for hiding this comment

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

It doesn't seem to matter which copy function is used (at least from local testing on my Macbook), the directory mtime stays the same. In fact, the only timestamp that changes is ctime, and that happens regardless of the copy function.

If sweeps take that into account, we're probably fine - if not, we could just hack the mtime with something like

 os.utime(dest, (time.time(), time.time()))

@effigies
Copy link
Member Author

I can reproduce the issue on Linux. Want to try this script?

Script:
#!/bin/bash

set -eux

mkdir testdir
touch -d "Jan1" testdir/testfile
echo "atime"
ls -luR testdir
echo "mtime"
ls -lR testdir

python <<EOF
import shutil

shutil.copytree("testdir", "testdir.copy2", copy_function=shutil.copy2)
EOF

# Reset atime from copytree
touch -d "Jan1" testdir/testfile

python <<EOF
import shutil

shutil.copytree("testdir", "testdir.copy", copy_function=shutil.copy)
EOF

echo "atime"
ls -lu testdir.copy/testfile
ls -lu testdir.copy2/testfile
echo "mtime"
ls -l testdir.copy/testfile
ls -l testdir.copy2/testfile

Result:

+ mkdir testdir
+ touch -d Jan1 testdir/testfile
+ echo atime
atime
+ ls -luR testdir
testdir:
total 0
-rw-rw-r-- 1 chris chris 0 Jan  1 00:00 testfile
+ echo mtime
mtime
+ ls -lR testdir
testdir:
total 0
-rw-rw-r-- 1 chris chris 0 Jan  1 00:00 testfile
+ python
+ touch -d Jan1 testdir/testfile
+ python
+ echo atime
atime
+ ls -lu testdir.copy/testfile
-rw-rw-r-- 1 chris chris 0 Mar 30 21:16 testdir.copy/testfile
+ ls -lu testdir.copy2/testfile
-rw-rw-r-- 1 chris chris 0 Jan  1 00:00 testdir.copy2/testfile
+ echo mtime
mtime
+ ls -l testdir.copy/testfile
-rw-rw-r-- 1 chris chris 0 Mar 30 21:16 testdir.copy/testfile
+ ls -l testdir.copy2/testfile
-rw-rw-r-- 1 chris chris 0 Jan  1 00:00 testdir.copy2/testfile

@mgxd
Copy link
Contributor

mgxd commented Mar 31, 2022

I think we're looking at this in two different ways.

Your tests are comparing the files within testdir, which absolutely show how using shutil.copy over shutil.copy2 modifies the mtime.

I was looking at the top level directory's mtime after using shutil.copy / shutil.copy2. My test was copying an existing fsaverage* directory, and then checking the copied directories' mtime. I'm not sure if the sweeps also care about directories, otherwise this is fine to merge.

@effigies
Copy link
Member Author

effigies commented Mar 31, 2022

The relevant bit is actually the atime more than the mtime. What we think is happening is that the sweeps are seeing files that haven't been accessed in years/months and suddenly they're gone. Being in a more recently accessed or modified directory does not seem to protect them.

Hope this is more clear. Can chat tomorrow if we're still not quite connecting.

Copy link
Contributor

@mgxd mgxd left a comment

Choose a reason for hiding this comment

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

Ah, then this LGTM

@effigies effigies merged commit ceeec5a into nipreps:maint/1.3.x Mar 31, 2022
@effigies effigies deleted the fix/fs-no-copy-atime branch March 31, 2022 13:11
@effigies effigies changed the title FIX: Use copy function that does not preserve mtime when creating fsaverage directories FIX: Use copy function that does not preserve atime when creating fsaverage directories Mar 31, 2022
effigies added a commit to nipreps/fmriprep that referenced this pull request Jul 18, 2024
20.2.8 (July 18, 2024)

Bug-fix release in the 20.2.x LTS series.

We anticipate this being the final release in the 20.2.x LTS series.

* FIX: Select volumetric dseg.tsv from recent TemplateFlow releases (#3257)
* FIX: LTS package build (#3328)
* DOC: Read html_baseurl from RTD environment, if available (#3324)
* DOCKER: Pin conda environment more strictly (#2853)
* MNT: Require niworkflows ~1.3.6 (#2740)
* CI: Upgrade docker orb (#2865)

This release includes a number of fixes that have accumulated in niworkflows,
including the following fixes that affect fMRIPrep:

* FIX: Remove unused ANTs parameter that was removed in 2.4.1 (nipreps/sdcflows#431)
* FIX: Limit 3dQwarp to maximum 4 CPUs for stability reasons (nipreps/sdcflows#128)
* MAINT: Make call to scipy.stats.mode compatible with scipy 1.11.0 (nipreps/sdcflows#371)
* FIX: TSV2JSON should convert empty TSV files to empty JSON files (nipreps/niworkflows#747)
* FIX: Use copy function that does not preserve mtime when creating fsaverage
  directories (nipreps/niworkflows#703)
* FIX: Set pixdim[4] to match RepetitionTime (nipreps/niworkflows#679)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants