Skip to content

feat(mlflow): resolve _log__ parameters in create_log_callback#2594

Draft
anevolbap wants to merge 4 commits into
pymc-labs:mainfrom
anevolbap:feat/1615-mlflow-resolve-log-transform
Draft

feat(mlflow): resolve _log__ parameters in create_log_callback#2594
anevolbap wants to merge 4 commits into
pymc-labs:mainfrom
anevolbap:feat/1615-mlflow-resolve-log-transform

Conversation

@anevolbap
Copy link
Copy Markdown
Contributor

@anevolbap anevolbap commented May 18, 2026

Summary

Auto-resolve _log__ parameter names in create_log_callback. Pass sigma for a HalfNormal and the callback maps it to sigma_log__ from draw.point on the first draw, then caches the mapping for the rest of sampling. Existing callers passing sigma_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_SUFFIXES documents the two caveats for follow-up PRs: append only scalar-valued transforms (mlflow.log_metric is scalar-only), and custom user transforms need a model handle to resolve (out of scope here). An inline comment on the log_metric call 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 with HalfNormal("sigma"), asks for parameters=["mu", "sigma"], asserts metrics under chain_0/mu and chain_0/sigma.
  • Unit tests on the resolver: exact-match wins, _log__ fallback, KeyError otherwise.
  • pre-commit clean.

`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
@anevolbap anevolbap marked this pull request as ready for review May 18, 2026 08:30
@github-actions github-actions Bot added enhancement New feature or request good first issue Good for newcomers . Doesn't require extensive knowledge of the repo and package labels May 18, 2026
@anevolbap anevolbap marked this pull request as draft May 18, 2026 08:41
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
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.89%. Comparing base (1a3f0d0) to head (7d9e487).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anevolbap anevolbap force-pushed the feat/1615-mlflow-resolve-log-transform branch 2 times, most recently from 7d9e487 to 804e932 Compare May 18, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request good first issue Good for newcomers . Doesn't require extensive knowledge of the repo and package mlflow tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatically handle <variable>_log__ and common transformations

1 participant