|
4 | 4 | import argparse
|
5 | 5 | import json
|
6 | 6 | import logging
|
| 7 | +import tempfile |
7 | 8 |
|
8 | 9 | from abc import ABC
|
9 | 10 | from dataclasses import dataclass
|
@@ -46,20 +47,20 @@ class JsonUtility(ABC):
|
46 | 47 | def __init__(self, log_path):
|
47 | 48 | self.paths = None
|
48 | 49 | self.variables = None
|
49 |
| - self.data = None |
| 50 | + self.data = list() |
50 | 51 | self.test_plan = None
|
51 | 52 | self.modelling_scenario = None
|
52 | 53 | self.causal_specification = None
|
53 | 54 | self.setup_logger(log_path)
|
54 | 55 |
|
55 |
| - def set_paths(self, json_path: str, dag_path: str, data_path: str): |
| 56 | + def set_paths(self, json_path: str, dag_path: str, data_paths: str): |
56 | 57 | """
|
57 | 58 | Takes a path of the directory containing all scenario specific files and creates individual paths for each file
|
58 | 59 | :param json_path: string path representation to .json file containing test specifications
|
59 | 60 | :param dag_path: string path representation to the .dot file containing the Causal DAG
|
60 | 61 | :param data_path: string path representation to the data file
|
61 | 62 | """
|
62 |
| - self.paths = JsonClassPaths(json_path=json_path, dag_path=dag_path, data_path=data_path) |
| 63 | + self.paths = JsonClassPaths(json_path=json_path, dag_path=dag_path, data_paths=data_paths) |
63 | 64 |
|
64 | 65 | def set_variables(self, inputs: list[dict], outputs: list[dict], metas: list[dict]):
|
65 | 66 | """Populate the Causal Variables
|
@@ -132,8 +133,9 @@ def _json_parse(self):
|
132 | 133 | """Parse a JSON input file into inputs, outputs, metas and a test plan"""
|
133 | 134 | with open(self.paths.json_path, encoding="utf-8") as f:
|
134 | 135 | self.test_plan = json.load(f)
|
135 |
| - |
136 |
| - self.data = pd.read_csv(self.paths.data_path) |
| 136 | + for data_file in self.paths.data_paths: |
| 137 | + df = pd.read_csv(data_file, header=0) |
| 138 | + self.data.append(df) |
137 | 139 |
|
138 | 140 | def _populate_metas(self):
|
139 | 141 | """
|
@@ -252,6 +254,7 @@ def get_args(test_args=None) -> argparse.Namespace:
|
252 | 254 | "--data_path",
|
253 | 255 | help="Specify path to file containing runtime data",
|
254 | 256 | required=True,
|
| 257 | + nargs='+', |
255 | 258 | )
|
256 | 259 | parser.add_argument(
|
257 | 260 | "--dag_path",
|
@@ -282,7 +285,7 @@ class JsonClassPaths:
|
282 | 285 | def __init__(self, json_path: str, dag_path: str, data_path: str):
|
283 | 286 | self.json_path = Path(json_path)
|
284 | 287 | self.dag_path = Path(dag_path)
|
285 |
| - self.data_path = Path(data_path) |
| 288 | + self.data_paths = [Path(path) for path in data_path] |
286 | 289 |
|
287 | 290 |
|
288 | 291 | @dataclass()
|
|
0 commit comments