# Timing and system resource metrics for Alert Production

description: Runtime metrics (customized for AP pipeline)
tasks:
    timing_isr:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: ip_isr  # metrics package
            connections.metric: IsrTime  # metric name
            connections.labelName: isr   # partial name of metadata dataset
            metadataDimensions: [instrument, exposure, detector]  # TimingMetricTask assumes visit
            target: isr.run              # method name in metadata. Usually matches label for top-level tasks
    timing_characterizeImage:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: pipe_tasks
            connections.metric: CharacterizeImageTime
            connections.labelName: characterizeImage
            target: characterizeImage.run
    timing_calibrate:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: pipe_tasks
            connections.metric: CalibrateTime
            connections.labelName: calibrate
            target: calibrate.run
    timing_imageDifference:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: pipe_tasks
            connections.metric: ImageDifferenceTime
            connections.labelName: imageDifference
            metadataDimensions: [instrument, visit, detector, skymap]
            target: imageDifference.run
    timing_imageDifference_astrometer:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: meas_astrom
            connections.metric: AstrometryTime
            connections.labelName: imageDifference
            metadataDimensions: [instrument, visit, detector, skymap]
            target: imageDifference:astrometer.loadAndMatch
    timing_imageDifference_register:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: pipe_tasks
            connections.metric: RegisterImageTime
            connections.labelName: imageDifference
            metadataDimensions: [instrument, visit, detector, skymap]
            target: imageDifference:register.run
    timing_imageDifference_subtract:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: ip_diffim
            connections.metric: ImagePsfMatchTime
            connections.labelName: imageDifference
            metadataDimensions: [instrument, visit, detector, skymap]
            target: imageDifference:subtract.subtractExposures
    timing_imageDifference_detection:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: meas_algorithms
            connections.metric: SourceDetectionTime
            connections.labelName: imageDifference
            metadataDimensions: [instrument, visit, detector, skymap]
            target: imageDifference:detection.run
    timing_imageDifference_measurement:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: ip_diffim
            connections.metric: DipoleFitTime
            connections.labelName: imageDifference
            metadataDimensions: [instrument, visit, detector, skymap]
            target: imageDifference:measurement.run
    timing_diaPipe:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: ap_association
            connections.metric: DiaPipelineTime
            connections.labelName: diaPipe
            target: diaPipe.run
    timing_diaPipe_diaSourceDpddifier:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: ap_association
            connections.metric: MapDiaSourceTime
            connections.labelName: diaPipe
            target: diaPipe:diaSourceDpddifier.run
    timing_diaPipe_diaCatalogLoader:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: ap_association
            connections.metric: LoadDiaCatalogsTime
            connections.labelName: diaPipe
            target: diaPipe:diaCatalogLoader.run
    timing_diaPipe_associator:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: ap_association
            connections.metric: AssociationTime
            connections.labelName: diaPipe
            target: diaPipe:associator.run
    timing_diaPipe_diaForcedSource:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: ap_association
            connections.metric: DiaForcedSourceTime
            connections.labelName: diaPipe
            target: diaPipe:diaForcedSource.run
    timing_diaPipe_alertPackager:
        class: lsst.verify.tasks.commonMetrics.TimingMetricTask
        config:
            connections.package: ap_association
            connections.metric: PackageAlertsTime
            connections.labelName: diaPipe
            target: diaPipe:alertPackager.run
    memory_apPipe:
        class: lsst.verify.tasks.commonMetrics.MemoryMetricTask
        config:
            connections.package: ap_pipe
            connections.metric: ApPipeMemory
            connections.labelName: diaPipe
            target: diaPipe.run  # Memory use is peak over process, so measure last task
    memory_diaForcedSource:
        class: lsst.verify.tasks.commonMetrics.MemoryMetricTask
        config:
            connections.package: ap_association
            connections.metric: DiaForcedSourceMemory
            connections.labelName: diaPipe
            target: diaPipe:diaForcedSource.run
    memory_alertPackager:
        class: lsst.verify.tasks.commonMetrics.MemoryMetricTask
        config:
            connections.package: ap_association
            connections.metric: PackageAlertsMemory
            connections.labelName: diaPipe
            target: diaPipe:alertPackager.run
