Skip to content

Commit 5fc78dd

Browse files
authored
Merge pull request #234 from nipype/ref-etelemetry
ref: update etelemetry to use simplified call
2 parents be16132 + 34ecab8 commit 5fc78dd

File tree

11 files changed

+59
-110
lines changed

11 files changed

+59
-110
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
command: pip install --no-cache-dir -r docs/requirements.txt
5050
- run:
5151
name: Build only this commit
52-
command: make -C docs SPHINXOPTS="-W" BUILDDIR="_build/no_version_html" html
52+
command: make -C docs SPHINXOPTS="-W" BUILDDIR="_build/no_version_html" SPHINX_APIDOC_OPTIONS="members,undoc-members,show-inheritance,noindex" html
5353
- store_artifacts:
5454
path: ./docs/_build/no_version_html
5555
- run:

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ Like this:
2424
```
2525
<code>
2626
```
27-
-->
27+
-->

.github/ISSUE_TEMPLATE/question.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ Include the following:
1212
------------------------
1313
What are you trying to accomplish?
1414
What have you tried?
15-
-->
15+
-->

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
- [ ] All tests passing
1313
- [ ] I have added tests to cover my changes
1414
- [ ] I have updated documentation (if necessary)
15-
- [ ] My code follows the code style of this project
16-
(we are using `black`: you can `pip install pre-commit`,
17-
run `pre-commit install` in the `pydra` directory
15+
- [ ] My code follows the code style of this project
16+
(we are using `black`: you can `pip install pre-commit`,
17+
run `pre-commit install` in the `pydra` directory
1818
and `black` will be run automatically with each commit)
1919

2020
## Acknowledgment
21-
- [ ] I acknowledge that this contribution will be available under the Apache 2 license.
21+
- [ ] I acknowledge that this contribution will be available under the Apache 2 license.

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
1111
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
14-

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
include versioneer.py
22
include pydra/_version.py
3-
include pydra/schema/context.jsonld
3+
include pydra/schema/context.jsonld

docs/conf.py

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@
1313
import sys
1414
from pathlib import Path
1515
from packaging.version import Version
16+
1617
sys.path.insert(0, str(Path(__file__).parent.parent.absolute()))
17-
sys.path.insert(1, str(Path(__file__).parent / 'sphinxext'))
18+
sys.path.insert(1, str(Path(__file__).parent / "sphinxext"))
1819
from pydra import __version__
1920
from github_link import make_linkcode_resolve
2021

2122

2223
# -- Project information -----------------------------------------------------
2324

24-
project = 'Pydra: A simple dataflow engine with scalable semantics'
25-
copyright = '2019 - 2020, The Nipype Developers team'
26-
author = 'The Nipype Developers team'
25+
project = "Pydra: A simple dataflow engine with scalable semantics"
26+
copyright = "2019 - 2020, The Nipype Developers team"
27+
author = "The Nipype Developers team"
2728

2829
# The full version, including alpha/beta/rc tags
2930
release = __version__
@@ -36,75 +37,66 @@
3637
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3738
# ones.
3839
extensions = [
39-
'sphinx.ext.autodoc',
40-
'sphinx.ext.doctest',
41-
'sphinx.ext.intersphinx',
42-
'sphinx.ext.coverage',
43-
'sphinx.ext.mathjax',
44-
'sphinx.ext.ifconfig',
45-
'sphinx.ext.linkcode',
46-
'sphinx.ext.githubpages',
47-
'sphinxcontrib.apidoc',
48-
'sphinxcontrib.napoleon'
40+
"sphinx.ext.autodoc",
41+
"sphinx.ext.doctest",
42+
"sphinx.ext.intersphinx",
43+
"sphinx.ext.coverage",
44+
"sphinx.ext.mathjax",
45+
"sphinx.ext.ifconfig",
46+
"sphinx.ext.linkcode",
47+
"sphinx.ext.githubpages",
48+
"sphinxcontrib.apidoc",
49+
"sphinxcontrib.napoleon",
4950
]
5051

5152
# Add any paths that contain templates here, relative to this directory.
52-
templates_path = ['_templates']
53+
templates_path = ["_templates"]
5354

5455
# List of patterns, relative to source directory, that match files and
5556
# directories to ignore when looking for source files.
5657
# This pattern also affects html_static_path and html_extra_path.
57-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'api/pydra.rst']
58+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "api/pydra.rst"]
5859

5960

6061
# -- Options for HTML output -------------------------------------------------
6162

6263
# The theme to use for HTML and HTML Help pages. See the documentation for
6364
# a list of builtin themes.
6465
#
65-
html_theme = 'sphinx_rtd_theme'
66+
html_theme = "sphinx_rtd_theme"
6667

6768
# Add any paths that contain custom static files (such as style sheets) here,
6869
# relative to this directory. They are copied after the builtin static files,
6970
# so a file named "default.css" will overwrite the builtin "default.css".
70-
html_static_path = ['_static']
71+
html_static_path = ["_static"]
7172

7273
# -- Options for extensions ---------------------------------------------------
7374

7475
# Autodoc
75-
autodoc_mock_imports = [
76-
'cloudpickle',
77-
'matplotlib',
78-
'numpy',
79-
'psutil',
80-
]
81-
apidoc_module_dir = '../pydra'
82-
apidoc_output_dir = 'api'
83-
apidoc_excluded_paths = ['conftest.py', '*/tests/*', 'tests/*', 'data/*']
76+
autodoc_mock_imports = ["cloudpickle", "matplotlib", "numpy", "psutil"]
77+
apidoc_module_dir = "../pydra"
78+
apidoc_output_dir = "api"
79+
apidoc_excluded_paths = ["conftest.py", "*/tests/*", "tests/*", "data/*"]
8480
apidoc_separate_modules = True
85-
apidoc_extra_args = ['--module-first', '-d 1', '-T']
81+
apidoc_extra_args = ["--module-first", "-d 1", "-T"]
8682

8783
# Napoleon
8884
# Accept custom section names to be parsed for numpy-style docstrings
8985
# of parameters.
9086
# Requires pinning sphinxcontrib-napoleon to a specific commit while
9187
# https://github.com/sphinx-contrib/napoleon/pull/10 is merged.
9288
napoleon_use_param = False
93-
napoleon_custom_sections = [
94-
('Inputs', 'Parameters'),
95-
('Outputs', 'Parameters'),
96-
]
89+
napoleon_custom_sections = [("Inputs", "Parameters"), ("Outputs", "Parameters")]
9790

9891
# Intersphinx
99-
intersphinx_mapping = {
100-
'https://docs.python.org/': None,
101-
}
92+
intersphinx_mapping = {"https://docs.python.org/": None}
10293

10394
# Linkcode
10495
# The following is used by sphinx.ext.linkcode to provide links to github
10596
linkcode_resolve = make_linkcode_resolve(
106-
'pydra', 'https://github.com/nipype/pydra/blob/{revision}/'
107-
'{package}/{path}#L{lineno}')
97+
"pydra",
98+
"https://github.com/nipype/pydra/blob/{revision}/" "{package}/{path}#L{lineno}",
99+
)
108100

109101
# Sphinx-versioning
110102
scv_show_banner = True

docs/sphinxext/github_link.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
import sys
1010
from functools import partial
1111

12-
REVISION_CMD = 'git rev-parse --short HEAD'
12+
REVISION_CMD = "git rev-parse --short HEAD"
1313

1414

1515
def _get_git_revision():
1616
try:
1717
revision = subprocess.check_output(REVISION_CMD.split()).strip()
1818
except (subprocess.CalledProcessError, OSError):
19-
print('Failed to execute git to get revision')
19+
print("Failed to execute git to get revision")
2020
return None
21-
return revision.decode('utf-8')
21+
return revision.decode("utf-8")
2222

2323

2424
def _linkcode_resolve(domain, info, package, url_fmt, revision):
@@ -38,18 +38,18 @@ def _linkcode_resolve(domain, info, package, url_fmt, revision):
3838

3939
if revision is None:
4040
return
41-
if domain not in ('py', 'pyx'):
41+
if domain not in ("py", "pyx"):
4242
return
43-
if not info.get('module') or not info.get('fullname'):
43+
if not info.get("module") or not info.get("fullname"):
4444
return
4545

46-
class_name = info['fullname'].split('.')[0]
46+
class_name = info["fullname"].split(".")[0]
4747
if type(class_name) != str:
4848
# Python 2 only
49-
class_name = class_name.encode('utf-8')
50-
module = __import__(info['module'], fromlist=[class_name])
49+
class_name = class_name.encode("utf-8")
50+
module = __import__(info["module"], fromlist=[class_name])
5151
try:
52-
obj = attrgetter(info['fullname'])(module)
52+
obj = attrgetter(info["fullname"])(module)
5353
except AttributeError:
5454
return
5555

@@ -65,14 +65,12 @@ def _linkcode_resolve(domain, info, package, url_fmt, revision):
6565
if not fn:
6666
return
6767

68-
fn = os.path.relpath(fn,
69-
start=os.path.dirname(__import__(package).__file__))
68+
fn = os.path.relpath(fn, start=os.path.dirname(__import__(package).__file__))
7069
try:
7170
lineno = inspect.getsourcelines(obj)[1]
7271
except Exception:
73-
lineno = ''
74-
return url_fmt.format(revision=revision, package=package,
75-
path=fn, lineno=lineno)
72+
lineno = ""
73+
return url_fmt.format(revision=revision, package=package, path=fn, lineno=lineno)
7674

7775

7876
def make_linkcode_resolve(package, url_fmt):
@@ -87,5 +85,6 @@ def make_linkcode_resolve(package, url_fmt):
8785
'{path}#L{lineno}')
8886
"""
8987
revision = _get_git_revision()
90-
return partial(_linkcode_resolve, revision=revision, package=package,
91-
url_fmt=url_fmt)
88+
return partial(
89+
_linkcode_resolve, revision=revision, package=package, url_fmt=url_fmt
90+
)

min-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
attrs
33
cloudpickle == 0.8.0
44
filelock == 3.0.0
5-
etelemetry
5+
etelemetry == 0.2.0

pydra/__init__.py

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
first-class operations. It forms the core of the Nipype 2.0 ecosystem.
66
77
"""
8+
import logging
9+
10+
logger = logging.getLogger("pydra")
811
from ._version import get_versions
912

1013
__version__ = get_versions()["version"]
@@ -14,54 +17,10 @@
1417
from . import mark
1518

1619

17-
def check_latest_version(raise_exception=False):
18-
"""
19-
Check for the latest version of the library.
20-
21-
Parameters
22-
----------
23-
raise_exception: :obj:`bool`
24-
Raise a RuntimeError if a bad version is being used
25-
26-
"""
20+
def check_latest_version():
2721
import etelemetry
28-
import logging
29-
from pkg_resources import parse_version
30-
31-
logger = logging.getLogger("pydra")
32-
33-
INIT_MSG = "Running {packname} version {version} (latest: {latest})".format
3422

35-
latest = {"version": "Unknown", "bad_versions": []}
36-
result = None
37-
try:
38-
result = etelemetry.get_project("nipype/pydra")
39-
except Exception as e:
40-
logger.warning("Could not check for version updates: \n%s", e)
41-
finally:
42-
if result:
43-
latest.update(**result)
44-
if parse_version(__version__) != parse_version(latest["version"]):
45-
logger.info(
46-
INIT_MSG(
47-
packname="pydra", version=__version__, latest=latest["version"]
48-
)
49-
)
50-
if latest["bad_versions"] and any(
51-
[
52-
parse_version(__version__) == parse_version(ver)
53-
for ver in latest["bad_versions"]
54-
]
55-
):
56-
message = (
57-
"You are using a version of Pydra with a critical "
58-
"bug. Please use a different version."
59-
)
60-
if raise_exception:
61-
raise RuntimeError(message)
62-
else:
63-
logger.critical(message)
64-
return latest
23+
return etelemetry.check_available_version("nipype/pydra", __version__, lgr=logger)
6524

6625

6726
# Run telemetry on import for interactive sessions, such as IPython, Jupyter notebooks, Python REPL

0 commit comments

Comments
 (0)