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

Add HTTP headers to all requests #1342

Merged
merged 2 commits into from
Jul 10, 2024
Merged

Add HTTP headers to all requests #1342

merged 2 commits into from
Jul 10, 2024

Conversation

PGijsbers
Copy link
Collaborator

@PGijsbers PGijsbers commented Jul 9, 2024

This allows us to better understand the traffic we see to our server API. It is not identifiable to a person.

Motivated after seeing large spikes in traffic recently. Some of them coming from requests/1.x.x agents - which leaves us wondering if this is from Python API users (potentially indirectly through e.g., the automlbenchmark), or scripts/bots that don't identify themselves as such.

On top of this PR, I think we might want to make our user-agent configurable so that services building on top of openml-python can identify themselves (e.g., automl benchmark, experiment bots). But I don't want to get into that right now.

I updated the unit tests that would otherwise crash. I explicitly did not add a check for the agent with these tests.
To me it feels that would be outside the scope of those tests. In general, it's a thin line the way its set up - should our tests even fail if they would just keyword argument instead of a positional one? But that too felt out of scope, so I change it to a (in my opinion) slightly better version of the same tests.

I do not feel this warrants its own unit test. If I should make one, could you recommend an approach? Just mocking the requests library and then calling _api_call for all types of requests? I just thought that wasn't particularly useful.

This allows us to better understand the traffic we see to our API.
It is not identifiable to a person.
@codecov-commenter
Copy link

codecov-commenter commented Jul 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.82%. Comparing base (923b49d) to head (1a0e654).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #1342       +/-   ##
============================================
+ Coverage    32.94%   83.82%   +50.87%     
============================================
  Files           38       38               
  Lines         5254     5261        +7     
============================================
+ Hits          1731     4410     +2679     
+ Misses        3523      851     -2672     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@PGijsbers
Copy link
Collaborator Author

pre-commit fail is a false negative, as the pre-commit.ci job does not fail (and neither does my local). Speaking of, we can probably remove the pre-commit/run-all-files workflow. I do not see what it accomplishes now that we have pre-commit.ci.

@PGijsbers PGijsbers requested a review from LennartPurucker July 9, 2024 13:54
Copy link
Contributor

@LennartPurucker LennartPurucker left a comment

Choose a reason for hiding this comment

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

LGTM!

@LennartPurucker
Copy link
Contributor

+1, let's remove pre-commit/run-all-files.

@PGijsbers PGijsbers merged commit e4e6f50 into develop Jul 10, 2024
13 of 15 checks passed
@PGijsbers PGijsbers deleted the enh/add-user-agent branch July 10, 2024 08:15
@PGijsbers PGijsbers added this to the 0.15.0 milestone Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants