Use pathmc for causal-discovery tooling#2642
Draft
cetagostini wants to merge 1 commit into
Draft
Conversation
Re-points the optional causal-discovery tools at the standalone pathmc library (pymc-labs/pathmc#307), so the discovery algorithm and DAG→model builder are maintained in one place. Everything works the same — the names resolve to the same implementations — but they now come from pathmc. - mmm/causal.py: TBFPC, BuildModelFromDAG, and TestResult are re-exported lazily from pathmc via a module-level __getattr__ (PEP 562). Importing the module no longer requires pathmc; only accessing those names does, with an actionable error pointing at the [dag] extra. CausalGraphModel (dowhy-based backdoor adjustment) stays here — it is used by the core MMM and pathmc provides its own native identification rather than wrapping dowhy. - causal_utils.py: same_markov_equivalence_class_CPdag becomes a thin wrapper over pathmc.same_markov_equivalence_class (no more pydot dependency). - pyproject: add pathmc to the [dag] extra. - tests: the discovery behavior is now covered exhaustively in pathmc, so the duplicated TBFPC/BuildModelFromDAG/Markov-equivalence tests are removed here; what remains is the CausalGraphModel suite plus wiring tests that verify the re-exports resolve to pathmc (skipped when pathmc is not installed). DRAFT — must not be merged until pathmc ships the discovery front end (pymc-labs/pathmc#307, #349) AND pymc-marketing migrates to PyMC 6, because pathmc requires PyMC >= 6 and pymc-marketing currently pins pymc < 6. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2642 +/- ##
==========================================
- Coverage 94.19% 93.05% -1.15%
==========================================
Files 100 100
Lines 15384 14835 -549
==========================================
- Hits 14491 13804 -687
- Misses 893 1031 +138 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
As this is a breaking change, I just added it to the v1.0 milestone |
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.
Warning
Draft — do not merge yet. This depends on:
pymc>=6, while pymc-marketing currently pinspymc<6, so the two cannot be installed together until then.Once both land, bump the
pathmcfloor in thedagextra to the release that includes the discovery tooling and flip this out of draft.Description
Re-points the optional causal-discovery tooling at the standalone pathmc library, so the discovery algorithm and DAG→model builder are maintained in one place (pathmc now owns PyMC-Labs' path-analysis / structural-causal-modeling stack). Behavior is unchanged — the names resolve to the same implementations — but they now come from pathmc.
mmm/causal.py—TBFPC,BuildModelFromDAG, andTestResultare re-exported lazily from pathmc via a module-level__getattr__(PEP 562). Importing the module no longer requires pathmc (so the core MMM import is unaffected); only accessing those names triggers the import, with an actionable error pointing atpip install pymc-marketing[dag].CausalGraphModel(dowhy-based backdoor adjustment) stays here — it is imported by the core MMM and pathmc deliberately provides its own native identification rather than wrapping dowhy.causal_utils.py—same_markov_equivalence_class_CPdagbecomes a thin wrapper overpathmc.same_markov_equivalence_class(drops thepydotdependency; pathmc uses a dependency-free DOT reader).pyproject.toml— addspathmcto the[dag]extra.TBFPC/BuildModelFromDAG/ Markov-equivalence tests are removed here; what remains is theCausalGraphModelsuite (unchanged) plus wiring tests that verify the re-exports resolve to pathmc (skipped when pathmc is not installed, i.e. on PyMC 5 CI).Related Issue
Checklist
[dag]extra)🤖 Generated with Claude Code
📚 Documentation preview 📚: https://pymc-marketing--2642.org.readthedocs.build/en/2642/