Skip to content

ENH: Run memoized check_version at REPL import, Node/Workflow/Interface init #30

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 1 commit into from
Sep 26, 2019
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
7 changes: 6 additions & 1 deletion nipype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
absolute_import)

import os
import functools
from distutils.version import LooseVersion

from .info import (LONG_DESCRIPTION as __doc__, URL as __url__, STATUS as
Expand Down Expand Up @@ -58,6 +59,7 @@ def get_info():
Rename, Function, Select, Merge)


@functools.lru_cache()
def check_version(raise_exception=False):
"""Check for the latest version of the library

Expand Down Expand Up @@ -95,5 +97,8 @@ def check_version(raise_exception=False):
logger.critical(message)


# Run telemetry on import for interactive sessions, such as IPython, Jupyter notebooks, Python REPL
if config.getboolean('execution', 'check_version'):
check_version()
import __main__
if not hasattr(__main__, '__file__'):
check_version()
4 changes: 4 additions & 0 deletions nipype/interfaces/base/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ class BaseInterface(Interface):

def __init__(self, from_file=None, resource_monitor=None,
ignore_exception=False, **inputs):
if config.getboolean('execution', 'check_version'):
from ... import check_version
check_version()

if not self.input_spec:
raise Exception(
'No input_spec in class: %s' % self.__class__.__name__)
Expand Down
3 changes: 3 additions & 0 deletions nipype/pipeline/engine/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def __init__(self, name=None, base_dir=None):

self.base_dir = base_dir
self.config = deepcopy(config._sections)
if config.getboolean('execution', 'check_version'):
from ... import check_version
check_version()

@property
def name(self):
Expand Down