Skip to content

Commit d54925f

Browse files
authored
Merge pull request #3 from oesteban/fix/nipype-et-patch
enh: simplify nipype etelemetry ping handling
2 parents 66a82c1 + a8b5d03 commit d54925f

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

fmriprep/config.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,13 @@
6767
:py:class:`~bids.layout.BIDSLayout`, etc.)
6868
6969
"""
70+
import os
7071
from multiprocessing import set_start_method
7172

73+
# Disable NiPype etelemetry always
74+
_disable_et = bool(os.getenv("NO_ET") is not None or os.getenv("NIPYPE_NO_ET") is not None)
75+
os.environ["NIPYPE_NO_ET"] = "1"
76+
os.environ["NO_ET"] = "1"
7277

7378
try:
7479
set_start_method('forkserver')
@@ -77,7 +82,6 @@
7782
finally:
7883
# Defer all custom import for after initializing the forkserver and
7984
# ignoring the most annoying warnings
80-
import os
8185
import sys
8286
import random
8387

@@ -110,6 +114,16 @@
110114

111115
DEFAULT_MEMORY_MIN_GB = 0.01
112116

117+
# Ping NiPype eTelemetry once if env var was not set
118+
# workers on the pool will have the env variable set from the master process
119+
if not _disable_et:
120+
# Just get so analytics track one hit
121+
from contextlib import suppress
122+
from requests import get as _get_url, ConnectionError, ReadTimeout
123+
with suppress((ConnectionError, ReadTimeout)):
124+
_get_url("https://rig.mit.edu/et/projects/nipy/nipype", timeout=0.05)
125+
126+
# Execution environment
113127
_exec_env = os.name
114128
_docker_ver = None
115129
# special variable set in the container
@@ -244,8 +258,6 @@ class nipype(_Config):
244258

245259
crashfile_format = 'txt'
246260
"""The file format for crashfiles, either text or pickle."""
247-
disable_telemetry = bool(os.getenv("NIPYPE_NO_ET") is None)
248-
"""Disable interface telemetry"""
249261
get_linked_libs = False
250262
"""Run NiPype's tool to enlist linked libraries for every interface."""
251263
memory_gb = None
@@ -295,12 +307,6 @@ def init(cls):
295307
})
296308
ncfg.enable_resource_monitor()
297309

298-
if not cls.disable_telemetry:
299-
# check for latest version
300-
from nipype import check_latest_version
301-
check_latest_version()
302-
os.environ["NIPYPE_NO_ET"] = "1"
303-
304310
# Nipype config (logs and execution)
305311
ncfg.update_config({
306312
'execution': {

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ install_requires =
3333
psutil >= 5.4
3434
pybids >= 0.10.2
3535
pyyaml
36+
requests
3637
sdcflows ~= 1.3.1
3738
smriprep ~= 0.6.1
3839
tedana >= 0.0.9a1, < 0.0.10

0 commit comments

Comments
 (0)