-
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
use python package-specific "user agent" string #665
use python package-specific "user agent" string #665
Conversation
@capnrefsmmat thoughts? |
Seems reasonable to me. I had considered putting the version information in the user-agent previously, but didn't know how to get the version information without hardcoding it in a constant somewhere. |
@@ -7,12 +7,22 @@ | |||
import pandas as pd | |||
import numpy as np | |||
from delphi_epidata import Epidata | |||
from delphi_epidata.delphi_epidata import _HEADERS | |||
from pkg_resources import get_distribution, DistributionNotFound |
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.
I couldn't find documentation for pkg_resources
. My guess is it comes from setuptools
which is being deprecated.
Maybe use importlib.metadata
to future-proof? From docs:
importlib.metadata is a library that provides access to the metadata of an installed Distribution Package, such as its entry points or its top-level names (Import Packages, modules, if any). Built in part on Python’s import system, this library intends to replace similar functionality in the entry point API and metadata API of pkg_resources. Along with importlib.resources, this package can eliminate the need to use the older and less efficient pkg_resources package.
> import pkg_resources
> import importlib.metadata
> print(pkg_resources.get_distribution('wheel'))
> print(importlib.metadata.version('wheel'))
wheel 0.41.2
0.41.2
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.
I shamelessly stole the version determination code from the delphi-epidata python client (that this client depends on): https://github.com/cmu-delphi/delphi-epidata/blob/d42517e714d6d1deebb6cffcdf3fb5adadc54481/src/client/delphi_epidata.py#L17-L25
I dont see where setuptools (as a whole) is being deprecated, but pkg_resources did get marked as such about half a year ago... But before we rush into yanking it out: importlib.metadata
requires python3.8 or a fancy requirements directive to pull in its backport, so its not such a simple drop-in replacement. There are also two other files in this repo that already use pkg_resources (
import pkg_resources |
import pkg_resources |
Lets kick this down the road a bit -- ill make GH issues to remove pkg_resources in each of the 3 repos.
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.
Got it, thanks for the clarifications. Not super critical as Python packaging evolves super slowly, so makes sense to just stay consistent with our other code.
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.
# Point API requests to the default endpoint | ||
Epidata.BASE_URL = "https://api.covidcast.cmu.edu/epidata" | ||
Epidata.BASE_URL = "https://api.covidcast.cmu.edu/epidata/api.php" |
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.
Epidata.BASE_URL = "https://api.covidcast.cmu.edu/epidata/api.php" | |
Epidata.BASE_URL = "https://api.covidcast.cmu.edu/epidata" |
whoops, i mustve edited the wrong version of the file which got api.php
back into the BASE_URL
* Remove usage of PHP alias in the Python client * Bump version * Update Python-packages/covidcast-py/setup.py * use python package-specific "user agent" string (#665) * Deprecate _async_fetch_epidata & update docs * Update changelog, re-regenerate docs * Handle deprecation warning in tests --------- Co-authored-by: melange396 <george.haff@gmail.com>
closes #660