Skip to content

ENH: Add versioning metadata to crash files #2626

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

Merged
merged 3 commits into from
Jul 2, 2018

Conversation

anibalsolon
Copy link
Contributor

Fixes #2625.

Changes proposed in this pull request

  • Add a JSON header as metadata for the crash files, containing the original nipype version.
  • When opening a crash file with the cli utility, it can check for the nipype version and warn the user about problems that different versions of nipype may generate when using the utility.
  • It shows the version from the header.
  • It works seamlessly with old versions.

@codecov-io
Copy link

codecov-io commented Jun 28, 2018

Codecov Report

Merging #2626 into master will decrease coverage by 0.03%.
The diff coverage is 81.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2626      +/-   ##
==========================================
- Coverage    67.6%   67.56%   -0.04%     
==========================================
  Files         339      339              
  Lines       42820    43372     +552     
  Branches     5290     5339      +49     
==========================================
+ Hits        28948    29306     +358     
- Misses      13189    13337     +148     
- Partials      683      729      +46
Flag Coverage Δ
#smoketests 49.39% <21.21%> (-1.37%) ⬇️
#unittests 65.38% <81.81%> (+0.28%) ⬆️
Impacted Files Coverage Δ
nipype/pipeline/plugins/tools.py 84.93% <100%> (ø) ⬆️
nipype/utils/filemanip.py 78.63% <81.25%> (+0.26%) ⬆️
nipype/workflows/fmri/fsl/preprocess.py 72.67% <0%> (-13.39%) ⬇️
nipype/workflows/fmri/fsl/estimate.py 61.97% <0%> (-2.82%) ⬇️
nipype/interfaces/fsl/model.py 77.91% <0%> (-2.71%) ⬇️
nipype/interfaces/io.py 51.82% <0%> (-2.65%) ⬇️
nipype/interfaces/fsl/preprocess.py 80.33% <0%> (-2.27%) ⬇️
nipype/utils/config.py 65.21% <0%> (-1.64%) ⬇️
nipype/interfaces/fsl/base.py 86.66% <0%> (-1.12%) ⬇️
... and 4 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 704b97d...d3de9f4. Read the comment docs.

Copy link
Member

@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.

Thanks for the PR @anibalsolon - I've left a little comments, this looks handy! but perhaps @satra or @effigies can give this a quick review as well.

if versioning:
from nipype import __version__ as version
metadata = json.dumps({'version': version},
ensure_ascii=True,
Copy link
Member

Choose a reason for hiding this comment

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

why not use UTF-8 like we do throughout the package?

Copy link
Contributor Author

@anibalsolon anibalsolon Jun 29, 2018

Choose a reason for hiding this comment

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

My initial preference around ASCII over UTF-8, in this case, is about Python 2 retro-compatibility.
If the error contains a path, for example, that uses an "é", Python 2 might not get so happy about it. Since JSON can be fully encoded using ASCII, I thought that this config might avoid some headaches.

I've done some tests now, and using UTF-8 will not be a problem at all.

encoding='ascii')

pkl_file.write(metadata.encode('ascii'))
pkl_file.write('\n'.encode('ascii'))
Copy link
Member

Choose a reason for hiding this comment

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

utf-8?

@@ -643,11 +643,44 @@ def loadpkl(infile):
else:
pkl_file = open(infile, 'rb')

if versioning:
pkl_metadata = {}

Copy link
Member

Choose a reason for hiding this comment

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

many blank lines (personal preference, feel free to ignore)

@anibalsolon
Copy link
Contributor Author

Thank you for the review @mgxd !

@mgxd mgxd merged commit fa864aa into nipy:master Jul 2, 2018
@anibalsolon anibalsolon deleted the enh/crash_file_versioning branch July 2, 2018 15:03
@effigies effigies added this to the 1.1.0 milestone Aug 30, 2018
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.

4 participants