Skip to content

Commit d40baf0

Browse files
committed
fix: address code review comments
1 parent 98bed63 commit d40baf0

File tree

5 files changed

+50
-14
lines changed

5 files changed

+50
-14
lines changed

docs/faq_tips_tricks.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,23 @@ A symptomatic output looks like: ::
126126

127127
If you would like to run *fMRIPrep* in parallel on multiple subjects please use
128128
`this method <https://neurostars.org/t/fmriprep-workaround-for-running-subjects-in-parallel/4449>`__.
129+
130+
131+
.. _upgrading:
132+
133+
A new version of *fMRIPrep* has been published, when should I upgrade?
134+
----------------------------------------------------------------------
135+
136+
We follow a philosophy of releasing very often, although the pace is slowing down
137+
with the maturation of the software.
138+
It is very likely that your version gets outdated over the extent of your study.
139+
If that is the case (an ongoing study), then we discourage changing versions.
140+
In other words, **the whole dataset should be processed with the same version (and
141+
same container build if they are being used) of *fMRIPrep*.**
142+
143+
On the other hand, if the project is about to start, then we strongly recommend
144+
using the latest version of the tool.
145+
146+
In any case, if you can find your release listed as *flagged* in `this file
147+
of our repo <https://github.com/poldracklab/fmriprep/blob/master/.versions.json>`__,
148+
then please update as soon as possible.

fmriprep/cli/run.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def get_parser():
4343
from packaging.version import Version
4444
from ..__about__ import __version__
4545
from ..workflows.bold.resampling import NONSTANDARD_REFERENCES
46-
from ._version import check_latest, is_flagged
46+
from .version import check_latest, is_flagged
4747

4848
verstr = 'fmriprep v{}'.format(__version__)
4949

@@ -281,10 +281,9 @@ def get_parser():
281281

282282
if latest is not None and currentv < latest:
283283
print("""\
284-
WARNING: The current version of fMRIPrep (%s) is outdated.
285-
Please consider upgrading to the latest version %s.
286-
Before upgrading, please consider that mixing fMRIPrep versions
287-
within a single study is strongly discouraged.""" % (
284+
You are using fMRIPrep-%s, and a newer version of fMRIPrep is available: %s.
285+
Please check out our documentation about how and when to upgrade:
286+
https://fmriprep.readthedocs.io/en/latest/faq.html#upgrading""" % (
288287
__version__, latest), file=sys.stderr)
289288

290289
_blist = is_flagged()

fmriprep/cli/tests/test_run.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Test CLI."""
22
from packaging.version import Version
33
import pytest
4-
from .. import _version
4+
from .. import version as _version
55
from ... import __about__
66
from ..run import get_parser
77

@@ -24,10 +24,9 @@ def _mock_check_latest(*args, **kwargs):
2424
captured = capsys.readouterr().err
2525

2626
msg = """\
27-
WARNING: The current version of fMRIPrep (%s) is outdated.
28-
Please consider upgrading to the latest version %s.
29-
Before upgrading, please consider that mixing fMRIPrep versions
30-
within a single study is strongly discouraged.""" % (current, latest)
27+
You are using fMRIPrep-%s, and a newer version of fMRIPrep is available: %s.
28+
Please check out our documentation about how and when to upgrade:
29+
https://fmriprep.readthedocs.io/en/latest/faq.html#upgrading""" % (current, latest)
3130

3231
assert (msg in captured) is expectation
3332

fmriprep/cli/tests/test_version.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from pathlib import Path
44
from packaging.version import Version
55
import pytest
6-
from .. import _version
7-
from .._version import check_latest, DATE_FMT, requests, is_flagged
6+
from .. import version as _version
7+
from ..version import check_latest, DATE_FMT, requests, is_flagged
88

99

1010
class MockResponse:
@@ -64,6 +64,24 @@ def mock_get(*args, **kwargs):
6464
assert isinstance(v, Version)
6565
assert v == Version('1.1.0')
6666

67+
# Mock timeouts
68+
def mock_get(*args, **kwargs):
69+
raise requests.exceptions.Timeout
70+
monkeypatch.setattr(requests, "get", mock_get)
71+
72+
cachefile.write_text('|'.join(('1.0.0', cachefile.read_text().split('|')[1])))
73+
v = check_latest()
74+
assert isinstance(v, Version)
75+
assert v == Version('1.0.0')
76+
77+
cachefile.write_text('2.0.0|20180121')
78+
v = check_latest()
79+
assert v is None
80+
81+
cachefile.unlink()
82+
v = check_latest()
83+
assert v is None
84+
6785

6886
@pytest.mark.parametrize(('result', 'code', 'json'), [
6987
(None, 404, None),

fmriprep/cli/_version.py renamed to fmriprep/cli/version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def check_latest():
3939
try:
4040
response = requests.get(url='https://pypi.org/pypi/fmriprep/json', timeout=1.0)
4141
except Exception:
42-
pass
42+
response = None
4343

4444
if response and response.status_code == 200:
4545
versions = [Version(rel) for rel in response.json()['releases'].keys()]
@@ -66,7 +66,7 @@ def is_flagged():
6666
response = requests.get(url="""\
6767
https://raw.githubusercontent.com/poldracklab/fmriprep/master/.versions.json""", timeout=1.0)
6868
except Exception:
69-
pass
69+
response = None
7070

7171
if response and response.status_code == 200:
7272
flagged = response.json().get('flagged', {}) or {}

0 commit comments

Comments
 (0)