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: Add migas telemetry in addition to sentry #2817

Merged
merged 5 commits into from
Dec 12, 2022
Merged

Conversation

mgxd
Copy link
Collaborator

@mgxd mgxd commented Jul 13, 2022

This adds migas telemetry in addition to sentry, to allow us to compare +/-'s

@mgxd mgxd marked this pull request as ready for review July 15, 2022 13:21
@mgxd mgxd requested review from oesteban and effigies and removed request for oesteban July 15, 2022 13:22
fmriprep/utils/sentry.py Outdated Show resolved Hide resolved
fmriprep/utils/sentry.py Outdated Show resolved Hide resolved
Copy link
Member

@oesteban oesteban left a comment

Choose a reason for hiding this comment

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

Added some suggestions, not particularly strong on them -- but thanks for considering.

@@ -794,7 +794,7 @@ jobs:
--fs-no-reconall --use-syn-sdc --ignore slicetiming \
--dummy-scans 1 --sloppy --write-graph \
--output-spaces MNI152NLin2009cAsym \
--mem-mb 14336 --nthreads 4 -vv
--mem-mb 14336 --nthreads 4 -vv --notrack
Copy link
Member

Choose a reason for hiding this comment

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

How much effort would it be to split debug/production pings for migas? It seems useful that we cross-compare with sentry on these debug heartbeats.

@@ -43,6 +44,7 @@ def main():
from ..utils.sentry import sentry_setup

sentry_setup()
ping_migas()
Copy link
Member

Choose a reason for hiding this comment

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

Is in this first ping when migas will check the user and figure out whether it is cached?

If not, I would favor to replicate sentry's design and have a migas_setup() call here.

I would imagine one day we will feed arguments here to help apps customize the settings:

migas_setup(userid="<some identifier generated by the app>", appid="override/fmriprep")

@@ -71,13 +73,15 @@ def main():
config.load(config_file)

if config.execution.reports_only:
ping_migas(status="success" if retcode == 0 else "error")
Copy link
Member

Choose a reason for hiding this comment

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

May we abide by OS' standards and just:

ping_migas(status=retcode)

Then let migas do the mapping.

sys.exit(int(retcode > 0))

if fmriprep_wf and config.execution.write_graph:
fmriprep_wf.write_graph(graph2use="colored", format="svg", simple_form=True)

retcode = retcode or (fmriprep_wf is None) * EX_SOFTWARE
if retcode != 0:
ping_migas(status="error")
Copy link
Member

Choose a reason for hiding this comment

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

What about replacing all these ping_migas with status with an exit hook? - https://docs.python.org/3/library/atexit.html

Since the hook does not allow to access the exit code, we probably want to:

  1. Add a new status or exitcode config setting (perhaps under the execution section). Initialize it at -1.
  2. Define some codes: e.g., 1001 (I haven't really thought this through, this might not be a good code) is set right before building the workflow, then 1002 is set after it is built and before calling run() and finally 0 is set when it is complete and successful. An error in the pipeline overrides the exitcode too.
  3. The atexit() hook will not send a ping if the code is still -1, and otherwise, submit whatever code it has.

fmriprep/utils/sentry.py Outdated Show resolved Hide resolved
if config.execution.notrack:
return

os.environ['ENABLE_MIGAS'] = 'yes'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
os.environ['ENABLE_MIGAS'] = 'yes'


import migas

if config.execution.notrack:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if config.execution.notrack:
if (
config.execution.notrack
or os.getenv("MIGAS_DISABLE", "no").lower() in ("yes", "on", "1", "true")
):

"""Communicate with the migas telemetry server."""
import os

import migas
Copy link
Member

Choose a reason for hiding this comment

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

delay after the following if branch?

session_id = config.execution.run_uuid.split('_')[1]

# TODO: check for bad versions
res = migas.add_project(
Copy link
Member

Choose a reason for hiding this comment

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

this looks like what migas_setup() would look like inside.

@effigies effigies added this to the 22.x milestone Jul 21, 2022
@mgxd mgxd self-assigned this Aug 30, 2022
- Add MIGAS_OPTOUT to let the client filter out pings
- Add `--notrack` to let fmriprep filter out pings
- Allow final ds210 fmriprep run to ping server and be caught/classified as CI
@effigies effigies modified the milestones: 22.x, 22.1.0 Dec 12, 2022
@effigies effigies mentioned this pull request Dec 12, 2022
7 tasks
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
fmriprep/cli/run.py Outdated Show resolved Hide resolved
@effigies effigies merged commit c6a9671 into nipreps:master Dec 12, 2022
@mgxd mgxd deleted the enh/migas branch December 12, 2022 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
Development

Successfully merging this pull request may close these issues.

3 participants