Skip to content

Add HTTP headers to all requests - #1342

Merged
PGijsbers merged 2 commits into
developfrom
enh/add-user-agent
Jul 10, 2024
Merged

Add HTTP headers to all requests#1342
PGijsbers merged 2 commits into
developfrom
enh/add-user-agent

Conversation

@PGijsbers

@PGijsbersPGijsbers commented Jul 9, 2024

Copy link
Copy Markdown
Collaborator

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

codecov-commenter commented Jul 9, 2024

Copy link
Copy Markdown

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
Copy Markdown
CollaboratorAuthor

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.

@LennartPuruckerLennartPurucker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@LennartPurucker

Copy link
Copy Markdown
Contributor

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

@PGijsbers
PGijsbers merged commit e4e6f50 into developJul 10, 2024
@PGijsbers
PGijsbers deleted the enh/add-user-agent branch July 10, 2024 08:15
@PGijsbersPGijsbers added this to the 0.15.0 milestone Sep 12, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@PGijsbers@codecov-commenter@LennartPurucker