From ea52ad71987b32f93a8d0a4c0299456d7171c54b Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Thu, 4 Jan 2024 17:12:09 +0200 Subject: [PATCH 1/4] Replace deprecated pkg_resources --- _delphi_utils_python/delphi_utils/geomap.py | 4 ++-- _delphi_utils_python/setup.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/_delphi_utils_python/delphi_utils/geomap.py b/_delphi_utils_python/delphi_utils/geomap.py index f43b80504..56ec4eded 100644 --- a/_delphi_utils_python/delphi_utils/geomap.py +++ b/_delphi_utils_python/delphi_utils/geomap.py @@ -12,7 +12,7 @@ from collections import defaultdict import pandas as pd -import pkg_resources +import importlib_resources from pandas.api.types import is_string_dtype @@ -138,7 +138,7 @@ def __init__(self, census_year=2020): self._geo_sets[geo_type] = self._load_geo_values(geo_type) def _load_crosswalk_from_file(self, from_code, to_code, data_path): - stream = pkg_resources.resource_stream(__name__, data_path) + stream = importlib_resources.files(__name__).joinpath(data_path) dtype = { from_code: str, to_code: str, diff --git a/_delphi_utils_python/setup.py b/_delphi_utils_python/setup.py index b3aa86358..eebdd44c0 100644 --- a/_delphi_utils_python/setup.py +++ b/_delphi_utils_python/setup.py @@ -11,6 +11,7 @@ "epiweeks", "freezegun", "gitpython", + "importlib_resources==6.1.1", "mock", "moto", "numpy", From 3ae53ad82af14808c24bc7fb10db534b8b9a2153 Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Tue, 23 Jan 2024 20:05:10 +0200 Subject: [PATCH 2/4] Less strict version --- _delphi_utils_python/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_delphi_utils_python/setup.py b/_delphi_utils_python/setup.py index eebdd44c0..9560feb71 100644 --- a/_delphi_utils_python/setup.py +++ b/_delphi_utils_python/setup.py @@ -11,7 +11,7 @@ "epiweeks", "freezegun", "gitpython", - "importlib_resources==6.1.1", + "importlib_resources>=1.3", "mock", "moto", "numpy", From bc6962eba534d95e839fa0e7933c68e7dc146b73 Mon Sep 17 00:00:00 2001 From: Dmitry Shemetov Date: Fri, 7 Jun 2024 14:58:05 -0700 Subject: [PATCH 3/4] lint(geomap): minor tweak --- _delphi_utils_python/delphi_utils/geomap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_delphi_utils_python/delphi_utils/geomap.py b/_delphi_utils_python/delphi_utils/geomap.py index 56ec4eded..0b7e8a766 100644 --- a/_delphi_utils_python/delphi_utils/geomap.py +++ b/_delphi_utils_python/delphi_utils/geomap.py @@ -131,14 +131,14 @@ def __init__(self, census_year=2020): self._crosswalks[from_code][to_code] = \ self._load_crosswalk_from_file(from_code, to_code, - join(f"data/{census_year}", file_path) + join("data", f"{census_year}", file_path) ) for geo_type in self._geos: self._geo_sets[geo_type] = self._load_geo_values(geo_type) def _load_crosswalk_from_file(self, from_code, to_code, data_path): - stream = importlib_resources.files(__name__).joinpath(data_path) + stream = importlib_resources.files(__name__) / data_path dtype = { from_code: str, to_code: str, From 195d7b23b898f810655ac903eb62286e7c42c051 Mon Sep 17 00:00:00 2001 From: Dmitry Shemetov Date: Fri, 7 Jun 2024 15:02:53 -0700 Subject: [PATCH 4/4] lint: format --- _delphi_utils_python/delphi_utils/geomap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_delphi_utils_python/delphi_utils/geomap.py b/_delphi_utils_python/delphi_utils/geomap.py index 5b6786036..be6df2d24 100644 --- a/_delphi_utils_python/delphi_utils/geomap.py +++ b/_delphi_utils_python/delphi_utils/geomap.py @@ -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 pandas as pd import importlib_resources +import pandas as pd from pandas.api.types import is_string_dtype