Skip to content

Commit d352a21

Browse files
authored
ENH: Add migas telemetry to nibabies (#226)
* ENH: Add migas telemetry to nibabies * FIX: Use conda installation of git-annex * ENH: Add migas envvar to enable tracking * CI: Disable usage reporting for CI
1 parent 20eeb8c commit d352a21

File tree

6 files changed

+43
-6
lines changed

6 files changed

+43
-6
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ jobs:
338338
nibabies-wrapper docker /tmp/data/${DATASET} /tmp/${DATASET}/derivatives/nibabies participant \
339339
-i nipreps/nibabies:latest \
340340
-e NIBABIES_DEV 1 --user $(id -u):$(id -g) \
341-
--network none \
341+
--network none --notrack \
342342
--config $PWD/nipype.cfg -w /tmp/${DATASET}/work \
343343
--fs-subjects-dir /tmp/data/${DATASET}/derivatives/infant-freesurfer \
344344
--skull-strip-template UNCInfant:cohort-1 \
@@ -364,7 +364,7 @@ jobs:
364364
nibabies-wrapper docker /tmp/data/${DATASET} /tmp/${DATASET}/derivatives/nibabies participant \
365365
-i nipreps/nibabies:latest \
366366
-e NIBABIES_DEV 1 --user $(id -u):$(id -g) \
367-
--network none \
367+
--network none --notrack \
368368
--config $PWD/nipype.cfg -w /tmp/${DATASET}/work \
369369
--fs-subjects-dir /tmp/data/${DATASET}/derivatives/infant-freesurfer \
370370
--skull-strip-template UNCInfant:cohort-1 \

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ RUN curl -sSL "http://neuro.debian.net/lists/$( lsb_release -c | cut -f2 ).us-ca
3737
(apt-key adv --refresh-keys --keyserver hkp://ha.pool.sks-keyservers.net 0xA5D32F012649A5A9 || true)
3838
RUN apt-get update && \
3939
apt-get install -y --no-install-recommends \
40-
connectome-workbench=1.5.0-1~nd20.04+1 \
41-
git-annex-standalone=8.20211123+git12-g02e3756bd-1~ndall+1 && \
40+
connectome-workbench=1.5.0-1~nd20.04+1 && \
4241
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
4342

4443
# Installing ANTs 2.3.4 (NeuroDocker build)

nibabies/cli/run.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def main():
1313
from pathlib import Path
1414

1515
from ..utils.bids import write_bidsignore, write_derivative_description
16+
from ..utils.misc import ping_migas
1617
from .parser import parse_args
1718
from .workflow import build_boilerplate, build_workflow
1819

@@ -22,6 +23,10 @@ def main():
2223

2324
parse_args()
2425

26+
# collect telemetry information - if `--notrack` is specified,
27+
# nothing is sent.
28+
ping_migas()
29+
2530
if "participant" in config.workflow.analysis_level:
2631
_pool = None
2732
if config.nipype.plugin == "MultiProc":
@@ -54,6 +59,7 @@ def main():
5459
nibabies_wf = retval['workflow']
5560

5661
if nibabies_wf is None:
62+
ping_migas(status='error')
5763
if config.execution.reports_only:
5864
sys.exit(int(retcode > 0))
5965
sys.exit(os.EX_SOFTWARE)
@@ -62,11 +68,13 @@ def main():
6268
nibabies_wf.write_graph(graph2use="colored", format="svg", simple_form=True)
6369

6470
if retcode != 0:
71+
ping_migas(status='error')
6572
sys.exit(retcode)
6673

6774
# generate boilerplate
6875
build_boilerplate(nibabies_wf)
6976
if config.execution.boilerplate_only:
77+
ping_migas(status='success')
7078
sys.exit(0)
7179

7280
gc.collect()
@@ -91,12 +99,13 @@ def main():
9199
nibabies_wf.run(**_plugin)
92100
except Exception as e:
93101
config.loggers.workflow.critical("nibabies failed: %s", e)
102+
ping_migas(status='error')
94103
raise
95104
else:
96105
config.loggers.workflow.log(25, "nibabies finished successfully!")
97-
98106
# Bother users with the boilerplate only iff the workflow went okay.
99107
boiler_file = config.execution.nibabies_dir / "logs" / "CITATION.md"
108+
ping_migas(status='success')
100109
if boiler_file.exists():
101110
if config.environment.exec_env in (
102111
"singularity",

nibabies/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ class execution(_Config):
399399
nibabies_dir = None
400400
"""Root of NiBabies BIDS Derivatives dataset. Depends on output_layout."""
401401
notrack = False
402-
"""Do not monitor *nibabies* using Sentry.io."""
402+
"""Do not monitor *nibabies* using *migas*."""
403403
output_dir = None
404404
"""Folder where derivatives will be stored."""
405405
me_output_echos = False

nibabies/utils/misc.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33
"""Miscellaneous utilities."""
44

5+
from .. import __version__
6+
57

68
def fix_multi_source_name(in_files):
79
"""
@@ -111,3 +113,29 @@ def combine_meepi_source(in_files):
111113
entities = [ent for ent in in_file.split("_") if not ent.startswith("echo-")]
112114
basename = "_".join(entities)
113115
return os.path.join(base, basename)
116+
117+
118+
def ping_migas(status='pending'):
119+
"""Communicate with the migas telemetry server."""
120+
import os
121+
122+
import migas
123+
124+
from ..config import execution
125+
126+
if execution.notrack:
127+
return
128+
129+
os.environ['ENABLE_MIGAS'] = 'yes'
130+
session_id = None
131+
if execution.run_uuid:
132+
session_id = execution.run_uuid.split('_')[1]
133+
134+
# TODO: check for bad versions
135+
res = migas.add_project(
136+
project="nipreps/nibabies",
137+
project_version=__version__,
138+
status=status,
139+
session_id=session_id, # uuid
140+
)
141+
return res

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ url = https://github.com/nipreps/nibabies
2424
python_requires = >= 3.7
2525
install_requires =
2626
attrs
27+
migas
2728
nibabel >= 3.0.1
2829
nipype >= 1.8.1
2930
nitime

0 commit comments

Comments
 (0)