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

Replace deprecated pkg_resources #1921

Merged
merged 5 commits into from
Jun 7, 2024
Merged
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
8 changes: 4 additions & 4 deletions _delphi_utils_python/delphi_utils/geomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
Authors: Dmitry Shemetov @dshemetov, James Sharpnack @jsharpna, Maria Jahja
"""

from os.path import join
from collections import defaultdict
from os.path import join
from typing import Iterator, List, Literal, Optional, Set, Union

import importlib_resources
import pandas as pd
import pkg_resources
from pandas.api.types import is_string_dtype


Expand Down Expand Up @@ -153,7 +153,7 @@ def __init__(self, census_year: int = 2020):
for from_code, to_codes in self.CROSSWALK_FILENAMES.items():
for to_code, file_path in to_codes.items():
self._crosswalks[from_code][to_code] = self._load_crosswalk_from_file(
from_code, to_code, join(f"data/{census_year}", file_path)
from_code, to_code, join("data", f"{census_year}", file_path)
)

for geo_type in self._geos:
Expand All @@ -162,7 +162,7 @@ def __init__(self, census_year: int = 2020):
def _load_crosswalk_from_file(
self, from_code: str, to_code: str, data_path: str
) -> pd.DataFrame:
stream = pkg_resources.resource_stream(__name__, data_path)
stream = importlib_resources.files(__name__) / data_path
dtype = {
from_code: str,
to_code: str,
Expand Down
1 change: 1 addition & 0 deletions _delphi_utils_python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"epiweeks",
"freezegun",
"gitpython",
"importlib_resources>=1.3",
"mock",
"moto~=4.2.14",
"numpy",
Expand Down
Loading