Skip to content

Commit

Permalink
last n rows instead of days (decouple from a current day)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-krystianc committed Nov 19, 2024
1 parent 1779416 commit 6af07a8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions generate_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# number of samples needed to calculate regression
SAMPLES = 10

# number of days to look back when calculating regression
DAYS = 14
# number of rows (days) to look back when calculating regression
ROWS = 14 * 3

# threshold in percents
THRESHOLD = 110
Expand Down Expand Up @@ -73,12 +73,10 @@ def get_regression(data_frame: pd.DataFrame) -> [str]:
data["timestamp"] = pd.to_datetime(data["timestamp"])
data = data.loc[data["scenario"] != 'warmup']

now = datetime.datetime.now(datetime.timezone.utc)
cutoff_date = now - datetime.timedelta(days=DAYS)
data = data.loc[data["timestamp"] > cutoff_date]
data = data.loc[-ROWS:]

regressions = get_regression(data)

if regressions:
with open(sys.argv[2], 'w', encoding='utf-8') as fp:
fp.write('\n'.join(regressions))
Expand Down

0 comments on commit 6af07a8

Please sign in to comment.