-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #251 from CITCOM-project/dafni-branch
Dockerised framework for DAFNI
- Loading branch information
Showing
12 changed files
with
804 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
../* | ||
../!causal_testing | ||
./!main_dafni.py | ||
./!data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#.env | ||
VARIABLES_PATH=./data/inputs/variables.json | ||
CAUSAL_TESTS=./data/inputs/causal_tests.json | ||
DATA_PATH=./data/inputs/runtime_data.csv | ||
DAG_PATH=./data/inputs/dag.dot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Define the Python version neded for CTF | ||
FROM python:3.10-slim | ||
|
||
## Prevents Python from writing pyc files | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
# | ||
## Keeps Python from buffering stdout and stderr to avoid the framework | ||
## from crashing without emitting any logs due to buffering | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
#Label maintainer | ||
LABEL maintainer="Dr. Farhad Allian - The University of Sheffield" | ||
|
||
# Create a folder for the source code/outputs | ||
RUN mkdir -p ./causal_testing | ||
RUN mkdir -p ./data/outputs | ||
|
||
# Copy the source code and test files from build into the container | ||
COPY --chown=nobody ../causal_testing ./causal_testing | ||
COPY --chown=nobody ./dafni/main_dafni.py ./ | ||
COPY --chown=nobody ./dafni/data/inputs ./data/inputs | ||
|
||
# Install core dependencies using PyPi | ||
RUN pip install causal-testing-framework --no-cache-dir | ||
|
||
#For local testing purposes | ||
ENV VARIABLES_PATH=./data/inputs/variables.json \ | ||
CAUSAL_TESTS=./data/inputs/causal_tests.json \ | ||
DATA_PATH=./data/inputs/runtime_data.csv \ | ||
DAG_PATH=./data/inputs/dag.dot | ||
|
||
# Define the entrypoint/commands | ||
CMD python main_dafni.py --variables_path $VARIABLES_PATH --dag_path $DAG_PATH --data_path $DATA_PATH --tests_path $CAUSAL_TESTS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Causal Testing Framework on DAFNI | ||
|
||
- This directory contains the containerisation files of the causal testing framework using Docker, which is used | ||
to upload the framework onto [DAFNI](https://www.dafni.ac.uk). | ||
- It is **not** recommended to install the causal testing framework using Docker, and should only be installed | ||
using [PyPI](https://pypi.org/project/causal-testing-framework/). | ||
|
||
### Folders | ||
|
||
- `data` contains two sub-folders (the structure is important for DAFNI). | ||
- `inputs` is a folder that contains the input files that are (separately) uploaded to DAFNI. | ||
- `causal_tests.json` is a JSON file that contains the causal tests. | ||
- `variables.json` is a JSON file that contains the variables and constraints to be used. | ||
- `dag.dot` is a dot file that contains the directed acyclc graph (dag) file. | ||
- `runtime_data.csv` is a csv file that contains the runtime data. | ||
|
||
- `outputs` is a folder where the `causal_tests_results.json` output file is created. | ||
|
||
### Docker files | ||
- `main_dafni.py` is the entry-point to the causal testing framework that is used by Docker. | ||
- `model_definition.yaml` is the model metadata that is required to be uploaded to DAFNI. | ||
- `.env` is an example of a configuration file containing the environment variables. This is only required | ||
if using `docker-compose` to build the image. | ||
- `Dockerfile` is the main blueprint that builds the image. | ||
- `.dockerignore` tells the Dockerfile which files to not include in the image. | ||
- `docker-compose.yaml` is another method of building the image and running the container in one line. | ||
Note: the `.env` file that contains the environment variables for `main_dafni.py` is only used here. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
{ | ||
"tests": [ | ||
{ | ||
"name": "max_doses _||_ cum_vaccinations", | ||
"estimator": "LinearRegressionEstimator", | ||
"estimate_type": "coefficient", | ||
"effect": "direct", | ||
"mutations": [ | ||
"max_doses" | ||
], | ||
"expected_effect": { | ||
"cum_vaccinations": "NoEffect" | ||
}, | ||
"formula": "cum_vaccinations ~ max_doses", | ||
"alpha": 0.05, | ||
"skip": false | ||
}, | ||
{ | ||
"name": "max_doses _||_ cum_vaccinated", | ||
"estimator": "LinearRegressionEstimator", | ||
"estimate_type": "coefficient", | ||
"effect": "direct", | ||
"mutations": [ | ||
"max_doses" | ||
], | ||
"expected_effect": { | ||
"cum_vaccinated": "NoEffect" | ||
}, | ||
"formula": "cum_vaccinated ~ max_doses", | ||
"alpha": 0.05, | ||
"skip": false | ||
}, | ||
{ | ||
"name": "max_doses _||_ cum_infections", | ||
"estimator": "LinearRegressionEstimator", | ||
"estimate_type": "coefficient", | ||
"effect": "direct", | ||
"mutations": [ | ||
"max_doses" | ||
], | ||
"expected_effect": { | ||
"cum_infections": "NoEffect" | ||
}, | ||
"formula": "cum_infections ~ max_doses", | ||
"alpha": 0.05, | ||
"skip": false | ||
}, | ||
{ | ||
"name": "vaccine --> cum_vaccinations", | ||
"estimator": "LinearRegressionEstimator", | ||
"estimate_type": "coefficient", | ||
"effect": "direct", | ||
"mutations": [ | ||
"vaccine" | ||
], | ||
"expected_effect": { | ||
"cum_vaccinations": "SomeEffect" | ||
}, | ||
"formula": "cum_vaccinations ~ vaccine", | ||
"skip": false | ||
}, | ||
{ | ||
"name": "vaccine --> cum_vaccinated", | ||
"estimator": "LinearRegressionEstimator", | ||
"estimate_type": "coefficient", | ||
"effect": "direct", | ||
"mutations": [ | ||
"vaccine" | ||
], | ||
"expected_effect": { | ||
"cum_vaccinated": "SomeEffect" | ||
}, | ||
"formula": "cum_vaccinated ~ vaccine", | ||
"skip": false | ||
}, | ||
{ | ||
"name": "vaccine --> cum_infections", | ||
"estimator": "LinearRegressionEstimator", | ||
"estimate_type": "coefficient", | ||
"effect": "direct", | ||
"mutations": [ | ||
"vaccine" | ||
], | ||
"expected_effect": { | ||
"cum_infections": "SomeEffect" | ||
}, | ||
"formula": "cum_infections ~ vaccine", | ||
"skip": false | ||
}, | ||
{ | ||
"name": "cum_vaccinations _||_ cum_vaccinated | ['vaccine']", | ||
"estimator": "LinearRegressionEstimator", | ||
"estimate_type": "coefficient", | ||
"effect": "direct", | ||
"mutations": [ | ||
"cum_vaccinations" | ||
], | ||
"expected_effect": { | ||
"cum_vaccinated": "NoEffect" | ||
}, | ||
"formula": "cum_vaccinated ~ cum_vaccinations + vaccine", | ||
"alpha": 0.05, | ||
"skip": false | ||
}, | ||
{ | ||
"name": "cum_vaccinations _||_ cum_infections | ['vaccine']", | ||
"estimator": "LinearRegressionEstimator", | ||
"estimate_type": "coefficient", | ||
"effect": "direct", | ||
"mutations": [ | ||
"cum_vaccinations" | ||
], | ||
"expected_effect": { | ||
"cum_infections": "NoEffect" | ||
}, | ||
"formula": "cum_infections ~ cum_vaccinations + vaccine", | ||
"alpha": 0.05, | ||
"skip": false | ||
}, | ||
{ | ||
"name": "cum_vaccinated _||_ cum_infections | ['vaccine']", | ||
"estimator": "LinearRegressionEstimator", | ||
"estimate_type": "coefficient", | ||
"effect": "direct", | ||
"mutations": [ | ||
"cum_vaccinated" | ||
], | ||
"expected_effect": { | ||
"cum_infections": "NoEffect" | ||
}, | ||
"formula": "cum_infections ~ cum_vaccinated + vaccine", | ||
"alpha": 0.05, | ||
"skip": false | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
digraph CausalDAG { | ||
rankdir=LR; | ||
"vaccine" -> "cum_vaccinations"; | ||
"vaccine" -> "cum_vaccinated"; | ||
"vaccine" -> "cum_infections"; | ||
"max_doses"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
pop_size,pop_type,pop_infected,n_days,vaccine_type,use_waning,rand_seed,cum_infections,cum_deaths,cum_recoveries,cum_vaccinations,cum_vaccinated,target_elderly,vaccine,max_doses | ||
50000,hybrid,1000,50,pfizer,True,1169,6277.0,15.0,6175.0,629466.0,530715.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,8888,6381.0,18.0,6274.0,630796.0,532010.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,370,6738.0,15.0,6621.0,631705.0,532864.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,9981,6784.0,18.0,6682.0,634582.0,535795.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,6305,6757.0,20.0,6659.0,631292.0,532464.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,1993,5844.0,17.0,5755.0,633314.0,534478.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,1938,6465.0,19.0,6353.0,627724.0,528993.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,4797,7044.0,15.0,6919.0,631246.0,532433.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,2308,6878.0,6.0,6801.0,628865.0,530038.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,4420,6429.0,11.0,6348.0,633803.0,535030.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,2314,6566.0,15.0,6477.0,629288.0,530550.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,7813,6913.0,17.0,6818.0,629290.0,530512.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,1050,6963.0,14.0,6860.0,627981.0,529212.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,3215,6671.0,17.0,6577.0,628802.0,530038.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,2286,6597.0,13.0,6505.0,628986.0,530195.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,3080,6926.0,16.0,6834.0,633636.0,534904.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,7405,6438.0,15.0,6347.0,630353.0,531540.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,9668,6577.0,15.0,6485.0,631257.0,532409.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,8211,6197.0,13.0,6103.0,633827.0,535056.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,4686,6761.0,16.0,6653.0,630557.0,531737.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,3591,7328.0,24.0,7214.0,629949.0,531124.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,4834,6617.0,22.0,6512.0,632609.0,533705.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,6142,7017.0,17.0,6902.0,635965.0,537252.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,6877,6845.0,15.0,6753.0,635678.0,536925.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,1878,6480.0,20.0,6390.0,630807.0,531999.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,3761,6972.0,16.0,6890.0,631100.0,532329.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,1741,6581.0,20.0,6491.0,632835.0,534088.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,5592,6561.0,19.0,6461.0,636799.0,537959.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,7979,7075.0,17.0,6966.0,632902.0,534140.0,True,1,2 | ||
50000,hybrid,1000,50,pfizer,True,71,6291.0,13.0,6203.0,631694.0,532901.0,True,1,2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"variables": [ | ||
{ | ||
"name": "pop_size", | ||
"datatype": "int", | ||
"typestring": "Input", | ||
"constraint": 50000 | ||
}, | ||
{ | ||
"name": "pop_infected", | ||
"datatype": "int", | ||
"typestring": "Input", | ||
"constraint": 1000 | ||
}, | ||
{ | ||
"name": "n_days", | ||
"datatype": "int", | ||
"typestring": "Input", | ||
"constraint": 50 | ||
}, | ||
{ | ||
"name": "vaccine", | ||
"datatype": "int", | ||
"typestring": "Input" | ||
}, | ||
{ | ||
"name": "cum_infections", | ||
"datatype": "int", | ||
"typestring": "Output" | ||
}, | ||
{ | ||
"name": "cum_vaccinations", | ||
"datatype": "int", | ||
"typestring": "Output" | ||
}, | ||
{ | ||
"name": "cum_vaccinated", | ||
"datatype": "int", | ||
"typestring": "Output" | ||
}, | ||
{ | ||
"name": "max_doses", | ||
"datatype": "int", | ||
"typestring": "Output" | ||
} | ||
] | ||
} |
Oops, something went wrong.