Skip to content

Commit bf09e1d

Browse files
authored
Merge pull request #279 from ing-bank/develop
Release v1.4.5
2 parents 2a6a2d4 + f36f922 commit bf09e1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+321
-300
lines changed

.github/workflows/license.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ repos:
44
hooks:
55
- id: black
66
- repo: https://github.com/charliermarsh/ruff-pre-commit
7-
rev: 'v0.0.270'
7+
rev: 'v0.0.277'
88
hooks:
99
- id: ruff
1010
args: [--fix]
1111
- repo: https://github.com/asottile/blacken-docs
12-
rev: 1.13.0
12+
rev: 1.14.0
1313
hooks:
1414
- id: blacken-docs
1515
- repo: local
@@ -24,5 +24,5 @@ repos:
2424
hooks:
2525
- id: nbqa-black
2626
- id: nbqa-ruff
27-
additional_dependencies: [ruff==v0.0.270]
27+
additional_dependencies: [ruff==v0.0.277]
2828

examples/integrations/kibana/elastic_connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
class ElasticConnector:
5-
def __init__(self):
5+
def __init__(self) -> None:
66
self.host = "localhost"
77
self.port = 9200
88
self.es = None

popmon/alerting/alerts_summary.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class AlertsSummary(Module):
3838
def __init__(
3939
self,
4040
read_key,
41-
store_key="",
41+
store_key: str = "",
4242
features=None,
4343
ignore_features=None,
44-
combined_variable="_AGGREGATE_",
45-
):
44+
combined_variable: str = "_AGGREGATE_",
45+
) -> None:
4646
"""Initialize an instance of AlertsSummary module.
4747
4848
:param str read_key: key of input data to read from datastore.

popmon/alerting/compute_tl_bounds.py

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from popmon.base import Module, Pipeline
3131

3232

33-
def traffic_light_summary(row, cols=None, prefix=""):
33+
def traffic_light_summary(row, cols=None, prefix: str = ""):
3434
"""Make a summary of traffic light alerts present in the dataframe
3535
3636
Count number of green, yellow and red traffic lights.
@@ -60,7 +60,9 @@ def traffic_light_summary(row, cols=None, prefix=""):
6060
return pd.Series(x)
6161

6262

63-
def traffic_light(value, red_high, yellow_high, yellow_low=0, red_low=0):
63+
def traffic_light(
64+
value, red_high, yellow_high, yellow_low: int = 0, red_low: int = 0
65+
) -> int:
6466
"""Get the corresponding traffic light given a value and traffic light bounds.
6567
6668
:param float value: value to check
@@ -120,17 +122,17 @@ def __init__(
120122
self,
121123
read_key,
122124
monitoring_rules=None,
123-
store_key="",
125+
store_key: str = "",
124126
features=None,
125127
ignore_features=None,
126-
apply_funcs_key="",
128+
apply_funcs_key: str = "",
127129
func=None,
128-
metrics_wide=False,
129-
prefix="traffic_light_",
130-
suffix="",
131-
entire=False,
130+
metrics_wide: bool = False,
131+
prefix: str = "traffic_light_",
132+
suffix: str = "",
133+
entire: bool = False,
132134
**kwargs,
133-
):
135+
) -> None:
134136
"""Initialize an instance of TrafficLightBounds module.
135137
136138
:param str read_key: key of input data to read from datastore
@@ -171,7 +173,7 @@ def get_description(self):
171173
"""Returns the traffic light function as description."""
172174
return self.traffic_light_func.__name__
173175

174-
def _set_traffic_lights(self, feature, cols, pattern, rule):
176+
def _set_traffic_lights(self, feature, cols, pattern, rule) -> None:
175177
process_cols = fnmatch.filter(cols, pattern)
176178

177179
for pcol in process_cols:
@@ -250,10 +252,10 @@ def pull_bounds(
250252
row,
251253
red_high,
252254
yellow_high,
253-
yellow_low=0,
254-
red_low=0,
255-
suffix_mean="_mean",
256-
suffix_std="_std",
255+
yellow_low: int = 0,
256+
red_low: int = 0,
257+
suffix_mean: str = "_mean",
258+
suffix_std: str = "_std",
257259
cols=None,
258260
):
259261
"""Calculate traffic light pull bounds for list of cols
@@ -307,10 +309,10 @@ def df_single_op_pull_bounds(
307309
df,
308310
red_high,
309311
yellow_high,
310-
yellow_low=0,
311-
red_low=0,
312-
suffix_mean="_mean",
313-
suffix_std="_std",
312+
yellow_low: int = 0,
313+
red_low: int = 0,
314+
suffix_mean: str = "_mean",
315+
suffix_std: str = "_std",
314316
cols=None,
315317
):
316318
"""Calculate traffic light pull bounds for list of cols on first row only
@@ -341,10 +343,10 @@ def __init__(
341343
self,
342344
read_key,
343345
rules,
344-
store_key="",
345-
suffix_mean="_mean",
346-
suffix_std="_std",
347-
):
346+
store_key: str = "",
347+
suffix_mean: str = "_mean",
348+
suffix_std: str = "_std",
349+
) -> None:
348350
"""Initialize an instance of DynamicTrafficLightBounds.
349351
350352
:param str read_key: key of input data to read from data store, only used to extract feature list.
@@ -385,10 +387,10 @@ def __init__(
385387
self,
386388
read_key,
387389
rules,
388-
store_key="",
389-
suffix_mean="_mean",
390-
suffix_std="_std",
391-
):
390+
store_key: str = "",
391+
suffix_mean: str = "_mean",
392+
suffix_std: str = "_std",
393+
) -> None:
392394
"""Initialize an instance of StaticBounds.
393395
394396
:param str read_key: key of input data to read from data store, only used to extract feature list.
@@ -432,7 +434,9 @@ class TrafficLightAlerts(Pipeline):
432434
- Apply them to profiled test statistics data
433435
"""
434436

435-
def __init__(self, read_key, store_key, rules, expanded_rules_key=""):
437+
def __init__(
438+
self, read_key, store_key, rules, expanded_rules_key: str = ""
439+
) -> None:
436440
"""Initialize an instance of TrafficLightBounds.
437441
438442
:param str read_key: key of input data to read from data store, only used to extract feature list.

popmon/analysis/apply_func.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
1717
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1818
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19-
19+
from __future__ import annotations
2020

2121
import warnings
22-
from typing import Optional
2322

2423
import numpy as np
2524
import pandas as pd
@@ -40,14 +39,14 @@ class ApplyFunc(Module):
4039
def __init__(
4140
self,
4241
apply_to_key,
43-
store_key="",
44-
assign_to_key="",
45-
apply_funcs_key="",
42+
store_key: str = "",
43+
assign_to_key: str = "",
44+
apply_funcs_key: str = "",
4645
features=None,
4746
apply_funcs=None,
4847
metrics=None,
49-
msg="",
50-
):
48+
msg: str = "",
49+
) -> None:
5150
"""Initialize an instance of ApplyFunc.
5251
5352
:param str apply_to_key: key of the input data to apply funcs to.
@@ -147,8 +146,8 @@ def add_apply_func(
147146
def transform(
148147
self,
149148
apply_to_data: dict,
150-
assign_to_data: Optional[dict] = None,
151-
apply_funcs: Optional[list] = None,
149+
assign_to_data: dict | None = None,
150+
apply_funcs: list | None = None,
152151
):
153152
"""
154153
Apply functions to specified feature and metrics

popmon/analysis/comparison/comparisons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def ks(p, q, *_):
168168
dim=1,
169169
htype="cat",
170170
)
171-
def unknown_labels(hist1, hist2):
171+
def unknown_labels(hist1, hist2) -> bool:
172172
# check consistency of bin_labels
173173
labels1 = hist1.keySet
174174
labels2 = hist2.keySet

popmon/analysis/comparison/hist_comparer.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from popmon.hist.hist_utils import COMMON_HIST_TYPES, is_numeric
4141

4242

43-
def hist_compare(row, hist_name1="", hist_name2=""):
43+
def hist_compare(row, hist_name1: str = "", hist_name2: str = ""):
4444
"""Function to compare two histograms
4545
4646
Apply statistical tests to compare two input histograms, such as:
@@ -107,11 +107,11 @@ def __init__(
107107
read_key,
108108
store_key,
109109
assign_to_key=None,
110-
hist_col="histogram",
111-
suffix="comp",
110+
hist_col: str = "histogram",
111+
suffix: str = "comp",
112112
*args,
113113
**kwargs,
114-
):
114+
) -> None:
115115
"""Initialize an instance of RollingHistComparer.
116116
117117
:param func_hist_collector: histogram collection function
@@ -160,10 +160,10 @@ def __init__(
160160
read_key,
161161
store_key,
162162
window,
163-
shift=1,
164-
hist_col="histogram",
165-
suffix="roll",
166-
):
163+
shift: int = 1,
164+
hist_col: str = "histogram",
165+
suffix: str = "roll",
166+
) -> None:
167167
"""Initialize an instance of RollingHistComparer.
168168
169169
:param str read_key: key of input data to read from data store
@@ -201,9 +201,9 @@ def __init__(
201201
self,
202202
read_key,
203203
store_key,
204-
hist_col="histogram",
205-
suffix="prev1",
206-
):
204+
hist_col: str = "histogram",
205+
suffix: str = "prev1",
206+
) -> None:
207207
"""Initialize an instance of PreviousHistComparer.
208208
209209
:param str read_key: key of input data to read from data store
@@ -228,10 +228,10 @@ def __init__(
228228
self,
229229
read_key,
230230
store_key,
231-
shift=1,
232-
hist_col="histogram",
233-
suffix="expanding",
234-
):
231+
shift: int = 1,
232+
hist_col: str = "histogram",
233+
suffix: str = "expanding",
234+
) -> None:
235235
"""Initialize an instance of ExpandingHistComparer.
236236
237237
:param str read_key: key of input data to read from data store
@@ -267,9 +267,9 @@ def __init__(
267267
reference_key,
268268
assign_to_key,
269269
store_key,
270-
hist_col="histogram",
271-
suffix="ref",
272-
):
270+
hist_col: str = "histogram",
271+
suffix: str = "ref",
272+
) -> None:
273273
"""Initialize an instance of ReferenceHistComparer.
274274
275275
:param str reference_key: key of input data to read from data store
@@ -306,10 +306,10 @@ def __init__(
306306
read_key,
307307
store_key,
308308
assign_to_key=None,
309-
hist_col="histogram",
309+
hist_col: str = "histogram",
310310
*args,
311311
**kwargs,
312-
):
312+
) -> None:
313313
"""Initialize an instance of NormHistComparer.
314314
315315
:param func_hist_collector: histogram collection function
@@ -349,7 +349,9 @@ def __init__(
349349
class RollingNormHistComparer(NormHistComparer):
350350
"""Compare histogram to previous rolling normalized histograms"""
351351

352-
def __init__(self, read_key, store_key, window, shift=1, hist_col="histogram"):
352+
def __init__(
353+
self, read_key, store_key, window, shift: int = 1, hist_col: str = "histogram"
354+
) -> None:
353355
"""Initialize an instance of RollingNormHistComparer.
354356
355357
:param str read_key: key of input data to read from data store
@@ -383,7 +385,9 @@ def transform(self, datastore):
383385
class ExpandingNormHistComparer(NormHistComparer):
384386
"""Compare histogram to previous expanding normalized histograms"""
385387

386-
def __init__(self, read_key, store_key, shift=1, hist_col="histogram"):
388+
def __init__(
389+
self, read_key, store_key, shift: int = 1, hist_col: str = "histogram"
390+
) -> None:
387391
"""Initialize an instance of ExpandingNormHistComparer.
388392
389393
:param str read_key: key of input data to read from data store
@@ -412,7 +416,9 @@ def transform(self, datastore):
412416
class ReferenceNormHistComparer(NormHistComparer):
413417
"""Compare histogram to reference normalized histograms"""
414418

415-
def __init__(self, reference_key, assign_to_key, store_key, hist_col="histogram"):
419+
def __init__(
420+
self, reference_key, assign_to_key, store_key, hist_col: str = "histogram"
421+
) -> None:
416422
"""Initialize an instance of ReferenceNormHistComparer.
417423
418424
:param str reference_key: key of input data to read from data store

0 commit comments

Comments
 (0)