-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathrun.py
More file actions
42 lines (35 loc) · 1.41 KB
/
run.py
File metadata and controls
42 lines (35 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
"""Functions to call when running the tool.
This module should contain a function called `run_module`, that is executed
when the module is run with `python -m delphi_utils.validator`.
"""
import argparse as ap
from .. import covidcast_port as covidcast
from .. import get_structured_logger, read_params
from .validate import Validator
def run_module():
"""Run the validator as a module."""
parser = ap.ArgumentParser()
parser.add_argument("--dry_run", action="store_true", help="When provided, return zero exit"
" status irrespective of the number of failures")
args = parser.parse_args()
params = read_params()
assert "validation" in params
covidcast.use_api_key(params["validation"]["common"]["api_credentials"])
dry_run_param = params["validation"]["common"].get("dry_run", False)
params["validation"]["common"]["dry_run"] = args.dry_run or dry_run_param
validator = Validator(params)
validator.validate().print_and_exit(
get_structured_logger(__name__,
params["common"].get("log_filename", None)),
not (args.dry_run or dry_run_param))
def validator_from_params(params):
"""Construct a validator from `params`.
Arguments
---------
params: Dict[str, Any]
Dictionary of parameters
"""
if "validation" in params:
return Validator(params)
return None