feat(mlflow): resolve _log__ parameters in create_log_callback#2594
Draft
anevolbap wants to merge 4 commits into
Draft
feat(mlflow): resolve _log__ parameters in create_log_callback#2594anevolbap wants to merge 4 commits into
_log__ parameters in create_log_callback#2594anevolbap wants to merge 4 commits into
Conversation
`create_log_callback` previously required users to pass the sampler-level name of a variable (e.g. `sigma_log__` for a `HalfNormal`). Pass the model-level name (`sigma`) and the callback now resolves it from `draw.point` keys on the first draw. Existing callers passing the transformed name still work because exact matches take priority. The transform suffix list starts with `_log__` only per pymc-labs#1615. A comment on `_TRANSFORM_SUFFIXES` documents the extension path for `_logodds__`, `_interval__`, `_ordered__`, `_simplex__`, and others. Closes pymc-labs#1615
Two notes for future contributors: only scalar-valued transforms are safe to append because `mlflow.log_metric` is scalar-only, and custom user transforms are out of scope because their `name` is unknown at module load time.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2594 +/- ##
==========================================
- Coverage 93.90% 93.89% -0.01%
==========================================
Files 92 92
Lines 14089 14102 +13
==========================================
+ Hits 13230 13241 +11
- Misses 859 861 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7d9e487 to
804e932
Compare
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
Auto-resolve
_log__parameter names increate_log_callback. Passsigmafor aHalfNormaland the callback maps it tosigma_log__fromdraw.pointon the first draw, then caches the mapping for the rest of sampling. Existing callers passingsigma_log__keep working because the resolver prefers exact matches.Scope is
_log__only per the issue's "good first start" note. The comment block on_TRANSFORM_SUFFIXESdocuments the two caveats for follow-up PRs: append only scalar-valued transforms (mlflow.log_metricis scalar-only), and custom user transforms need a model handle to resolve (out of scope here). An inline comment on thelog_metriccall flags the scalar-only constraint for future maintainers.Closes #1615.
Test plan
pytest tests/test_mlflow.py -k "resolve or logging_callback or callback_raises"(6 tests) passes locally.test_logging_callback_resolves_log_transform: model withHalfNormal("sigma"), asks forparameters=["mu", "sigma"], asserts metrics underchain_0/muandchain_0/sigma._log__fallback, KeyError otherwise.pre-commitclean.