Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 5, 2025

Integrate new MMM class with MLflow

Plan:

  • Explore repository structure and understand the issue
  • Identify that there are two MMM classes: old (mmm.py) and new (multidimensional.py)
  • Understand current mlflow.py only patches the old MMM class
  • Import the new multidimensional MMM class in mlflow.py
  • Apply the same patch_mmm_fit to the new MMM class
  • Add or update tests for the new MMM integration
  • Verify changes follow minimal modification principles
  • Ensure backward compatibility
  • Fix pre-commit check issues

Summary

Successfully integrated the new multidimensional MMM class with MLflow autologging using the existing patch_mmm_fit function. The solution is minimal and follows best practices.

Changes Made

Production Code (pymc_marketing/mlflow.py):

  • Added import of MultiDimensionalMMM from pymc_marketing.mmm.multidimensional
  • Applied patch_mmm_fit to MultiDimensionalMMM.fit when log_mmm=True
  • Total: 2 lines added

Tests (tests/test_mlflow.py):

  • Added import and teardown logic for MultiDimensionalMMM
  • Added test fixtures: multidimensional_mmm(), toy_multidim_X(), toy_multidim_y()
  • Added test_autolog_multidimensional_mmm() to verify integration
  • Fixed unused variable linting issue
  • Total: 81 lines added

Pre-commit Checks

ruff check: All checks passed
ruff format: Code properly formatted
mypy: No type errors
trailing whitespace: None found
end-of-file: Proper newlines

Both the old MMM class and the new multidimensional MMM class now have identical MLflow integration.

Original prompt

This section details on the original issue you should resolve

<issue_title>Integrate new MMM class with MLflow</issue_title>
<issue_description>This would be integration like with the other MMM class which has a patched fit method</issue_description>

Comments on the Issue (you are @copilot in this section)

@kskyten I'm unclear on what the specific missing functionality is. I ran the MMM auto logging example from the mlflow module, and it does produce outputs to mlflow. @williambdean > I'm unclear on what the specific missing functionality is. I ran the MMM auto logging example from the mlflow module, and it does produce outputs to mlflow.

Yes, you're right. There is a base functionality that comes from the logging for all PyMC models.

I was think about some specific to the new MMM class just like with the old one:

if log_mmm:
MMM.fit = patch_mmm_fit(MMM.fit)

def patch_mmm_fit(fit: Callable) -> Callable:
@wraps(fit)
def new_fit(self, *args, **kwargs):
log_mmm_configuration(self)
idata = fit(self, *args, **kwargs)
log_inference_data(idata, save_file="idata.nc")
return idata
return new_fit

Do you have any thoughts on what would be helpful? @kskyten </comment_new>
<comment_new>@williambdean
Lets start with using current patch_fit for the fit method</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


📚 Documentation preview 📚: https://pymc-marketing--2072.org.readthedocs.build/en/2072/

@github-actions github-actions bot added the tests label Nov 5, 2025
@williambdean
Copy link
Contributor

@copilot please ensure that the pre-commit checks pass ...

Copilot AI changed the title [WIP] Integrate new MMM class with MLflow Integrate multidimensional MMM class with MLflow autologging Nov 5, 2025
Copilot AI requested a review from williambdean November 5, 2025 16:57
Copilot finished work on behalf of williambdean November 5, 2025 16:57
Copy link
Contributor Author

Copilot AI commented Nov 5, 2025

@copilot please ensure that the pre-commit checks pass ...

Fixed the pre-commit check issue. The unused variable idata in the test has been removed. All checks now pass:

  • ✅ ruff check
  • ✅ ruff format
  • ✅ mypy
  • ✅ trailing whitespace
  • ✅ end-of-file

Commit: 979a9b6

Copilot finished work on behalf of williambdean November 5, 2025 17:03
@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.57%. Comparing base (f59d7e3) to head (0a8422f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2072   +/-   ##
=======================================
  Coverage   92.56%   92.57%           
=======================================
  Files          68       68           
  Lines        9420     9422    +2     
=======================================
+ Hits         8720     8722    +2     
  Misses        700      700           

☔ 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.

Copy link
Contributor

@cetagostini cetagostini left a comment

Choose a reason for hiding this comment

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

La leyenda viviente!!!!

@juanitorduz juanitorduz marked this pull request as ready for review November 18, 2025 09:03
@juanitorduz juanitorduz merged commit 9cc82f4 into main Nov 18, 2025
38 checks passed
@juanitorduz juanitorduz deleted the copilot/integrate-new-mmm-class branch November 18, 2025 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good second issue Bit more involved but still doable for newcomers mlflow MMM no releasenotes tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate new MMM class with MLflow

4 participants