-
Notifications
You must be signed in to change notification settings - Fork 27
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 #667
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,19 @@ | |
from typing import Union, Iterable | ||
|
||
import pandas as pd | ||
import pkg_resources | ||
|
||
COUNTY_CENSUS = pd.read_csv( | ||
pkg_resources.resource_filename(__name__, "geo_mappings/county_census.csv"), dtype=str) | ||
MSA_CENSUS = pd.read_csv( | ||
pkg_resources.resource_filename(__name__, "geo_mappings/msa_census.csv"), dtype=str) | ||
STATE_CENSUS = pd.read_csv( | ||
pkg_resources.resource_filename(__name__, "geo_mappings/state_census.csv"), dtype=str) | ||
import importlib_resources | ||
|
||
county_census = importlib_resources.files(__name__) / 'geo_mappings' / 'county_census.csv' | ||
with importlib_resources.as_file(county_census) as path: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this context manager afford us anything? it looks like |
||
COUNTY_CENSUS = pd.read_csv(path, dtype=str) | ||
|
||
msa_census = importlib_resources.files(__name__) / 'geo_mappings' / 'msa_census.csv' | ||
with importlib_resources.as_file(msa_census) as path: | ||
MSA_CENSUS = pd.read_csv(path, dtype=str) | ||
|
||
state_census = importlib_resources.files(__name__) / 'geo_mappings' / 'state_census.csv' | ||
with importlib_resources.as_file(state_census) as path: | ||
STATE_CENSUS = pd.read_csv(path, dtype=str) | ||
|
||
# Filter undesired rows from CSVs. | ||
# They're not removed from the files to keep them identical to rda files. | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -30,7 +30,8 @@ | |||||
"imageio-ffmpeg", | ||||||
"imageio", | ||||||
"tqdm", | ||||||
"epiweeks" | ||||||
"epiweeks", | ||||||
"importlib_resources==6.1.1", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we be pinning the exact version? I'd assume we just want a compatible version, as in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It definitely makes sense for this to less rigid than requiring an exact version, particularly since the other packages are specified with open-ended constraints (or none at all). Based on the last comment linked gitlab issue, it looks like this could be:
Suggested change
Backports are nice for functionality but potentially headache-inducing w.r.t. dependency complexity... We could make the requirement " |
||||||
], | ||||||
package_data={"covidcast": ["shapefiles/*/*", "geo_mappings/*"]} | ||||||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is the top-level namespace for this sub-package, we should either prefix this variable name with an underscore or avoid creating the variable in the first place. this is especially true because its name is the lowercase version of the name of a constant, so maybe make the name more descriptive if you want to keep it around.