Skip to content

Commit

Permalink
Merge 6a8eda0 into 7e46ea1
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineDao committed Nov 2, 2021
2 parents 7e46ea1 + 6a8eda0 commit 17ec472
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
16 changes: 9 additions & 7 deletions honeybee_vtk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ def load_config(json_path: str, model: Model, scene: Scene,
assert len(model.sensor_grids.data) > 0, 'Sensor grids are not loaded on'\
' this model. Reload them using grid options.'

config_dir = pathlib.Path(json_path).parent

try:
with open(json_path) as fh:
config = json.load(fh)
Expand All @@ -464,14 +466,14 @@ def load_config(json_path: str, model: Model, scene: Scene,
data = DataConfig.parse_obj(json_obj)
# only if data is requested move forward.
if not data.hide:
if not pathlib.Path(json_obj['path']).is_dir():
raise FileNotFoundError(
f'The path {json_obj["path"]} does not exist. It is likely that the'
' config file is not in the current working directory and the paths'
' to the result folders defined in the config file are relative to'
' the location of the config file.'
)
folder_path = pathlib.Path(data.path)
if not folder_path.is_dir():
folder_path = config_dir.joinpath(
folder_path).resolve().absolute()
data.path = folder_path.as_posix()
if not folder_path.is_dir():
raise FileNotFoundError(
f'No folder found at {data.path}')
identifier = data.identifier
grid_type = _get_grid_type(model)
# Validate data if asked for
Expand Down
40 changes: 35 additions & 5 deletions tests/assets/config/valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@
"min": 0,
"max": 20,
"color_set": "original",
"position": [0.5, 0.05],
"position": [
0.5,
0.05
],
"label_parameters": {
"color": [34, 247, 10],
"color": [
34,
247,
10
],
"size": 0,
"bold": true
}
Expand All @@ -23,18 +30,41 @@
"identifier": "UDI",
"object_type": "grid",
"unit": "Percentage",
"path": "./tests/assets/udi_results",
"path": "./tests/assets/df_results",
"hide": true,
"legend_parameters": {
"hide_legend": false,
"min": 0,
"max": 100,
"color_set": "nuanced",
"position": [0.9, 0.5],
"position": [
0.9,
0.5
],
"orientation": "vertical",
"width": 0.05,
"height": 0.45
}
},
{
"identifier": "Relative Path DF Results",
"object_type": "grid",
"unit": "Percentage",
"path": "../udi_results",
"hide": false,
"legend_parameters": {
"hide_legend": false,
"min": 0,
"max": 100,
"color_set": "nuanced",
"position": [
0.9,
0.5
],
"orientation": "vertical",
"width": 0.05,
"height": 0.45
}
}
]
}
}

0 comments on commit 17ec472

Please sign in to comment.