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

Fix python client's user-agent version #1431

Closed
melange396 opened this issue May 9, 2024 · 1 comment · Fixed by #1436
Closed

Fix python client's user-agent version #1431

melange396 opened this issue May 9, 2024 · 1 comment · Fixed by #1436
Labels
bug code health readability, maintainability, best practices, etc logs and monitoring logging, monitoring, alerting python client changes the Python client

Comments

@melange396
Copy link
Collaborator

Change the way the python client determines its own version number.

The current implementation uses importlib to get the "installed version" of the package and set it in the user-agent string. This is apparently fragile enough that is misreporting its version number to the API server (in a number of places on our own systems, no less!). Maybe it worked better in the past before it was updated to stop using pkg_resources. ¯\_(ツ)_/¯

On a single one of our automation servers, different jobs make requests that announce user-agents of both delphi_epidata/0.0.11 (Python) and delphi_epidata/0.0.12 (Python) (among others!). To make it even more ridiculous, the addition of the " (Python)" suffix didn't come around until version 4.1.0. This does suggest the possibility of a misconfiguration of some sort on the machine, but the way the client is implemented makes that even more difficult to track down.

Unless someone has a better idea, we can keep something like the existing try structure and attempt to get the version from the package but fall back to the "0.script" text if it doesnt work, or we could just be lazy and add delphi_epidata.py to the bumpversion config.

@melange396 melange396 added bug python client changes the Python client code health readability, maintainability, best practices, etc logs and monitoring logging, monitoring, alerting labels May 9, 2024
@dshemetov
Copy link
Contributor

dshemetov commented May 18, 2024

So of course, I end up finding the perfect guide for this (by the Python Packaging Authority) only after we fix it, but it's all good because this guide provides many approaches and we ended up doing approach (2) they recommend here single-sourcing the package version. And interestingly, approach (5) is the one we did previously and it has this caveat:

Be aware that the importlib.metadata API only knows about what’s in the installation metadata, which is not necessarily the code that’s currently imported.

So maybe that's the edge case we ran into 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug code health readability, maintainability, best practices, etc logs and monitoring logging, monitoring, alerting python client changes the Python client
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants