|
1 | 1 | # Causal Testing Framework on DAFNI |
2 | 2 |
|
3 | 3 | - This directory contains the containerisation files of the causal testing framework using Docker, which is used |
4 | | -to upload the framework onto [DAFNI](https://www.dafni.ac.uk). |
| 4 | + to upload the framework onto [DAFNI](https://www.dafni.ac.uk). |
5 | 5 | - It is **not** recommended to install the causal testing framework using Docker, and should only be installed |
6 | | - using [PyPI](https://pypi.org/project/causal-testing-framework/). |
| 6 | + using [conda-forge](https://anaconda.org/channels/conda-forge/packages/causal-testing-framework/overview) or [PyPI](https://pypi.org/project/causal-testing-framework/). |
7 | 7 |
|
8 | 8 | ### Directory Hierarchy |
9 | 9 |
|
10 | | -- `data` contains two sub-folders (the structure is important for DAFNI). |
11 | | - - `inputs` is a folder that contains the input files that are (separately) uploaded to DAFNI. |
12 | | - - `causal_tests.json` is a JSON file that contains the causal tests. |
13 | | - - `dag.dot` is a dot file that contains the directed acyclic graph (dag). In this file, Causal Variables are defined as |
14 | | - node metadata attributes as key-value pairs using the following syntax: |
15 | | - `node [datatype="int", typestring="input"]`. The `datatype` key specifies the datatype of the causal variable |
16 | | - as a string (e.g. `"int"`, `"str"`) and the `typestring` key specifies its typestring, which is also a string |
17 | | - representing the variable type (e.g. `"input"` or `"output"`). |
18 | | - - `runtime_data.csv` is the `.csv` file that contains the runtime data. |
| 10 | +- `data` contains two folders (structure is critical for DAFNI workflows): |
| 11 | + - `inputs` contains all input files that are uploaded to DAFNI. |
| 12 | + - `causal_tests.json` is a JSON file containing generated causal tests. If it exists, the framework can automatically run tests without regenerating. |
| 13 | + - `dag.dot` is a DOT file defining the directed acyclic graph (DAG). Causal variables are stored in node metadata as key-value pairs using the syntax: |
| 14 | + `node [datatype="int", typestring="input"]` |
| 15 | + - `datatype` specifies the variable's data type (e.g., `"int"`, `"str"`). |
| 16 | + - `typestring` specifies whether the variable is an `"input"` or `"output"`. |
| 17 | + - `runtime_data.csv` contains the input runtime data for testing. |
| 18 | + - `outputs` is the folder where `causal_test_results.json` is created after running tests. |
19 | 19 |
|
20 | | - - `outputs` is a folder where the `causal_tests_results.json` output file is created. |
| 20 | +### Workflow |
21 | 21 |
|
22 | | -### Docker files |
23 | | -- `model_definition.yaml` is the model metadata that is required to be uploaded to DAFNI. |
24 | | -- `Dockerfile` is the main blueprint that builds the image. The main command calls the `causal_testing` module, |
25 | | - with specified paths for the DAG, input runtime data, test configurations, and the output filename as defined above. |
26 | | - This command is identical to that referenced in the main [README.md](../README.md) file. |
27 | | -- `docker-compose.yaml` is another method of building the image and running the container in one line. |
28 | | - Note: the `.env` file that contains the environment variables for `main_dafni.py` is only used here. |
29 | | -- `.dockerignore` tells the Dockerfile which files to not include in the image. |
30 | | -- `.env` is an example of a configuration file containing the environment variables. This is only required |
31 | | - if using `docker-compose` to build the image. |
| 22 | +- The `entrypoint.sh` script now supports auto-detection: |
| 23 | + - If `causal_tests.json` exists in `data/inputs`, the script automatically runs the test mode. |
| 24 | + - If it does not exist, the script generates the causal tests first. |
| 25 | + - The user can still override this behaviour by setting `EXECUTION_MODE` explicitly in the `.env` file. |
| 26 | +- Filenames for `causal_tests.json` and `causal_test_results.json` are now configurable through environment variables (`CAUSAL_TESTS` and `CAUSAL_TEST_RESULTS`) in the `.env` file. |
| 27 | +- Input/output directories are fixed as `data/inputs` and `data/outputs` to comply with DAFNI requirements. |
| 28 | +- The script now reads all configuration parameters (estimator, effect type, threads, verbosity, query filters, adequacy metrics, etc.) **from the `.env` file**, keeping the Docker image and container clean and flexible. |
32 | 29 |
|
| 30 | +### Docker files |
33 | 31 |
|
| 32 | +- `model_definition.yaml` is the model metadata required for DAFNI. |
| 33 | +- `Dockerfile` builds the container image and uses `entrypoint.sh` as the main entrypoint. All paths and options are now configurable via `.env`. |
| 34 | +- `docker-compose.yaml` allows building and running the container with a single command. The `.env` file is required here to define all environment variables. |
| 35 | +- `.dockerignore` specifies files to exclude from the Docker image. |
| 36 | +- `.env` provides all configurable environment variables for the workflow (execution mode, filenames, estimator options, DAG/effects configuration, and runtime options). This is only needed if using `docker-compose`. |
0 commit comments