<commit_before>description = "a module housing checks of skymap summary functionality"
author      = "<EMAIL>"

#---------------------------------------------------------------------------------------------------

import eventSupervisor.eventSupervisorUtils as esUtils

#---------------------------------------------------------------------------------------------------

### methods to identify updates by description

def is_skymapSummaryStart( description ):
    ''' determine whether description is for a skymap summary start alert by matching a string fragment. NOT IMPLEMENTED -> return False '''
    raise NotImplementedError('is_skymapSummaryStart')
    return False

#---------------------------------------------------------------------------------------------------

#-------------------------------------------------
# skymap autosummary
#-------------------------------------------------

class SkymapSummaryStartItem(esUtils.EventSupervisorQueueItem):
    """
    a check that the autosummary of skymaps started as expected

    alert:
        graceid
        fitsname
        tagnames
    options:
        dt
        email
    """
    name = "skymap summary start"

    def __init__(self, alert, t0, options, gdb, annotate=False, warnings=False, logDir='.', logTag='iQ'):
        graceid = alert['uid']
        self.fitsname = alert['file']
        self.tagnames = alert['object']['tag_names']

        self.description = "check that autosummary of skymaps started processing %s"%self.fitsname

        ### extract params from config
        timeout = float(options['dt'])
        email = options['email'].split()

        ### generate tasks
        tasks = [skymapSummaryStartCheck(timeout, self.fitsname, tagnames=self.tagnames, email=email, logDir=logDir, logTag='%s.%s'%(logTag, self.name))]

        ### wrap up instantiation
        super(SkymapSummaryStartItem, self).__init__( graceid,
                                                      gdb,
                                                      t0,
                                                      tasks,
                                                      annotate=annotate,
                                                      warnings=warnings,
                                                      logDir=logDir,
                                                      logTag=logTag,
                                                    )


class skymapSummaryStartCheck(esUtils.EventSupervisorTask):
    """
    a check that skymap autosummary started as expected
    """
    name = "skymapSummaryStart"

    def __init__(self, timeout, fitsname, tagnames=[], email=[], logDir='.', logTag='iQ'):
        self.fitsname = fitsname
        self.tagnames = tagnames
        self.description = "check that autosummary of skymaps started processing %s"%fitsname
        super(skymapSummaryStartCheck, self).__init__( timeout,
                                                       email=email,
                                                       logDir=logDir,
                                                       logTag=logTag,
                                                     )

    def skymapSummaryStart(self, graceid, gdb, verbose=False, annotate=False, **kwargs):
        """
        a check that skymap autosummary started as expected
        NOT IMPLEMENTED
        """
        raise NotImplementedError(self.name)


class SkymapSummaryItem(esUtils.EventSupervisorQueueItem):
    """
    a check that autosummary of skymaps ran and reported as expected

    alert:
        graceid
        fitsname
        tagnames
    options:
        data dt
        finish dt
        email
    """
    name = "skymap summary"

    def __init__(self, alert, t0, options, gdb, annotate=False, warnings=False, logDir='.', logTag='iQ'):
        graceid = alert['uid']
        self.fitsname = alert['description'].split()[-1] ### likely to break because I haven't written this yet...
        self.tagnames = alert['object']['tag_names']

        self.description = "check that autosummary of skymaps picked up and correctly processed %s"%self.fitsname

        ### extract params from config
        data_dt   = float(options['data dt'])
        finish_dt = float(options['finish dt'])
        email     = options['email'].split()

        ### generate tasks
        taskTag = '%s.%s'%(logTag, self.name)
        tasks = [skymapSummaryDataCheck(data_dt, self.fitsname, tagnames=self.tagnames, email=email, logDir=logDir, logTag=logTag),
                 skymapSummaryFinishCheck(finish_dt, self.fitsname, tagnames=self.tagnames, email=email, logDir=logDir, logTag=logTag)
                ]

        ### wrap up instantiation
        super(SkymapSummaryItem, self).__init__( graceid,
                                                 gdb,
                                                 t0,
                                                 tasks,
                                                 annotate=annotate,
                                                 warnings=warnings,
                                                 logDir=logDir,
                                                 logTag=logTag,
                                               )

class skymapSummaryDataCheck(esUtils.EventSupervisorTask):
    """
    a check that skymap autosummary generated the expected data
    """
    name = "skymapSummaryData"

    def __init__(self, timeout, fitsname, tagnames=[], email=[], logDir='.', logTag='iQ'):
        self.fitsname = fitsname
        self.tagnames = tagnames
        self.description = "check that autosummary of skymaps generated the expected data for %s"%fitsname
        super(skymapSummaryDataCheck, self).__init__( timeout,
                                                      email=email,
                                                      logDir=logDir,
                                                      logTag=logTag,
                                                    )

    def skymapSummaryData(self, graceid, gdb, verbose=False, annotate=False, **kwargs):
        """
        a check that skymap autosummary generated the expected data
        NOT IMPLEMENTED
        """
        raise NotImplementedError(self.name)

class skymapSummaryFinishCheck(esUtils.EventSupervisorTask):
    """
    a check that skymap autosummary finished as expected
    """
    name = "skymapSummaryFinish"

    def __init__(self, timeout, fitsname, tagnames=[], email=[], logDir='.', logTag='iQ'):
        self.fitsname = fitsname
        self.tagnames = tagnames
        self.description = "check that autosummary of skymaps finished as expected for %s"%fitsname
        super(skymapSummaryFinishCheck, self).__init__( timeout,
                                                        email=email,
                                                        logDir=logDir,
                                                        logTag=logTag,
                                                      )

    def skymapSummaryFinish(self, graceid, gdb, verbose=False, annotate=False, **kwargs):
        """
        a check that skymap autosummary finished as expected
        NOT IMPLEMENTED
        """
        raise NotImplementedError(self.name)<commit_msg>laid out a fairly complete skeleton of how skymapSummary checks should work, but did not actually implement them.<commit_after>description = "a module housing checks of skymap summary functionality"
author      = "<EMAIL>"

#---------------------------------------------------------------------------------------------------

import eventSupervisor.eventSupervisorUtils as esUtils

#---------------------------------------------------------------------------------------------------

### methods to identify updates by description

def is_snglFITSStart( description ):
    ''' determine whether description is for a snglFITS start alert by matching a string fragment.'''
    raise NotImplementedError('is_SnglFITSStart')
    return False

def is_snglFITSFinish( description ):
    ''' determine whether description is for a snglFITS finish alert by matching a string fragment.'''
    raise NotImplementedError('is_SnglFITSFinish')
    return False

def is_multFITSStart( description ):
    ''' determine whether description is for multFITS start alert by matching a string fragment.'''
    raise NotImplementedError('is_MultFITSStart')
    return False

#---------------------------------------------------------------------------------------------------

#-------------------------------------------------
# skymap autosummary
#-------------------------------------------------

class SnglFITSStartItem(esUtils.EventSupervisorQueueItem):
    """
    a check that snglFITS started as expected

    alert:
        graceid
        fitsname
        tagnames
    options:
        dt
        email
    """
    name = "snglFITS start"

    def __init__(self, alert, t0, options, gdb, annotate=False, warnings=False, logDir='.', logTag='iQ'):
        graceid = alert['uid']
        self.fitsname = alert['file']
        self.tagnames = alert['object']['tag_names']

        self.description = "check that snglFITS started processing %s"%self.fitsname

        ### extract params from config
        timeout = float(options['dt'])
        email = options['email'].split()

        ### generate tasks
        tasks = [snglFITSStartCheck(timeout, self.fitsname, tagnames=self.tagnames, email=email, logDir=logDir, logTag='%s.%s'%(logTag, self.name))]

        ### wrap up instantiation
        super(SnglFITSStartItem, self).__init__( graceid,
                                                      gdb,
                                                      t0,
                                                      tasks,
                                                      annotate=annotate,
                                                      warnings=warnings,
                                                      logDir=logDir,
                                                      logTag=logTag,
                                                    )


class snglFITSStartCheck(esUtils.EventSupervisorTask):
    """
    a check that snglFITS started as expected
    """
    name = "snglFITSStart"

    def __init__(self, timeout, fitsname, tagnames=[], email=[], logDir='.', logTag='iQ'):
        self.fitsname = fitsname
        self.tagnames = tagnames
        self.description = "check that snglFITS started processing %s"%fitsname
        super(snglFITSStartCheck, self).__init__( timeout,
                                                       email=email,
                                                       logDir=logDir,
                                                       logTag=logTag,
                                                     )

    def snglFITSStart(self, graceid, gdb, verbose=False, annotate=False, **kwargs):
        """
        a check that snglFITS started as expected
        NOT IMPLEMENTED
        """
        raise NotImplementedError(self.name)

class SnglFITSItem(esUtils.EventSupervisorQueueItem):
    """
    a check that snglFITS ran as expected

    alert:
        graceid
        fitsname
        tagnames
    options:
        dt
        email
    """
    name = "snglFITS"

    def __init__(self, alert, t0, options, gdb, annotate=False, warnings=False, logDir='.', logTag='iQ'):
        graceid = alert['uid']

        raise NotImplementedError(self.name) ### FIXME: need to parse out filename from log comment, get tagnames from looking through log? Just ignore tagnames? Include those in the log comment from within snglFITS.py?

        self.fitsname = alert['file']
        self.tagnames = alert['object']['tag_names']

        self.description = "check that snglFITS started processing %s"%self.fitsname

        ### extract params from config
        timeout = float(options['dt'])
        email = options['email'].split()

        ### generate tasks
        tasks = [snglFITSFinishCheck(timeout, self.fitsname, tagnames=self.tagnames, email=email, logDir=logDir, logTag='%s.%s'%(logTag, self.name))]

        ### wrap up instantiation
        super(SnglFITSItem, self).__init__( graceid,
                                                      gdb,
                                                      t0,
                                                      tasks,
                                                      annotate=annotate,
                                                      warnings=warnings,
                                                      logDir=logDir,
                                                      logTag=logTag,
                                                    )


class snglFITSFinishCheck(esUtils.EventSupervisorTask):
    """
    a check that snglFITS finished as expected
    """
    name = "snglFITSFinish"

    def __init__(self, timeout, fitsname, tagnames=[], email=[], logDir='.', logTag='iQ'):
        self.fitsname = fitsname
        self.tagnames = tagnames
        self.description = "check that snglFITS finished processing %s"%fitsname
        super(snglFITSFinishCheck, self).__init__( timeout,
                                                       email=email,
                                                       logDir=logDir,
                                                       logTag=logTag,
                                                     )

    def snglFITSFinish(self, graceid, gdb, verbose=False, annotate=False, **kwargs):
        """
        a check that snglFITS finished as expected
        NOT IMPLEMENTED
        """
        raise NotImplementedError(self.name)

class MultFITSStartItem(esUtils.EventSupervisorQueueItem):
    """
    a check that multFITS started as expected

    alert:
        graceid
        fitsname
        tagnames
    options:
        dt
        email
    """
    name = "multFITS start"

    def __init__(self, alert, t0, options, gdb, annotate=False, warnings=False, logDir='.', logTag='iQ'):
        graceid = alert['uid']

        raise NotImplementedError(self.name) ### FIXME: need to parse out filename from log comment, get tagnames from looking through log? Just ignore tagnames? Include those in the log comment from within snglFITS.py?

        self.fitsname = alert['file']
        self.tagnames = alert['object']['tag_names']

        self.description = "check that multFITS started processing %s"%self.fitsname

        ### extract params from config
        timeout = float(options['dt'])
        email = options['email'].split()

        ### generate tasks
        tasks = [multFITSStartCheck(timeout, self.fitsname, tagnames=self.tagnames, email=email, logDir=logDir, logTag='%s.%s'%(logTag, self.name))]

        ### wrap up instantiation
        super(MultFITSStartItem, self).__init__( graceid,
                                                      gdb,
                                                      t0,
                                                      tasks,
                                                      annotate=annotate,
                                                      warnings=warnings,
                                                      logDir=logDir,
                                                      logTag=logTag,
                                                    )

class multFITSStartCheck(esUtils.EventSupervisorTask):
    """
    a check that multFITS started as expected
    """
    name = "multFITSStart"

    def __init__(self, timeout, fitsname, tagnames=[], email=[], logDir='.', logTag='iQ'):
        self.fitsname = fitsname
        self.tagnames = tagnames
        self.description = "check that multFITS started processing %s"%fitsname
        super(multFITSStartCheck, self).__init__( timeout,
                                                       email=email,
                                                       logDir=logDir,
                                                       logTag=logTag,
                                                     )

    def snglFITSStart(self, graceid, gdb, verbose=False, annotate=False, **kwargs):
        """
        a check that multFITS started as expected
        NOT IMPLEMENTED
        """
        raise NotImplementedError(self.name)

class MultFITSItem(esUtils.EventSupervisorQueueItem):
    """
    a check that multFITS ran as expected

    alert:
        graceid
        fitsname
        tagnames
    options:
        dt
        email
    """
    name = "multFITS"

    def __init__(self, alert, t0, options, gdb, annotate=False, warnings=False, logDir='.', logTag='iQ'):
        graceid = alert['uid']

        raise NotImplementedError(self.name) ### FIXME: need to parse out filename from log comment, get tagnames from looking through log? Just ignore tagnames? Include those in the log comment from within snglFITS.py?

        self.fitsname = alert['file']
        self.tagnames = alert['object']['tag_names']

        self.description = "check that multFITS started processing %s"%self.fitsname

        ### extract params from config
        timeout = float(options['dt'])
        email = options['email'].split()

        ### generate tasks
        tasks = [multFITSFinishCheck(timeout, self.fitsname, tagnames=self.tagnames, email=email, logDir=logDir, logTag='%s.%s'%(logTag, self.name))]

        ### wrap up instantiation
        super(multFITSItem, self).__init__( graceid,
                                                      gdb,
                                                      t0,
                                                      tasks,
                                                      annotate=annotate,
                                                      warnings=warnings,
                                                      logDir=logDir,
                                                      logTag=logTag,
                                                    )

class multFITSFinishCheck(esUtils.EventSupervisorTask):
    """
    a check that multFITS finished as expected
    """
    name = "multFITSFinish"

    def __init__(self, timeout, fitsname, tagnames=[], email=[], logDir='.', logTag='iQ'):
        self.fitsname = fitsname
        self.tagnames = tagnames
        self.description = "check that multFITS fimished processing %s"%fitsname
        super(multFITSFinishCheck, self).__init__( timeout,
                                                       email=email,
                                                       logDir=logDir,
                                                       logTag=logTag,
                                                     )

    def snglFITSFinish(self, graceid, gdb, verbose=False, annotate=False, **kwargs):
        """
        a check that multFITS finish as expected
        NOT IMPLEMENTED
        """
        raise NotImplementedError(self.name)
{'fraction_non_alphanumeric': 0.12182472480948349, 'fraction_numerical': 0.0006879762912785775, 'mean_word_length': 1.324068380273029, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 152, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3186324', 'n_tokens_mistral': 4383, 'n_tokens_neox': 4290, 'n_words': 1109}