Skip to content

DRAFT: use web-search api-params - #125

Merged
philbudne merged 7 commits into
mediacloud:mainfrom
philbudne:feature-api-params
Sep 26, 2026
Merged

philbudne merged 7 commits into
mediacloud:mainfrom
philbudne:feature-api-params

Conversation

@philbudne

@philbudne philbudne commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

draft using web-search search/api-params call to:

  1. check if a newer version of this library available/recommended
  2. set rate limit according to the user's actual rate limit!

To avoid confusion (and adhere to comments) this version goes thru some gyrations to allow the user to patch URL and rate limit AFTER instantiating an API object, but not as many as my first version (which implemented caching). Users who create a new API object for each call they make will fetch the api-params on each request!

Open issues:

  1. Not fully tested (tests are SLOW under rate limiting!!!)
  2. Actual rate limit capped by RATE_LIMIT_PER_MINUTE to avoid admins from running at very high rates
  3. Need to settle on policy for warning about new releases (ignore fix releases?)

Update api-client github URL
Discuss updating server API_PYTHON_CLIENT info
@philbudne

Copy link
Copy Markdown
Contributor Author

NOTE! The api-params call is currently only available from the staging web-search server!

fixes mediacloud#123

* Use admin connection for higher rates
* Force higher rates for directory (rates not enforced)
* Keep API objects around in search tests to keep rate limiter state
* Removed all sleeps!
@rahulbot
rahulbot self-requested a review September 22, 2026 07:50

@rahulbot rahulbot 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. Clever approach to dynamically setting rate limit based on server allowance for user. I'm not sure about the changes from _search to _admin_search... is that for speed? Just want to make sure it doesn't leave us exposed to somehow breaking regular user searches. Otherwise typing additions look good too.

@philbudne

philbudne commented Sep 22, 2026 via email

Copy link
Copy Markdown
Contributor Author

* Restarted with version from main
* Kept global API sessions from new version
* Added check for MC_API_TEST_FAST (runs in about 20 sec vs 20 minutes)
   (by modifying contents of self._search vs using _admin_search)
* Made test_story explicitly use _user_search
* Kept test_story_admin (explicitly using _admin_search)
* Kept addition of collections arg in stories_by_source_over_interval tests
@philbudne
philbudne merged commit 12cb716 into mediacloud:main Sep 26, 2026
0 of 2 checks passed
@philbudne
philbudne deleted the feature-api-params branch September 26, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants