Skip to content

Conversation

@elbeejay
Copy link
Contributor

@elbeejay elbeejay commented Feb 10, 2023

Aims to close #83 by adding a string to the header in our HTTP GET requests that identifies the python dataretrieval package and version making the request.

Checked functionality against what the R package does and this follows that convention. The "user-agent" information sent to the server is python-dataretrieval/<version> which is consistent with the approach in R.

Wrote some tests for this logic.


@thodson-usgs can you confirm that my syntax for getting the current version is correct? We don't currently have a _version.py file so in the interest of having the code be more resilient there's currently try-except logic to substitute "version-unknown" when it is not available. But I am hoping that once we do the next release the code dataretrieval.__version__ will successfully return the version information as a string. Used similar logic to automatically set the versions for the hosted documentation that gets built each time a commit is made.

@elbeejay elbeejay added the enhancement New feature or request label Feb 10, 2023
@elbeejay elbeejay marked this pull request as ready for review February 13, 2023 21:32
@thodson-usgs
Copy link
Collaborator

thodson-usgs commented Feb 14, 2023

@elbeejay, something is wrong with my understanding. I swore that setuptools_scm writes _version.py and that was read by dataretrieval.__version__ but now I'm getting an AttributeError. I'll need to debug this further.

@elbeejay
Copy link
Contributor Author

Updated the versioning references based on the documentation for setuptools_scm. This resulted in the retirement of support for Python 3.7, as the best practices for both obtaining the package version at runtime, as well as the dynamic loading of version information for the Sphinx documentation (per setuptools_scm documentation), require the use of the standard library functionality importlib.metadata, which was added in Python 3.8.

Copy link
Collaborator

@thodson-usgs thodson-usgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revise __init__.py

Copy link
Collaborator

@thodson-usgs thodson-usgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks @elbeejay!

@thodson-usgs thodson-usgs merged commit 2365b5f into DOI-USGS:master Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a user agent for GET requests

2 participants