From 8ea3c0535052656ee772347e65359430471571fe Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 3 Apr 2019 13:11:56 -0400 Subject: [PATCH 1/3] ENH: remove all prior existing citation files first - makes it friendly to the cases where all output is under git-annex. .write_text() just opens a file in "w" mode so it would fail on annex protected file. - if previous run did succeed generating e.g. .html file, if subsequent run fails, updated version of .html would not be generated and provided CITATION files could get out of sync. Removing all CITATION* files prior generation resolves both of the issues. --- fmriprep/cli/run.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/fmriprep/cli/run.py b/fmriprep/cli/run.py index 8cf0a64e8..3105d50a5 100755 --- a/fmriprep/cli/run.py +++ b/fmriprep/cli/run.py @@ -786,7 +786,18 @@ def build_workflow(opts, retval): boilerplate = retval['workflow'].visit_desc() if boilerplate: - (logs_path / 'CITATION.md').write_text(boilerplate) + # To please git-annex users and also to guarantee consistency + # among different renderings of the same file, first remove any + # existing one + citation_files = { + ext: str(logs_path / 'CITATION.' + ext) + for ext in ('bib', 'tex', 'md', 'html') + } + for citation_file in citation_files.values(): + if op.lexists(citation_file): + citation_file.unlink() + + Path(citation_files['md']).write_text(boilerplate) logger.log(25, 'Works derived from this fMRIPrep execution should ' 'include the following boilerplate:\n\n%s', boilerplate) @@ -795,8 +806,8 @@ def build_workflow(opts, retval): pkgrf('fmriprep', 'data/boilerplate.bib'), '--filter', 'pandoc-citeproc', '--metadata', 'pagetitle="fMRIPrep citation boilerplate"', - str(logs_path / 'CITATION.md'), - '-o', str(logs_path / 'CITATION.html')] + citation_files['md'], + '-o', citation_files['html']] try: check_call(cmd, timeout=10) except (FileNotFoundError, CalledProcessError, TimeoutExpired): @@ -806,8 +817,8 @@ def build_workflow(opts, retval): # Generate LaTex file resolving citations cmd = ['pandoc', '-s', '--bibliography', pkgrf('fmriprep', 'data/boilerplate.bib'), - '--natbib', str(logs_path / 'CITATION.md'), - '-o', str(logs_path / 'CITATION.tex')] + '--natbib', citation_files['md'], + '-o', citation_files['tex']] try: check_call(cmd, timeout=10) except (FileNotFoundError, CalledProcessError, TimeoutExpired): @@ -815,7 +826,7 @@ def build_workflow(opts, retval): ' '.join(cmd)) else: copyfile(pkgrf('fmriprep', 'data/boilerplate.bib'), - (logs_path / 'CITATION.bib')) + citation_files['bib']) return retval From 19c7e713aee6bfa0fadb537e549f364767c2503a Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Thu, 4 Apr 2019 11:17:29 -0400 Subject: [PATCH 2/3] RF: reverting back to use pathlib for consistency They are suggestsions from code review by Oscar Co-Authored-By: yarikoptic --- fmriprep/cli/run.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fmriprep/cli/run.py b/fmriprep/cli/run.py index 3105d50a5..fcfe9aeaf 100755 --- a/fmriprep/cli/run.py +++ b/fmriprep/cli/run.py @@ -790,14 +790,14 @@ def build_workflow(opts, retval): # among different renderings of the same file, first remove any # existing one citation_files = { - ext: str(logs_path / 'CITATION.' + ext) + ext: logs_path / ('CITATION.%s' % ext) for ext in ('bib', 'tex', 'md', 'html') } for citation_file in citation_files.values(): - if op.lexists(citation_file): + if citation_file.exists() or citation_file.is_symlink(): citation_file.unlink() - Path(citation_files['md']).write_text(boilerplate) + citation_files['md'].write_text(boilerplate) logger.log(25, 'Works derived from this fMRIPrep execution should ' 'include the following boilerplate:\n\n%s', boilerplate) @@ -806,8 +806,8 @@ def build_workflow(opts, retval): pkgrf('fmriprep', 'data/boilerplate.bib'), '--filter', 'pandoc-citeproc', '--metadata', 'pagetitle="fMRIPrep citation boilerplate"', - citation_files['md'], - '-o', citation_files['html']] + str(citation_files['md']), + '-o', str(citation_files['html'])] try: check_call(cmd, timeout=10) except (FileNotFoundError, CalledProcessError, TimeoutExpired): @@ -817,8 +817,8 @@ def build_workflow(opts, retval): # Generate LaTex file resolving citations cmd = ['pandoc', '-s', '--bibliography', pkgrf('fmriprep', 'data/boilerplate.bib'), - '--natbib', citation_files['md'], - '-o', citation_files['tex']] + '--natbib', str(citation_files['md']), + '-o', str(citation_files['tex'])] try: check_call(cmd, timeout=10) except (FileNotFoundError, CalledProcessError, TimeoutExpired): From 38cfd773470b27c002d6ad4ba89e8d905840aee9 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 4 Apr 2019 22:50:46 -0400 Subject: [PATCH 3/3] ENH: added myself to .zenodo.json The order is not really clear, so added myself all the way at the end before Russ P. --- .zenodo.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.zenodo.json b/.zenodo.json index 3ead90fd1..7cdc3096d 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -106,6 +106,11 @@ "affiliation": "University College London", "orcid": "0000-0002-9699-9052" }, + { + "name": "Halchenko, Yaroslav O.", + "affiliation": "Dartmouth College: Hanover, NH, United States", + "orcid": "0000-0003-3456-2493" + }, { "name": "Poldrack, Russell A.", "affiliation": "Department of Psychology, Stanford University",