feat(mlflow): add StaticTokenAuth for HTTP bearer-token servers - #338
Open
HCookie wants to merge 1 commit into
Open
feat(mlflow): add StaticTokenAuth for HTTP bearer-token servers#338HCookie wants to merge 1 commit into
HCookie wants to merge 1 commit into
Conversation
HCookie
force-pushed
the
feat/custom-mlflow
branch
from
August 4, 2026 19:48
36c37c5 to
c316291
Compare
Add StaticTokenAuth, an AuthBase that authenticates with a static, pre-issued bearer token instead of the interactive Keycloak refresh-token flow. It reuses the existing on-disk token store (~/.anemoi/mlflow-token.json), keyed by server URL, so a token supplied once via login() is remembered across sessions. AnemoiMlflowClient gains a `static_token` parameter: pass a token string to use it directly, or True to load a previously saved static token; otherwise it falls back to TokenAuth as before. This enables using anemoi-utils against MLflow servers that accept a long-lived HTTP access/bearer token. - auth.py: StaticTokenAuth, shared enabled_guard decorator, ServerConfig gains a static_token field (legacy load_config() contract preserved) - client.py: static_token parameter wiring - tests: StaticTokenAuth unit tests + client selection-logic tests
HCookie
force-pushed
the
feat/custom-mlflow
branch
from
August 4, 2026 19:49
c316291 to
b31c03e
Compare
HCookie
marked this pull request as ready for review
August 4, 2026 19:54
gmertes
reviewed
Aug 21, 2026
gmertes
left a comment
Member
There was a problem hiding this comment.
Is there any benefit to sharing the same token file? Given that the new class is already standalone and not inheriting from the other one, would it not make more sense to also keep the token file separate?
I'm also not sure if the login logic will even work with a shared file, because the login command in anemoi-training will iterate over all urls in the store and attempt to login to them. Let's discuss when you're back from leave?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
StaticTokenAuthsoanemoi.utils.mlflowcan authenticate to MLflow servers that accept a static, pre-issued HTTP bearer token, instead of only the interactive Keycloak refresh-token flow (TokenAuth).What's included
StaticTokenAuth(auth.py): anAuthBasethat stores the token inMLFLOW_TRACKING_TOKEN(so MLflow sendsAuthorization: Bearer <token>). It reuses the existing on-disk store (~/.anemoi/mlflow-token.json), keyed by server URL, so a token supplied once vialogin()is remembered across sessions. No token server / refresh flow.AnemoiMlflowClient(static_token=...)(client.py): pass a token string to use it directly,Trueto load a previously saved static token, or leave unset to fall back toTokenAuth(unchanged default behaviour).enabled_guarddecorator (factored out ofTokenAuth);ServerConfiggains astatic_tokenfield. The deprecatedload_config()contract is preserved (the new field is excluded from its output).StaticTokenAuthunit tests + client selection-logic tests (34 pass locally; pre-commit clean).Usage
Notes / caveats
POST, so a read-only token may be insufficient.Backwards compatibility
No behaviour change unless
static_tokenis passed;TokenAuthremains the default. Draft pending review of the API surface (static_token: str | bool).