Skip to content

feat: use delphi-logger #1469

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

Closed
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions requirements.api.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
delphi_utils
delphi_logger @ git+https://github.com/cmu-delphi/delphi-logger
epiweeks==2.1.2
Flask==2.2.5
Flask-Limiter==3.3.0
Expand Down
1 change: 1 addition & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ black>=20.8b1
bump2version==1.0.1
covidcast==0.1.5
delphi_utils
delphi_logger @ git+https://github.com/cmu-delphi/delphi-logger
docker==6.0.1
dropbox==11.36.0
freezegun==1.2.2
Expand Down
2 changes: 1 addition & 1 deletion src/acquisition/covid_hosp/common/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# first party
import delphi.operations.secrets as secrets
from delphi.epidata.common.logger import get_structured_logger
from delphi_logger import get_structured_logger

Columndef = namedtuple("Columndef", "csv_name sql_name dtype")

Expand Down
2 changes: 1 addition & 1 deletion src/acquisition/covidcast/csv_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from delphi_utils import Nans
from delphi.utils.epiweek import delta_epiweeks
from delphi.epidata.common.covidcast_row import CovidcastRow
from delphi.epidata.common.logger import get_structured_logger
from delphi_logger import get_structured_logger

DataFrameRow = NamedTuple('DFRow', [
('geo_id', str),
Expand Down
2 changes: 1 addition & 1 deletion src/acquisition/covidcast/csv_to_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from delphi.epidata.acquisition.covidcast.csv_importer import CsvImporter, PathDetails
from delphi.epidata.acquisition.covidcast.database import Database, DBLoadStateException
from delphi.epidata.acquisition.covidcast.file_archiver import FileArchiver
from delphi.epidata.common.logger import get_structured_logger
from delphi_logger import get_structured_logger


def get_argument_parser():
Expand Down
20 changes: 10 additions & 10 deletions src/acquisition/covidcast/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# first party
import delphi.operations.secrets as secrets
from delphi.epidata.common.logger import get_structured_logger
from delphi_logger import get_structured_logger
from delphi.epidata.common.covidcast_row import CovidcastRow


Expand Down Expand Up @@ -117,28 +117,28 @@ def insert_or_update_batch(self, cc_rows: List[CovidcastRow], batch_size=2**20,
get_structured_logger("insert_or_update_batch").fatal(err_msg)
raise DBLoadStateException(err_msg)

# NOTE: `value_update_timestamp` is hardcoded to "NOW" (which is appropriate) and
# NOTE: `value_update_timestamp` is hardcoded to "NOW" (which is appropriate) and
# `is_latest_issue` is hardcoded to 1 (which is temporary and addressed later in this method)
insert_into_loader_sql = f'''
INSERT INTO `{self.load_table}`
(`source`, `signal`, `time_type`, `geo_type`, `time_value`, `geo_value`,
`value_updated_timestamp`, `value`, `stderr`, `sample_size`, `issue`, `lag`,
`value_updated_timestamp`, `value`, `stderr`, `sample_size`, `issue`, `lag`,
`is_latest_issue`, `missing_value`, `missing_stderr`, `missing_sample_size`)
VALUES
(%s, %s, %s, %s, %s, %s,
UNIX_TIMESTAMP(NOW()), %s, %s, %s, %s, %s,
(%s, %s, %s, %s, %s, %s,
UNIX_TIMESTAMP(NOW()), %s, %s, %s, %s, %s,
1, %s, %s, %s)
'''

# all load table entries are already marked "is_latest_issue".
# if an entry in the load table is NOT in the latest table, it is clearly now the latest value for that key (so we do nothing (thanks to INNER join)).
# if an entry *IS* in both load and latest tables, but latest table issue is newer, unmark is_latest_issue in load.
fix_is_latest_issue_sql = f'''
UPDATE
`{self.load_table}` JOIN `{self.latest_view}`
USING (`source`, `signal`, `geo_type`, `geo_value`, `time_type`, `time_value`)
SET `{self.load_table}`.`is_latest_issue`=0
WHERE `{self.load_table}`.`issue` < `{self.latest_view}`.`issue`
UPDATE
`{self.load_table}` JOIN `{self.latest_view}`
USING (`source`, `signal`, `geo_type`, `geo_value`, `time_type`, `time_value`)
SET `{self.load_table}`.`is_latest_issue`=0
WHERE `{self.load_table}`.`issue` < `{self.latest_view}`.`issue`
'''

# TODO: consider handling cc_rows as a generator instead of a list
Expand Down
2 changes: 1 addition & 1 deletion src/acquisition/covidcast/file_archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import shutil

# first party
from delphi.epidata.common.logger import get_structured_logger
from delphi_logger import get_structured_logger

class FileArchiver:
"""Archives files by moving and compressing."""
Expand Down
2 changes: 1 addition & 1 deletion src/client/delphi_epidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from aiohttp import ClientSession, TCPConnector, BasicAuth

from delphi_utils.logger import get_structured_logger
from delphi_logger import get_structured_logger

__version__ = "4.1.23"

Expand Down
7 changes: 6 additions & 1 deletion src/client/packaging/pypi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
"Changelog": "https://github.com/cmu-delphi/delphi-epidata/blob/main/src/client/packaging/pypi/CHANGELOG.md",
},
packages=setuptools.find_packages(),
install_requires=["aiohttp", "delphi-utils", "requests>=2.7.0", "tenacity"],
install_requires=[
"aiohttp",
"delphi_logger @ git+https://github.com/cmu-delphi/delphi-logger",
"requests>=2.7.0",
"tenacity"
],
classifiers=[
"Programming Language :: Python",
"License :: OSI Approved :: MIT License",
Expand Down
254 changes: 0 additions & 254 deletions src/common/logger.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/maintenance/covidcast_meta_cache_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# first party
from delphi.epidata.acquisition.covidcast.database import Database
from delphi.epidata.common.logger import get_structured_logger
from delphi_logger import get_structured_logger
from delphi.epidata.client.delphi_epidata import Epidata

def get_argument_parser():
Expand Down
2 changes: 1 addition & 1 deletion src/maintenance/delete_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# first party
from delphi.epidata.acquisition.covidcast.database import Database
from delphi.epidata.common.logger import get_structured_logger
from delphi_logger import get_structured_logger


def get_argument_parser():
Expand Down
Loading
Loading