Skip to content

Commit

Permalink
fix: explicitly copy the outputs of grouped DAGs
Browse files Browse the repository at this point in the history
Unlike the standard DAGs, grouped DAGs are executed in an isolated context and the output files and folders should be copied to the main folder explicitly.
  • Loading branch information
mostaphaRoudsari committed Jul 30, 2024
1 parent de942c0 commit 1711c9f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 9 deletions.
6 changes: 5 additions & 1 deletion pollination/utci_comfort_map/_comfort.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pollination_dsl.dag import Inputs, GroupedDAG, task
from pollination_dsl.dag import Inputs, GroupedDAG, task, Outputs
from dataclasses import dataclass
from typing import Dict, List

Expand Down Expand Up @@ -260,3 +260,7 @@ def compute_tcp(
{'from': Tcp()._outputs.hsp, 'to': 'metrics/HSP/{{self.name}}.csv'},
{'from': Tcp()._outputs.csp, 'to': 'metrics/CSP/{{self.name}}.csv'}
]

results_folder = Outputs.folder(source='results')
conditions = Outputs.folder(source='conditions')
metrics = Outputs.folder(source='metrics')
7 changes: 6 additions & 1 deletion pollination/utci_comfort_map/_dynshade.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@ def run_radiance_shade_contrib(
sun_modifiers=sun_modifiers,
sun_up_hours=sun_up_hours
) -> List[Dict]:
pass
return [
{
'from': ShadeContribEntryPoint()._outputs.shd_trans,
'to': 'radiance/shortwave/shd_trans/final'
}
]
8 changes: 7 additions & 1 deletion pollination/utci_comfort_map/_radiance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pollination_dsl.dag import Inputs, GroupedDAG, task
from pollination_dsl.dag import Inputs, GroupedDAG, task, Outputs
from dataclasses import dataclass

from pollination.honeybee_radiance.grid import MirrorGrid, RadiantEnclosureInfo
Expand Down Expand Up @@ -208,3 +208,9 @@ def ground_reflected_sky(
'to': 'shortwave/results/reflected/{{self.name}}.ill'
}
]


enclosures = Outputs.folder(source='enclosures')
shortwave_results = Outputs.folder(source='shortwave/results')
shortwave_grids = Outputs.folder(source='shortwave/grids')
longwave_view_factors = Outputs.folder(source='longwave/view_factors')
4 changes: 3 additions & 1 deletion pollination/utci_comfort_map/_shdcontrib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pollination_dsl.dag import Inputs, GroupedDAG, task
from pollination_dsl.dag import Inputs, GroupedDAG, task, Outputs
from dataclasses import dataclass

from pollination.honeybee_radiance.contrib import DaylightContribution
Expand Down Expand Up @@ -175,3 +175,5 @@ def ground_reflected_sky_shade_group(
'to': 'shd_trans/final/{{self.grid}}/{{self.group}}/reflected.ill'
}
]

shd_trans = Outputs.folder(source='shd_trans/final')
41 changes: 36 additions & 5 deletions pollination/utci_comfort_map/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,24 @@ def run_radiance_simulation(
sun_modifiers=prepare_folder._outputs.shortwave_resources,
view_factor_modifiers=prepare_folder._outputs.longwave_resources,
) -> List[Dict]:
pass
return [
{
'from': RadianceMappingEntryPoint()._outputs.enclosures,
'to': 'radiance/enclosures'
},
{
'from': RadianceMappingEntryPoint()._outputs.shortwave_results,
'to': 'radiance/shortwave/results'
},
{
'from': RadianceMappingEntryPoint()._outputs.shortwave_grids,
'to': 'radiance/shortwave/grids'
},
{
'from': RadianceMappingEntryPoint()._outputs.longwave_view_factors,
'to': 'radiance/longwave/view_factors'
}
]

@task(
template=DynamicShadeContribEntryPoint,
Expand All @@ -236,12 +253,13 @@ def run_radiance_simulation(
sub_folder='radiance',
sub_paths={
'octree_file': 'dynamic_shades/{{item.default}}',
'octree_file_with_suns': 'dynamic_shades({{item.sun}}',
'octree_file_with_suns': 'dynamic_shades/{{item.sun}}',
'sky_dome': 'sky.dome',
'sky_matrix': 'sky.mtx',
'sky_matrix_direct': 'sky_direct.mtx',
'sun_modifiers': 'suns.mod',
'sun_up_hours': 'sun-up-hours.txt'
'sun_up_hours': 'sun-up-hours.txt',
'sensor_grids': '_split_info.json'
}
)
def run_radiance_dynamic_shade_contribution(
Expand All @@ -251,7 +269,7 @@ def run_radiance_dynamic_shade_contribution(
octree_file_with_suns=prepare_folder._outputs.shortwave_resources,
group_name='{{item.identifier}}',
sensor_grid_folder='radiance/shortwave/grids',
sensor_grids=prepare_folder._outputs.sensor_grids,
sensor_grids=prepare_folder._outputs.sensor_grids_folder,
sky_dome=prepare_folder._outputs.shortwave_resources,
sky_matrix=prepare_folder._outputs.shortwave_resources,
sky_matrix_direct=prepare_folder._outputs.shortwave_resources,
Expand Down Expand Up @@ -304,7 +322,20 @@ def run_comfort_map(
solarcal_par=solarcal_parameters,
comfort_parameters=comfort_parameters
) -> List[Dict]:
pass
return [
{
'from': ComfortMappingEntryPoint()._outputs.results_folder,
'to': 'initial_results/results'
},
{
'from': ComfortMappingEntryPoint()._outputs.conditions,
'to': 'initial_results/conditions'
},
{
'from': ComfortMappingEntryPoint()._outputs.metrics,
'to': 'initial_results/metrics'
}
]

@task(template=MergeFolderDataPostProcess, needs=[run_comfort_map])
def restructure_temperature_results(
Expand Down

0 comments on commit 1711c9f

Please sign in to comment.