-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerate_yaml.py
More file actions
113 lines (98 loc) · 2.82 KB
/
generate_yaml.py
File metadata and controls
113 lines (98 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
"""
Description:
- This script generates the YAML file for the project.
Usage:
- python generate_yaml.py
Output:
- project.yaml
"""
from analysis.config import codelists
# --- YAML HEADER ---
yaml_header = """
version: '4.0'
actions:
"""
# --- YAML MEASURES BODY ----
# Template for measures generation
yaml_template = """
generate_measures_{test}_tests:
run: >
ehrql:v1 generate-measures
analysis/measure_definition.py
--output output/{test}_tests/measures.arrow
--
--test {test}
outputs:
highly_sensitive:
measures: output/{test}_tests/measures.arrow
generate_measures_{test}_tests_light:
run: >
ehrql:v1 generate-measures
analysis/measure_definition.py
--output output/{test}_tests/measures_light.arrow
--
--test {test}
--light
outputs:
highly_sensitive:
measures: output/{test}_tests/measures_light.arrow
generate_processed_data_{test}_tests:
run: >
python:latest
analysis/write_processed_csv_files.py
--output-dir output/{test}_tests
--test {test}
needs:
[generate_measures_{test}_tests]
outputs:
moderately_sensitive:
monthly_tables: output/{test}_tests/*deciles_table_counts_per_month*.csv
monthly_counts: output/{test}_tests/*practice_counts_per_month*.csv
code_table: output/{test}_tests/top_5_code_table.csv
event_counts_table: output/{test}_tests/event_counts.csv
generate_processed_data_{test}_tests_light:
run: >
python:latest
analysis/write_processed_csv_files.py
--output-dir output/{test}_tests
--test {test}
--light
needs:
[generate_measures_{test}_tests_light]
outputs:
moderately_sensitive:
monthly_tables: output/{test}_tests/*deciles_table_counts_per_month*_light.csv
monthly_counts: output/{test}_tests/*practice_counts_per_month*_light.csv
code_table: output/{test}_tests/top_5_code_table_light.csv
event_counts_table: output/{test}_tests/event_counts_light.csv
generate_dataset_test_{test}:
run: >
ehrql:v1 generate-dataset
analysis/dataset_definition.py
--test-data-file analysis/test_dataset.py
--output output/tests/{test}_dataset.csv
--
--test {test}
outputs:
highly_sensitive:
population: output/tests/{test}_dataset.csv
"""
yaml_body = ""
needs = {}
tests = codelists
del tests["diab_res"]
del tests["alt_numeric"]
for test in tests.keys():
yaml_body += yaml_template.format(test=test)
yaml_plots = """
generate_plots:
run: >
r:latest
analysis/plots.r
outputs:
moderately_sensitive:
plots: output*.png
"""
yaml = yaml_header + yaml_body + yaml_plots
with open("project.yaml", "w") as file:
file.write(yaml)