Skip to content

DAFNI Workflow Enhancements #299

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 27 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5dc3d27
remove variables from entry-point
f-allian Dec 6, 2024
b929564
update sample dag file to include the variables as node attributes
f-allian Dec 6, 2024
354fd3e
update Dockerfile for dafni image
f-allian Dec 6, 2024
0e53b47
update dafni model definition
f-allian Dec 6, 2024
4497da2
update README.md
f-allian Dec 6, 2024
fb83d65
turned main_dafni.py into a module
f-allian Dec 6, 2024
5b736b8
final touches to main_dafni.py
f-allian Dec 10, 2024
ea46bdc
add: tests for main_dafni.py
f-allian Dec 10, 2024
005d2da
update: tests to dafni workflow
f-allian Dec 10, 2024
9a45392
fix: typo in Dockerfile
f-allian Dec 10, 2024
456048c
fix: default in ignore_cycles tests_main_dafni.py
f-allian Dec 10, 2024
029fdfc
updated causal_tests_results.json
f-allian Dec 10, 2024
802e274
update: file names
f-allian Dec 10, 2024
05a85fd
update: README.md metadata
f-allian Dec 13, 2024
3cd85ae
update: README
f-allian Jan 21, 2025
a03a807
Merge remote-tracking branch 'origin/main' into dafni-dev
f-allian Mar 6, 2025
5202034
Merge branch 'main' into dafni-dev
f-allian Apr 2, 2025
66cb0e7
remove: main_dafni.py and related files
f-allian Apr 2, 2025
233a49c
update: Docker image and config file
f-allian Apr 2, 2025
4a34334
update: DAFNI model_definition.yaml
f-allian Apr 2, 2025
5742985
update: example DAFNI test and results
f-allian Apr 2, 2025
60b3c7f
update: README.md
f-allian Apr 2, 2025
8977c0f
remove project tags for now
f-allian Apr 3, 2025
28aa53e
Merge branch 'main' into dafni-dev
f-allian Apr 29, 2025
a26c051
update: docker-compose.yaml
f-allian May 1, 2025
74c6f2f
update: publish-to-dafni.yaml
f-allian May 1, 2025
40faa83
Merge branch 'main' into dafni-dev
f-allian May 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/publish-to-dafni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,25 @@ jobs:
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install causal-testing-framework -e .[dev]
python -m pip install dafni-cli

- name: Run tests before uploading
id: tests
run: |
python -m pytest ./dafni/tests

- name: Build the container
if: steps.tests.outcome == 'success'
run: |
docker build -t ctf:${{ env.VERSION }} -f ./dafni/Dockerfile .
docker save ctf:${{ env.VERSION }} | gzip > ctf-dafni-${{ env.VERSION }}.tar.gz

- name: Install DAFNI-CLI and log in
- name: Log into DAFNI
run: |
python -m pip install dafni-cli
dafni login

- name: Upload to DAFNI
Expand Down
17 changes: 7 additions & 10 deletions dafni/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,23 @@ ENV PYTHONDONTWRITEBYTECODE=1
## from crashing without emitting any logs due to buffering
ENV PYTHONUNBUFFERED=1

#Label maintainer
# 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 the source code from local root and test files from build into the container
COPY --chown=nobody ./causal_testing ./causal_testing
COPY --chown=nobody ./dafni/src/ ./src
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
# Set the PYTHONPATH environment variable to include the /src directory
ENV PYTHONPATH="/src:${PYTHONPATH}"

# 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
CMD python -m main_dafni --dag_path $DAG_PATH --data_path $DATA_PATH --tests_path $TESTS_PATH
4 changes: 2 additions & 2 deletions dafni/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ to upload the framework onto [DAFNI](https://www.dafni.ac.uk).
- `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.
- `dag.dot` is a dot file that contains the directed acyclc graph (dag) file,
including the variables (and constraints if necessary) as node attributes.
- `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.
Expand Down
13 changes: 9 additions & 4 deletions dafni/data/inputs/dag.dot
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
digraph CausalDAG {
rankdir=LR;
"vaccine" -> "cum_vaccinations";
"vaccine" -> "cum_vaccinated";
"vaccine" -> "cum_infections";
"max_doses";
vaccine [datatype="int", typestring="input"];
cum_vaccinations [datatype="int", typestring="output"];
cum_vaccinated [datatype="int", typestring="output"];
cum_infections [datatype="int", typestring="output"];
max_doses [datatype="int", typestring="output"];
vaccine -> cum_vaccinations;
vaccine -> cum_vaccinated;
vaccine -> cum_infections;
max_doses;
}
108 changes: 81 additions & 27 deletions dafni/data/outputs/causal_tests_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
"outcome": "cum_vaccinations",
"adjustment_set": [],
"effect_measure": "coefficient",
"effect_estimate": 252628.1066666667,
"ci_low": 252271.33332001517,
"ci_high": 252984.8800133182
"effect_estimate": {
"max_doses": 252628.1066666667
},
"ci_low": [
252271.33332001517
],
"ci_high": [
252984.8800133182
]
}
},
{
Expand All @@ -42,9 +48,15 @@
"outcome": "cum_vaccinated",
"adjustment_set": [],
"effect_measure": "coefficient",
"effect_estimate": 213111.93333333335,
"ci_low": 212755.15056812647,
"ci_high": 213468.71609854023
"effect_estimate": {
"max_doses": 213111.93333333335
},
"ci_low": [
212755.15056812647
],
"ci_high": [
213468.71609854023
]
}
},
{
Expand All @@ -66,9 +78,15 @@
"outcome": "cum_infections",
"adjustment_set": [],
"effect_measure": "coefficient",
"effect_estimate": 2666.3066666666664,
"ci_low": 2619.972040648758,
"ci_high": 2712.6412926845746
"effect_estimate": {
"max_doses": 2666.3066666666664
},
"ci_low": [
2619.972040648758
],
"ci_high": [
2712.6412926845746
]
}
},
{
Expand All @@ -89,9 +107,15 @@
"outcome": "cum_vaccinations",
"adjustment_set": [],
"effect_measure": "coefficient",
"effect_estimate": 315785.1333333332,
"ci_low": 315339.1666500188,
"ci_high": 316231.1000166476
"effect_estimate": {
"vaccine": 315785.1333333332
},
"ci_low": [
315339.1666500188
],
"ci_high": [
316231.1000166476
]
}
},
{
Expand All @@ -112,9 +136,15 @@
"outcome": "cum_vaccinated",
"adjustment_set": [],
"effect_measure": "coefficient",
"effect_estimate": 266389.91666666657,
"ci_low": 265943.93821015797,
"ci_high": 266835.89512317517
"effect_estimate": {
"vaccine": 266389.91666666657
},
"ci_low": [
265943.93821015797
],
"ci_high": [
266835.89512317517
]
}
},
{
Expand All @@ -135,9 +165,15 @@
"outcome": "cum_infections",
"adjustment_set": [],
"effect_measure": "coefficient",
"effect_estimate": 3332.883333333332,
"ci_low": 3274.9650508109467,
"ci_high": 3390.801615855717
"effect_estimate": {
"vaccine": 3332.883333333332
},
"ci_low": [
3274.9650508109467
],
"ci_high": [
3390.801615855717
]
}
},
{
Expand All @@ -159,9 +195,15 @@
"outcome": "cum_vaccinated",
"adjustment_set": [],
"effect_measure": "coefficient",
"effect_estimate": 0.9998656401531605,
"ci_low": 0.9929245394499968,
"ci_high": 1.0068067408563242
"effect_estimate": {
"cum_vaccinations": 0.9998656401531605
},
"ci_low": [
0.9929245394499968
],
"ci_high": [
1.0068067408563242
]
}
},
{
Expand All @@ -183,9 +225,15 @@
"outcome": "cum_infections",
"adjustment_set": [],
"effect_measure": "coefficient",
"effect_estimate": -0.006416682407515084,
"ci_low": -0.05663010083886572,
"ci_high": 0.043796736023835554
"effect_estimate": {
"cum_vaccinations": -0.006416682407515084
},
"ci_low": [
-0.05663010083886572
],
"ci_high": [
0.043796736023835554
]
}
},
{
Expand All @@ -207,9 +255,15 @@
"outcome": "cum_infections",
"adjustment_set": [],
"effect_measure": "coefficient",
"effect_estimate": -0.006176900588291234,
"ci_low": -0.05639349612119588,
"ci_high": 0.04403969494461341
"effect_estimate": {
"cum_vaccinated": -0.006176900588291234
},
"ci_low": [
-0.05639349612119588
],
"ci_high": [
0.04403969494461341
]
}
}
]
4 changes: 2 additions & 2 deletions dafni/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ services:
causal-testing-framework:
build:
context: ../
dockerfile: ./dafni/Dockerfile
dockerfile: dafni/Dockerfile
env_file:
- .env
volumes:
- .:/usr/src/app
- ./dafni:/usr/src/
8 changes: 0 additions & 8 deletions dafni/model_definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ spec:
path: inputs/
required: true

- name: Variables
description: >
A .JSON file containing the input variables to be used
default:
- 02e755c8-952b-461a-a914-4f4ffbe2edf1
path: inputs/
required: true

outputs:
datasets:
- name: causal_test_results.json
Expand Down
Empty file added dafni/src/__init__.py
Empty file.
Loading
Loading