Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
minhkhul committed Oct 21, 2024
1 parent 6a193eb commit 3115595
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
13 changes: 6 additions & 7 deletions _delphi_utils_python/delphi_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
from __future__ import absolute_import

from .archive import ArchiveDiffer, GitArchiveDiffer, S3ArchiveDiffer
from .export import create_export_csv, create_backup_csv
from .utils import read_params

from .slack_notifier import SlackNotifier
from .logger import get_structured_logger
from .export import create_backup_csv, create_export_csv
from .geomap import GeoMapper
from .smooth import Smoother
from .signal import add_prefix
from .logger import get_structured_logger
from .nancodes import Nans
from .signal import add_prefix
from .slack_notifier import SlackNotifier
from .smooth import Smoother
from .utils import read_params
from .weekday import Weekday

__version__ = "0.3.25"
17 changes: 9 additions & 8 deletions _delphi_utils_python/delphi_utils/export.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
"""Export data in the format expected by the Delphi API."""
# -*- coding: utf-8 -*-
from datetime import datetime
import gzip
from os.path import join, getsize
from typing import Optional
import logging
from datetime import datetime
from os.path import getsize, join
from typing import Optional

from epiweeks import Week
import numpy as np
import pandas as pd
from epiweeks import Week

from .nancodes import Nans


def filter_contradicting_missing_codes(df, sensor, metric, date, logger=None):
"""Find values with contradictory missingness codes, filter them, and log."""
columns = ["val", "se", "sample_size"]
Expand Down Expand Up @@ -142,7 +143,7 @@ def create_backup_csv(
geo_res: Optional[str] = None,
sensor: Optional[str] = None,
metric: Optional[str] = None,
logger: Optional[logging.Logger] = None
logger: Optional[logging.Logger] = None,
):
"""Save data for use as a backup.
Expand Down Expand Up @@ -186,18 +187,18 @@ def create_backup_csv(

# Label the file with today's date (the date the data was fetched).
if not issue:
issue = datetime.today().strftime('%Y%m%d')
issue = datetime.today().strftime("%Y%m%d")

backup_filename = [issue, geo_res, metric, sensor]
backup_filename = "_".join(filter(None, backup_filename)) + ".csv.gz"
backup_file = join(backup_dir, backup_filename)

with gzip.open(backup_file, 'wt', newline='') as f:
with gzip.open(backup_file, "wt", newline="") as f:
df.to_csv(f, index=False, na_rep="NA")

if logger:
logger.info(
"Backup file created",
backup_file=backup_file,
backup_size=getsize(backup_file)
backup_size=getsize(backup_file),
)

0 comments on commit 3115595

Please sign in to comment.