Skip to content

Use pathmc for causal-discovery tooling#2642

Draft
cetagostini wants to merge 1 commit into
mainfrom
use-pathmc-for-causal-discovery
Draft

Use pathmc for causal-discovery tooling#2642
cetagostini wants to merge 1 commit into
mainfrom
use-pathmc-for-causal-discovery

Conversation

@cetagostini

@cetagostini cetagostini commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Warning

Draft — do not merge yet. This depends on:

  1. pathmc shipping the causal-discovery front end (Port causal-discovery tools from PyMC-Marketing into pathmc pathmc#307, PR Add causal-discovery front end (TBFPC, CPDAG, DAG→model) pathmc#349), and
  2. pymc-marketing migrating to PyMC 6 — pathmc requires pymc>=6, while pymc-marketing currently pins pymc<6, so the two cannot be installed together until then.

Once both land, bump the pathmc floor in the dag extra 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.pyTBFPC, BuildModelFromDAG, and TestResult are 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 at pip 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.pysame_markov_equivalence_class_CPdag becomes a thin wrapper over pathmc.same_markov_equivalence_class (drops the pydot dependency; pathmc uses a dependency-free DOT reader).
  • pyproject.toml — adds pathmc to the [dag] extra.
  • tests — the discovery behavior is now covered exhaustively in pathmc (159 tests). The duplicated TBFPC / BuildModelFromDAG / Markov-equivalence tests are removed here; what remains is the CausalGraphModel suite (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

  • Pre-commit linting/style checks (ruff/ruff-format) pass on the changed files
  • Tests included (CausalGraphModel suite retained; pathmc re-export wiring tests added; discovery behavior tested upstream in pathmc)
  • Documentation updated (module docstrings explain the pathmc move and the [dag] extra)

Note: the pathmc-backed tests skip in current CI because pathmc cannot be installed alongside PyMC 5. End-to-end validation on this side runs once pymc-marketing is on PyMC 6; the behavior itself is validated by pathmc's own suite.

🤖 Generated with Claude Code


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

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

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.05%. Comparing base (649547e) to head (6e80605).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
pymc_marketing/causal_utils.py 40.00% 3 Missing ⚠️
pymc_marketing/mmm/causal.py 66.66% 3 Missing ⚠️
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.
📢 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.

@juanitorduz juanitorduz added this to the 1.0 milestone Jun 24, 2026
@juanitorduz

Copy link
Copy Markdown
Collaborator

As this is a breaking change, I just added it to the v1.0 milestone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants