Skip to content

Commit 67a10e0

Browse files
authored
Merge pull request #965 from sgsmob/validator
Simplify syntax to suppress all validation checks for a signal/geo/time
2 parents b1ef84e + 00e85f7 commit 67a10e0

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

_delphi_utils_python/delphi_utils/validator/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Please update the follow settings:
5656
* `end_date`: specifies the last date to be checked; this can be specified as `YYYY-MM-DD`, `today`, or `today-{num}`. The latter is interpretted as `num` days before the current date.
5757
* `span_length`: specifies the number of days before the `end_date` to check. `span_length` should be long enough to contain all recent source data that is still in the process of being updated (i.e. in the backfill period), for example, if the data source of interest has a 2-week lag before all reports are in for a given date, `span_length` should be 14 days
5858
* `suppressed_errors`: list of objects specifying errors that have been manually verified as false positives or acceptable deviations from expected. These errors can be specified with the following variables, where omitted values are interpreted as a wildcard, i.e., not specifying a date applies to all dates:
59-
* `check_name` (required): name of the check, as specified in the validation output
59+
* `check_name`: name of the check, as specified in the validation output
6060
* `date`: date in `YYYY-MM-DD` format
6161
* `geo_type`: geo resolution of the data
6262
* `signal`: name of COVIDcast API signal

_delphi_utils_python/delphi_utils/validator/errors.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ValidationFailure:
2323
"""Structured report of single validation failure."""
2424

2525
def __init__(self,
26-
check_name: str,
26+
check_name: Optional[str]=None,
2727
date: Optional[Union[str, dt.date]]=None,
2828
geo_type: Optional[str]=None,
2929
signal: Optional[str]=None,
@@ -33,8 +33,9 @@ def __init__(self,
3333
3434
Parameters
3535
----------
36-
check_name: str
37-
Name of check at which the failure happened.
36+
check_name: Optional[str]
37+
Name of check at which the failure happened. A value of `None` is used to express all
38+
possible checks with a given `date`, `geo_type`, and/or `signal`.
3839
date: Optional[Union[str, dt.date]]
3940
Date corresponding to the data over which the failure happened.
4041
Strings are interpretted in ISO format ("YYYY-MM-DD").

_delphi_utils_python/tests/validator/test_errors.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def test_init(self):
2020
vf2 = ValidationFailure("chk", dt.date(1990, 10, 3))
2121
assert vf2.check_name == "chk"
2222
assert vf2.date == dt.date(1990, 10, 3)
23-
assert vf2.geo_type == None
24-
assert vf2.signal == None
23+
assert vf2.geo_type is None
24+
assert vf2.signal is None
2525
assert vf2.message == ""
2626

2727
# Values extracted from a filename.
@@ -33,6 +33,14 @@ def test_init(self):
3333
assert vf3.signal == "cases_7dav"
3434
assert vf3.message == ""
3535

36+
# All missing arguments
37+
vf4 = ValidationFailure()
38+
assert vf4.check_name is None
39+
assert vf4.date is None
40+
assert vf4.geo_type is None
41+
assert vf4.signal is None
42+
assert vf4.message == ""
43+
3644
with pytest.raises(AssertionError,
3745
match='`filename` argument expected to be in "{date}_{geo_type}_'\
3846
'{signal}.{extension}" format'):

0 commit comments

Comments
 (0)