@@ -46,20 +46,20 @@ class JsonUtility(ABC):
46
46
def __init__ (self , log_path ):
47
47
self .paths = None
48
48
self .variables = None
49
- self .data = None
49
+ self .data = []
50
50
self .test_plan = None
51
51
self .modelling_scenario = None
52
52
self .causal_specification = None
53
53
self .setup_logger (log_path )
54
54
55
- def set_paths (self , json_path : str , dag_path : str , data_path : str ):
55
+ def set_paths (self , json_path : str , dag_path : str , data_paths : str ):
56
56
"""
57
57
Takes a path of the directory containing all scenario specific files and creates individual paths for each file
58
58
:param json_path: string path representation to .json file containing test specifications
59
59
:param dag_path: string path representation to the .dot file containing the Causal DAG
60
60
:param data_path: string path representation to the data file
61
61
"""
62
- self .paths = JsonClassPaths (json_path = json_path , dag_path = dag_path , data_path = data_path )
62
+ self .paths = JsonClassPaths (json_path = json_path , dag_path = dag_path , data_paths = data_paths )
63
63
64
64
def set_variables (self , inputs : list [dict ], outputs : list [dict ], metas : list [dict ]):
65
65
"""Populate the Causal Variables
@@ -132,14 +132,15 @@ def _json_parse(self):
132
132
"""Parse a JSON input file into inputs, outputs, metas and a test plan"""
133
133
with open (self .paths .json_path , encoding = "utf-8" ) as f :
134
134
self .test_plan = json .load (f )
135
-
136
- self .data = pd .read_csv (self .paths .data_path )
135
+ for data_file in self .paths .data_paths :
136
+ df = pd .read_csv (data_file , header = 0 )
137
+ self .data .append (df )
138
+ self .data = pd .concat (self .data )
137
139
138
140
def _populate_metas (self ):
139
141
"""
140
142
Populate data with meta-variable values and add distributions to Causal Testing Framework Variables
141
143
"""
142
-
143
144
for meta in self .variables .metas :
144
145
meta .populate (self .data )
145
146
@@ -193,8 +194,10 @@ def _setup_test(self, causal_test_case: CausalTestCase, estimator: Estimator) ->
193
194
- causal_test_engine - Test Engine instance for the test being run
194
195
- estimation_model - Estimator instance for the test being run
195
196
"""
196
- data_collector = ObservationalDataCollector (self .modelling_scenario , self .paths .data_path )
197
+
198
+ data_collector = ObservationalDataCollector (self .modelling_scenario , self .data )
197
199
causal_test_engine = CausalTestEngine (self .causal_specification , data_collector , index_col = 0 )
200
+
198
201
minimal_adjustment_set = self .causal_specification .causal_dag .identification (causal_test_case .base_test_case )
199
202
treatment_var = causal_test_case .treatment_variable
200
203
minimal_adjustment_set = minimal_adjustment_set - {treatment_var }
@@ -252,6 +255,7 @@ def get_args(test_args=None) -> argparse.Namespace:
252
255
"--data_path" ,
253
256
help = "Specify path to file containing runtime data" ,
254
257
required = True ,
258
+ nargs = "+" ,
255
259
)
256
260
parser .add_argument (
257
261
"--dag_path" ,
@@ -277,12 +281,12 @@ class JsonClassPaths:
277
281
278
282
json_path : Path
279
283
dag_path : Path
280
- data_path : Path
284
+ data_paths : list [ Path ]
281
285
282
- def __init__ (self , json_path : str , dag_path : str , data_path : str ):
286
+ def __init__ (self , json_path : str , dag_path : str , data_paths : str ):
283
287
self .json_path = Path (json_path )
284
288
self .dag_path = Path (dag_path )
285
- self .data_path = Path (data_path )
289
+ self .data_paths = [ Path (path ) for path in data_paths ]
286
290
287
291
288
292
@dataclass ()
0 commit comments