Skip to content

Commit b7b18d6

Browse files
committed
refactor: bundle covidcast==0.2.2 in delphi_utils #1972
1 parent 84d0597 commit b7b18d6

File tree

11 files changed

+955
-28
lines changed

11 files changed

+955
-28
lines changed

_delphi_utils_python/delphi_utils/covidcast_port.py

+580
Large diffs are not rendered by default.

_delphi_utils_python/delphi_utils/validator/datafetcher.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33

44
import re
55
import threading
6+
import warnings
67
from os import listdir
78
from os.path import isfile, join
8-
import warnings
9-
import requests
10-
import pandas as pd
9+
1110
import numpy as np
12-
import covidcast
11+
import pandas as pd
12+
import requests
13+
14+
from .. import covidcast_port as covidcast
1315
from .errors import APIDataFetchError, ValidationFailure
1416

1517
FILENAME_REGEX = re.compile(

_delphi_utils_python/delphi_utils/validator/dynamic.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
"""Dynamic file checks."""
2+
3+
import re
24
from dataclasses import dataclass
35
from datetime import date, timedelta
46
from typing import Dict, Set
5-
import re
6-
import pandas as pd
7+
78
import numpy as np
8-
import covidcast
9-
from .errors import ValidationFailure
9+
import pandas as pd
10+
11+
from .. import covidcast_port as covidcast
1012
from .datafetcher import get_geo_signal_combos, threaded_api_calls
11-
from .utils import relative_difference_by_min, TimeWindow, lag_converter
13+
from .errors import ValidationFailure
14+
from .utils import TimeWindow, lag_converter, relative_difference_by_min
1215

1316

1417
class DynamicValidator:

_delphi_utils_python/delphi_utils/validator/run.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
when the module is run with `python -m delphi_utils.validator`.
66
"""
77
import argparse as ap
8-
import covidcast
9-
from .. import read_params, get_structured_logger
8+
9+
from .. import covidcast_port as covidcast
10+
from .. import get_structured_logger, read_params
1011
from .validate import Validator
1112

1213

_delphi_utils_python/setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
required = [
88
"boto3",
9-
"covidcast",
109
"cvxpy",
1110
"darker[isort]~=2.1.1",
1211
"epiweeks",

_delphi_utils_python/tests/test-covidcast-port.py

+346
Large diffs are not rendered by default.

_delphi_utils_python/tests/validator/test_datafetcher.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def raise_for_status(self):
4848
else:
4949
return MockResponse([{"signals": [{"active": True}]}], 200)
5050

51-
# the `kw` approach is needed here because otherwise pytest thinks the
51+
# the `kw` approach is needed here because otherwise pytest thinks the
5252
# requests_mock arg is supposed to be a fixture
5353
@requests_mock.Mocker(kw="mock_requests")
5454
def test_bad_api_key(self, **kwargs):
@@ -57,7 +57,7 @@ def test_bad_api_key(self, **kwargs):
5757
get_geo_signal_combos("chng", api_key="")
5858

5959
@mock.patch('requests.get', side_effect=mocked_requests_get)
60-
@mock.patch("covidcast.metadata")
60+
@mock.patch("delphi_utils.covidcast_port.metadata")
6161
def test_get_geo_signal_combos(self, mock_metadata, mock_get):
6262
"""Test that the geo signal combos are correctly pulled from the covidcast metadata."""
6363
# Need to use actual data_source and signal names since we reference the API
@@ -87,7 +87,7 @@ def test_get_geo_signal_combos(self, mock_metadata, mock_get):
8787
("msa", "pcr_specimen_positivity_rate"),
8888
("msa", "pcr_specimen_total_tests")])
8989

90-
@mock.patch("covidcast.signal")
90+
@mock.patch("delphi_utils.covidcast_port.signal")
9191
def test_threaded_api_calls(self, mock_signal):
9292
"""Test that calls to the covidcast API are made."""
9393

google_symptoms/delphi_google_symptoms/run.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,16 @@
55
when the module is run with `python -m delphi_google_symptoms`.
66
"""
77
import time
8-
from datetime import datetime, date
8+
from datetime import date, datetime
99
from itertools import product
10-
import covidcast
1110

11+
import delphi_utils.covidcast_port as covidcast
1212
import numpy as np
13-
from pandas import to_datetime
14-
from delphi_utils import (
15-
create_export_csv,
16-
get_structured_logger
17-
)
13+
from delphi_utils import create_export_csv, get_structured_logger
1814
from delphi_utils.validator.utils import lag_converter
15+
from pandas import to_datetime
1916

20-
from .constants import (COMBINED_METRIC,
21-
GEO_RESOLUTIONS, SMOOTHERS, SMOOTHERS_MAP)
17+
from .constants import COMBINED_METRIC, GEO_RESOLUTIONS, SMOOTHERS, SMOOTHERS_MAP
2218
from .geo import geo_map
2319
from .pull import pull_gs_data
2420

sir_complainsalot/delphi_sir_complainsalot/check_source.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
from datetime import datetime, timedelta
55
from typing import List
66

7-
import covidcast
7+
import delphi_utils.covidcast_port as covidcast
88
import pandas as pd
99

10-
covidcast.covidcast._ASYNC_CALL = True # pylint: disable=protected-access
10+
covidcast._ASYNC_CALL = True # pylint: disable=protected-access
1111

1212
@dataclass
1313
class Complaint:

sir_complainsalot/delphi_sir_complainsalot/run.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import time
99
from itertools import groupby
1010

11-
import covidcast
11+
import delphi_utils.covidcast_port as covidcast
1212
from delphi_utils import SlackNotifier
1313
from delphi_utils import get_structured_logger
1414
from delphi_utils import read_params

testing_utils/indicator_validation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from os.path import isfile, join, basename
33
from datetime import datetime
44

5-
import covidcast
5+
import delphi_utils.covidcast_port as covidcast
66
from joblib import Memory
77
import nest_asyncio
88
from numpy.core.numeric import NaN

0 commit comments

Comments
 (0)