Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: bundle covidcast==0.2.2 in delphi_utils #1985

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
580 changes: 580 additions & 0 deletions _delphi_utils_python/delphi_utils/covidcast_port.py

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions _delphi_utils_python/delphi_utils/validator/datafetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

import re
import threading
import warnings
from os import listdir
from os.path import isfile, join
import warnings
import requests
import pandas as pd

import numpy as np
import covidcast
import pandas as pd
import requests

from .. import covidcast_port as covidcast
from .errors import APIDataFetchError, ValidationFailure

FILENAME_REGEX = re.compile(
Expand Down
13 changes: 8 additions & 5 deletions _delphi_utils_python/delphi_utils/validator/dynamic.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
"""Dynamic file checks."""

import re
from dataclasses import dataclass
from datetime import date, timedelta
from typing import Dict, Set
import re
import pandas as pd

import numpy as np
import covidcast
from .errors import ValidationFailure
import pandas as pd

from .. import covidcast_port as covidcast
from .datafetcher import get_geo_signal_combos, threaded_api_calls
from .utils import relative_difference_by_min, TimeWindow, lag_converter
from .errors import ValidationFailure
from .utils import TimeWindow, lag_converter, relative_difference_by_min


class DynamicValidator:
Expand Down
5 changes: 3 additions & 2 deletions _delphi_utils_python/delphi_utils/validator/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
when the module is run with `python -m delphi_utils.validator`.
"""
import argparse as ap
import covidcast
from .. import read_params, get_structured_logger

from .. import covidcast_port as covidcast
from .. import get_structured_logger, read_params
from .validate import Validator


Expand Down
2 changes: 1 addition & 1 deletion _delphi_utils_python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

required = [
"boto3",
"covidcast",
"cvxpy",
"darker[isort]~=2.1.1",
"delphi-epidata==4.1.20",
"epiweeks",
"freezegun",
"gitpython",
Expand Down
346 changes: 346 additions & 0 deletions _delphi_utils_python/tests/test-covidcast-port.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions _delphi_utils_python/tests/validator/test_datafetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def raise_for_status(self):
else:
return MockResponse([{"signals": [{"active": True}]}], 200)

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

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

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

Expand Down
14 changes: 5 additions & 9 deletions google_symptoms/delphi_google_symptoms/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@
when the module is run with `python -m delphi_google_symptoms`.
"""
import time
from datetime import datetime, date
from datetime import date, datetime
from itertools import product
import covidcast

import delphi_utils.covidcast_port as covidcast
import numpy as np
from pandas import to_datetime
from delphi_utils import (
create_export_csv,
get_structured_logger
)
from delphi_utils import create_export_csv, get_structured_logger
from delphi_utils.validator.utils import lag_converter
from pandas import to_datetime

from .constants import (COMBINED_METRIC,
GEO_RESOLUTIONS, SMOOTHERS, SMOOTHERS_MAP)
from .constants import COMBINED_METRIC, GEO_RESOLUTIONS, SMOOTHERS, SMOOTHERS_MAP
from .geo import geo_map
from .pull import pull_gs_data

Expand Down
4 changes: 2 additions & 2 deletions sir_complainsalot/delphi_sir_complainsalot/check_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from datetime import datetime, timedelta
from typing import List

import covidcast
import delphi_utils.covidcast_port as covidcast
import pandas as pd

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

@dataclass
class Complaint:
Expand Down
2 changes: 1 addition & 1 deletion sir_complainsalot/delphi_sir_complainsalot/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import time
from itertools import groupby

import covidcast
import delphi_utils.covidcast_port as covidcast
from delphi_utils import SlackNotifier
from delphi_utils import get_structured_logger
from delphi_utils import read_params
Expand Down
2 changes: 1 addition & 1 deletion testing_utils/indicator_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from os.path import isfile, join, basename
from datetime import datetime

import covidcast
import delphi_utils.covidcast_port as covidcast
from joblib import Memory
import nest_asyncio
from numpy.core.numeric import NaN
Expand Down
Loading