@@ -357,6 +357,7 @@ def rebuild_status(click, start_date, end_date, services) -> None:
357
357
# If there are changes we then extract the whole history for each changed
358
358
# TCAI in rebuild_feeds.
359
359
360
+
360
361
def run_detection_sql (start_date , end_date , services ) -> None :
361
362
if not conf .reprocess :
362
363
log .info (f"Running detection from { start_date } to { end_date } " )
@@ -633,24 +634,25 @@ def process_data(blocking_status, new):
633
634
+ m .accessible_perc_BS * nu
634
635
)
635
636
636
- # Stability should grow slowly when accessible_perc is constant over time
637
- # but drop quickly if accessible_perc changes a lot
637
+ # Stability moves slowly towards 1 when accessible_perc is constant over
638
+ # time but drop quickly towards 0 when accessible_perc changes a lot.
639
+ # It is later on used to decide when we are confident enough to make
640
+ # statements on BLOCKED/OK status. It is also immediately set to 0 when we
641
+ # detect a blocking change event to mitigate flapping.
638
642
s_def = 0.7 # default stability
639
- stability = np .cos (3.14 / 2 * delta )
640
- m ["stab_insta" ] = stability
641
-
642
- tau = 0.99
643
- good = stability * (1 - tau ) + m .stability .fillna (s_def ) * tau
643
+ stability_thr = 0.8 # threshold to consider a TCAI stable
644
+ gtau = 0.99 # moving average tau for
645
+ btau = 0.7
644
646
645
- tau = 0.7
646
- bad = stability * (1 - tau ) + m .stability .fillna (s_def ) * tau
647
+ stability = np .cos (3.14 / 2 * delta )
648
+ m ["stab_insta" ] = stability # used for charting
649
+ good = stability * (1 - gtau ) + m .stability .fillna (s_def ) * gtau
650
+ gstable = stability >= stability_thr
651
+ m .loc [gstable , "stability" ] = good [gstable ]
647
652
648
- thr = 0.8
649
- s = stability >= thr
650
- # m[s]["stability"] = good[s]
651
- m .loc [s , "stability" ] = good [s ]
652
- s = stability < thr
653
- m .loc [s , "stability" ] = bad [s ]
653
+ bad = stability * (1 - btau ) + m .stability .fillna (s_def ) * btau
654
+ bstable = stability < stability_thr
655
+ m .loc [bstable , "stability" ] = bad [bstable ]
654
656
655
657
m .status = m .status .fillna ("UNKNOWN" )
656
658
m .old_status = m .status .fillna ("UNKNOWN" )
@@ -688,23 +690,27 @@ def process_data(blocking_status, new):
688
690
# moving average on cnt
689
691
m ["cnt" ] = mavg_cnt
690
692
691
- assert sorted (m .columns ) == [
692
- "accessible_perc" ,
693
- "change" ,
694
- "cnt" ,
695
- "confirmed_perc" ,
696
- "input" ,
697
- "input_ap" ,
698
- "input_cnt" ,
699
- "old_status" ,
700
- "probe_asn" ,
701
- "probe_cc" ,
702
- "pure_anomaly_perc" ,
703
- "stab_insta" ,
704
- "stability" ,
705
- "status" ,
706
- "test_name" ,
707
- ] or True , sorted (m .columns )
693
+ assert (
694
+ sorted (m .columns )
695
+ == [
696
+ "accessible_perc" ,
697
+ "change" ,
698
+ "cnt" ,
699
+ "confirmed_perc" ,
700
+ "input" ,
701
+ "input_ap" ,
702
+ "input_cnt" ,
703
+ "old_status" ,
704
+ "probe_asn" ,
705
+ "probe_cc" ,
706
+ "pure_anomaly_perc" ,
707
+ "stab_insta" ,
708
+ "stability" ,
709
+ "status" ,
710
+ "test_name" ,
711
+ ]
712
+ or True
713
+ ), sorted (m .columns )
708
714
return m , events
709
715
710
716
@@ -780,8 +786,7 @@ def load_blocking_status_df(click):
780
786
781
787
782
788
def reprocess_data_from_df (idf , debug = False ):
783
- """Reprocess data using Pandas
784
- Used for testing/tuning
789
+ """Reprocess data using Pandas. Used primarily for testing.
785
790
"""
786
791
status = pd .DataFrame (
787
792
columns = [
@@ -832,6 +837,7 @@ def reprocess_data_from_df(idf, debug=False):
832
837
events = pd .concat (events_tmp )
833
838
else :
834
839
events = pd .DataFrame ()
840
+ print ("DONE" )
835
841
return events , status , status_history
836
842
837
843
@@ -844,7 +850,7 @@ def main():
844
850
click = Clickhouse .from_url (conf .db_uri ) # settings={"use_numpy":True})
845
851
846
852
# create_tables()
847
- # FIXME : configure services
853
+ # TODO : configure services
848
854
services = {
849
855
"Facebook" : ["https://www.facebook.com/" ],
850
856
"Twitter" : ["https://twitter.com/" ],
0 commit comments