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

enh: simplify nipype etelemetry ping handling #3

Merged
merged 3 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions fmriprep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@
:py:class:`~bids.layout.BIDSLayout`, etc.)

"""
import os
from multiprocessing import set_start_method

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

try:
set_start_method('forkserver')
Expand All @@ -77,7 +82,6 @@
finally:
# Defer all custom import for after initializing the forkserver and
# ignoring the most annoying warnings
import os
import sys
import random

Expand Down Expand Up @@ -110,6 +114,16 @@

DEFAULT_MEMORY_MIN_GB = 0.01

# Ping NiPype eTelemetry once if env var was not set
# workers on the pool will have the env variable set from the master process
if not _disable_et:
# Just get so analytics track one hit
from contextlib import suppress
from requests import get as _get_url, ConnectionError, ReadTimeout
with suppress((ConnectionError, ReadTimeout)):
_get_url("https://rig.mit.edu/et/projects/nipy/nipype", timeout=0.05)

# Execution environment
_exec_env = os.name
_docker_ver = None
# special variable set in the container
Expand Down Expand Up @@ -244,8 +258,6 @@ class nipype(_Config):

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

if not cls.disable_telemetry:
# check for latest version
from nipype import check_latest_version
check_latest_version()
os.environ["NIPYPE_NO_ET"] = "1"

# Nipype config (logs and execution)
ncfg.update_config({
'execution': {
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ install_requires =
psutil >= 5.4
pybids >= 0.10.2
pyyaml
requests
Copy link
Owner

Choose a reason for hiding this comment

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

at this point, why not just add etelemetry directly and leverage the check there:
etelemetry.get_project("nipy/nipype")

Copy link
Author

Choose a reason for hiding this comment

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

I thought of using _etrequest directly, but we really don't want to do any kind of error handling. After going through the code it seemed more lightweight

Copy link
Owner

Choose a reason for hiding this comment

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

You bring up a good point... it would be useful to have an exception-free version in etelemetry.

sdcflows ~= 1.3.1
smriprep ~= 0.6.1
tedana >= 0.0.9a1, < 0.0.10
Expand Down