Skip to content

New and Improved CTF Frontend Entrypoint #309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Mar 4, 2025
Merged

New and Improved CTF Frontend Entrypoint #309

merged 19 commits into from
Mar 4, 2025

Conversation

f-allian
Copy link
Contributor

@f-allian f-allian commented Feb 21, 2025

  • This PR contains a feature/enhancement of the CTF by means of a new front-end entry-point using a traditional main.py & __main__.py convention.
  • The goal is to replace the now-outdated CausalTestSuite and JSONFrontEnd modules.
  • This new method removes redundant/legacy code in the framework, enables easier querying of dataframes, and removes unnecessary input configurations (e.g. variables.json) in the DAFNI module since these are intuitively defined the .dot file.
  • Closes Issues Remove Legacy Code #302, Create a Main Entry Point to the CTF #303
  • Note: this is a WIP

Examples

1. Using the CLI:

python -m causal_testing \
    --dag_path path/to/dag.dot \
    --data_paths path/to/data.csv \
    --test_config path/to/tests.json \
    --output path/to/results.json \
    --query "cum_deaths > 20" 

2. Using the Python API

from causal_testing.main import CausalTestingFramework, CausalTestingPaths

# 1. Set up paths
paths = CausalTestingPaths(
    dag_path="path/to/dag.dot",
    data_paths=["path/to/data.csv"],
    test_config_path="path/to/tests.json",
    output_path="path/to/results.json"
)

# 2. Create framework instance
framework = CausalTestingFramework(
    paths=paths,
    ignore_cycles=False,
    query="cum_deaths > 20"
)

# 3. Run the analysis
framework.setup()
framework.load_tests()
results = framework.run_tests()
framework.save_results(results)

Previous Method:

image

New Method:

image

@f-allian f-allian added the enhancement New feature or request label Feb 21, 2025
@f-allian f-allian self-assigned this Feb 21, 2025
Copy link

github-actions bot commented Feb 21, 2025

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ PYTHON black 31 0 0.94s
✅ PYTHON pylint 31 0 5.34s

See detailed report in MegaLinter reports

MegaLinter is graciously provided by OX Security

Copy link

codecov bot commented Feb 21, 2025

Codecov Report

Attention: Patch coverage is 82.83262% with 40 lines in your changes missing coverage. Please review.

Project coverage is 93.59%. Comparing base (15fa8ee) to head (5bdb82e).
Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
causal_testing/main.py 82.46% 37 Missing ⚠️
causal_testing/__main__.py 83.33% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #309      +/-   ##
==========================================
- Coverage   94.64%   93.59%   -1.06%     
==========================================
  Files          25       27       +2     
  Lines        1345     1577     +232     
==========================================
+ Hits         1273     1476     +203     
- Misses         72      101      +29     
Files with missing lines Coverage Δ
causal_testing/specification/causal_dag.py 99.50% <100.00%> (+<0.01%) ⬆️
causal_testing/testing/metamorphic_relation.py 100.00% <ø> (ø)
causal_testing/__main__.py 83.33% <83.33%> (ø)
causal_testing/main.py 82.46% <82.46%> (ø)

... and 3 files with indirect coverage changes


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 c5d6a8f...5bdb82e. Read the comment docs.

@f-allian f-allian requested a review from jmafoster1 February 27, 2025 10:21
@jmafoster1
Copy link
Contributor

One thing I have changed here is that, where you'd changed the treatments to be specified as "mutations": ["max_doses"], I've changed it to "treatment_variable": "max_doses" since we only ever support one treatment anyway.

@jmafoster1
Copy link
Contributor

The only exception to that is where we're doing the temporal estimation, but that's specified with the treatment_strategy field anyway

Copy link
Contributor

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

I reckon we're about ready. I don't think there's too much point in testing the other exceptions in main.py just to make codecov happy.

@jmafoster1 jmafoster1 marked this pull request as ready for review March 4, 2025 11:53
@f-allian f-allian changed the title DRAFT: New and Improved CTF Frontend Entrypoint New and Improved CTF Frontend Entrypoint Mar 4, 2025
@f-allian f-allian merged commit acb62d4 into main Mar 4, 2025
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants