Skip to content

Commit acb62d4

Browse files
authored
Merge pull request #309 from CITCOM-project/f-allian/front-end
New and Improved CTF Frontend Entrypoint
2 parents c5d6a8f + 5bdb82e commit acb62d4

File tree

14 files changed

+937
-204
lines changed

14 files changed

+937
-204
lines changed

README.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,42 @@ For more information on how to use the Causal Testing Framework, please refer to
5656
>[!NOTE]
5757
>We recommend you use a 64 bit OS (standard in most modern machines) as we have had reports of the installation crashing on some 32 bit Debian installations.
5858
59+
## Usage
60+
>[!NOTE]
61+
> Example usage can be found in the `examples` directory.
62+
63+
1. To run the causal testing framework, you need some runtime data from your system, some causal test cases, and a causal DAG that specifies the expected causal relationships between the variables in your runtime data (and any other relevant variables that are _not_ recorded in the data but are known to be relevant).
64+
65+
2. If you do not already have causal test cases, you can convert your causal DAG to causal tests by running the following command.
66+
67+
```
68+
python causal_testing/testing/metamorphic_relation.py --dag_path $PATH_TO_DAG --output_path $PATH_TO_TESTS
69+
```
70+
71+
3. You can now execute your tests by running the following command.
72+
```
73+
python -m causal_testing --dag_path $PATH_TO_DAG --data_paths $PATH_TO_DATA --test_config $PATH_TO_TESTS --output $OUTPUT
74+
```
75+
The results will be saved for inspection in a JSON file located at `$OUTPUT`.
76+
In the future, we hope to add a visualisation tool to assist with this.
77+
5978
## How to Cite
6079
If you use our framework in your work, please cite the following:
6180

62-
``This research has used version X.Y.Z (software citation) of the
81+
``This research has used version X.Y.Z (software citation) of the
6382
Causal Testing Framework (paper citation).``
6483

65-
The paper citation should be the Causal Testing Framework [paper](https://dl.acm.org/doi/10.1145/3607184),
84+
The paper citation should be the Causal Testing Framework [paper](https://dl.acm.org/doi/10.1145/3607184),
6685
and the software citation should contain the specific Figshare [DOI](https://orda.shef.ac.uk/articles/software/CITCOM_Software_Release/24427516) of the version used in your work.
6786

6887

6988

7089
<details>
7190
<summary><b>BibTeX Citations</b></summary>
72-
91+
7392
<details>
7493
<summary>Paper</summary>
75-
94+
7695
```
7796
@ARTICLE{Clark_etal_2023,
7897
author = {Clark, Andrew G. and Foster, Michael and Prifling, Benedikt and Walkinshaw, Neil and Hierons, Robert M.
@@ -89,10 +108,10 @@ and the software citation should contain the specific Figshare [DOI](https://ord
89108
```
90109

91110
</details>
92-
111+
93112
<details>
94113
<summary>Software (example)</summary>
95-
114+
96115
```
97116
@ARTICLE{Wild2023,
98117
author = {Foster, Michael and Clark, Andrew G. and Somers, Richard and Wild, Christopher and Allian, Farhad and Hierons, Robert M. and Wagg, David and Walkinshaw, Neil},
@@ -114,15 +133,15 @@ To contribute to our work, please ensure the following:
114133
1. [Fork the repository](https://help.github.com/articles/fork-a-repo/) into your own GitHub account, and [clone](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) it to your local machine.
115134
2. [Create a new branch](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository) in your forked repository. Give this branch an appropriate name, and create commits that describe the changes.
116135
3. [Push your changes](https://docs.github.com/en/get-started/using-git/pushing-commits-to-a-remote-repository) to your new branch in your remote fork, compare with `CausalTestingFramework/main`, and ensure any conflicts are resolved.
117-
4. Create a draft [pull request](https://docs.github.com/en/get-started/quickstart/hello-world#opening-a-pull-request) from your branch, and ensure you have [linked](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls) it to any relevant issues in your description.
136+
4. Create a draft [pull request](https://docs.github.com/en/get-started/quickstart/hello-world#opening-a-pull-request) from your branch, and ensure you have [linked](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls) it to any relevant issues in your description.
118137

119138
We use the [unittest]() module to develop our tests and the [pytest](https://pytest.org/en/latest/) framework as our test discovery, [pylint](https://pypi.org/project/pylint/) for our code analyser, and [black](https://pypi.org/project/black/) for our code formatting.
120139
To find the other (optional) developer dependencies, please check `pyproject.toml`.
121140

122141

123142

124-
## Acknowledgements
143+
## Acknowledgements
125144

126145
The Causal Testing Framework is supported by the UK's Engineering and Physical Sciences Research Council (EPSRC),
127-
with the project name [CITCOM](https://gow.epsrc.ukri.org/NGBOViewGrant.aspx?GrantRef=EP/T030526/1) - "_Causal Inference for Testing of Computational Models_"
146+
with the project name [CITCOM](https://gow.epsrc.ukri.org/NGBOViewGrant.aspx?GrantRef=EP/T030526/1) - "_Causal Inference for Testing of Computational Models_"
128147
under the grant EP/T030526/1.

causal_testing/__main__.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""This module contains the main entrypoint functionality to the Causal Testing Framework."""
2+
3+
import logging
4+
from .main import setup_logging, parse_args, CausalTestingPaths, CausalTestingFramework
5+
6+
7+
def main() -> None:
8+
"""
9+
10+
Main entry point for the Causal Testing Framework
11+
12+
"""
13+
14+
# Parse arguments
15+
args = parse_args()
16+
17+
# Setup logging
18+
setup_logging(args.verbose)
19+
20+
# Create paths object
21+
paths = CausalTestingPaths(
22+
dag_path=args.dag_path,
23+
data_paths=args.data_paths,
24+
test_config_path=args.test_config,
25+
output_path=args.output,
26+
)
27+
28+
# Create and setup framework
29+
framework = CausalTestingFramework(paths, ignore_cycles=args.ignore_cycles, query=args.query)
30+
framework.setup()
31+
32+
# Load and run tests
33+
framework.load_tests()
34+
35+
if args.batch_size > 0:
36+
logging.info(f"Running tests in batches of size {args.batch_size}")
37+
results = framework.run_tests_in_batches(batch_size=args.batch_size, silent=args.silent)
38+
else:
39+
logging.info("Running tests in regular mode")
40+
results = framework.run_tests(silent=args.silent)
41+
42+
# Save results
43+
framework.save_results(results)
44+
45+
logging.info("Causal testing completed successfully.")
46+
47+
48+
if __name__ == "__main__":
49+
main()

0 commit comments

Comments
 (0)