Skip to content

Conversation

@f-allian
Copy link
Collaborator

@f-allian f-allian commented Jan 30, 2026

  • In causal_testing/main.py, the save_results method now filters out tests marked with "skip": true in the test configuration, so only active tests are paired with their results and saved.

  • In tests/main_tests/test_main.py, both test_ctf and test_ctf_exception_silent now use only active tests (not skipped) when checking which tests passed, aligning the test logic with the updated main code.

  • Closes issue Misaligned test results when skip:true tests are present in causal tests #377

@f-allian f-allian self-assigned this Jan 30, 2026
@f-allian f-allian added the bug Something isn't working label Jan 30, 2026
@github-actions
Copy link

github-actions bot commented Jan 30, 2026

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ PYTHON black 32 0 0.95s
✅ PYTHON pylint 32 0 6.13s

See detailed report in MegaLinter reports

MegaLinter is graciously provided by OX Security

@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.87%. Comparing base (32fbf15) to head (178a465).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #378   +/-   ##
=======================================
  Coverage   97.86%   97.87%           
=======================================
  Files          27       27           
  Lines        1544     1550    +6     
=======================================
+ Hits         1511     1517    +6     
  Misses         33       33           
Files with missing lines Coverage Δ
causal_testing/main.py 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd9241f...178a465. Read the comment docs.

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

@f-allian f-allian marked this pull request as ready for review January 30, 2026 13:02
@f-allian f-allian requested a review from jmafoster1 January 30, 2026 13:02
Copy link
Collaborator

@jmafoster1 jmafoster1 left a comment

Choose a reason for hiding this comment

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

This solution means that skipped tests don't make it into the results file. Personally, I'd prefer they were still there so we have a record of all the test outcomes so we know if any where skipped (as opposed to not generated/considered). It'd be good to preserve order too if we can, although putting skipped test cases at the end is more acceptable than not having them there at all.

@f-allian
Copy link
Collaborator Author

f-allian commented Feb 2, 2026

@jmafoster1

Is this what you're after? For example, a causal test case with skip:true:

    {
      "name": "treatment --> outcome",
      "estimator": "LinearRegressionEstimator",
      "estimate_type": "coefficient",
      "effect": "direct",
      "treatment_variable": "treatment",
      "formula": "treatment ~ outcome",
      "alpha": 0.05,
      "skip": true,
      "expected_effect": {
        "treatment": "SomeEffect"
      }
}

now has a corresponding result:

  {
    "name": "treatment --> outcome",
    "estimate_type": "coefficient",
    "effect": "direct",
    "treatment_variable": "treatment",
    "expected_effect": {
      "treatment": "SomeEffect"
    },
    "formula": null,
    "alpha": 0.05,
    "skip": true,
    "passed": null,
    "result": {
      "status": "skipped",
      "reason": "Test marked as skip:true in the causal test config file.
    }
}  

@f-allian f-allian requested a review from jmafoster1 February 2, 2026 12:40
Copy link
Collaborator

@jmafoster1 jmafoster1 left a comment

Choose a reason for hiding this comment

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

This is a nice solution. I've suggested a couple of potential minor improvements

"effect": test_config.get("effect", "direct"),
"treatment_variable": test_config["treatment_variable"],
"expected_effect": test_config["expected_effect"],
"formula": None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"formula": None,
"formula": test_config.get("formula"),

Just in case the user has specified a formula in the test config.

| result.effect_estimate.to_dict()
| (result.adequacy.to_dict() if result.adequacy else {})
if result.effect_estimate
else {"error": result.error_message}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
else {"error": result.error_message}
else {"status": "error", "reason": result.error_message}

I quite liked the status/reason format. It might even be nice to include it as part of the "normal" output as well, e.g. "status": "passed/failed". Then we can just query test["result"]["status"]

)

output = {
"name": test_config["name"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be sensible to move the commonalities between the if and the else into a single entry and then update the bits that differ in order to make the code a bit DRY-er? Less to maintain in the future...

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants