From 580abd6bea2165c589f2670391dd23faf19feba7 Mon Sep 17 00:00:00 2001 From: mostaphaRoudsari Date: Thu, 14 Apr 2022 19:56:23 -0400 Subject: [PATCH] fix: remove params outputs from DAGs Otherwise, it won't run on Pollination! --- pollination/three_phase/entry.py | 19 ++++++++++++----- .../three_phase/three_phase/calculation.py | 21 ++++++++++++------- .../three_phase/three_phase/preparation.py | 11 +++++----- requirements.txt | 1 + 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/pollination/three_phase/entry.py b/pollination/three_phase/entry.py index 8d6a3a6..a5c2816 100644 --- a/pollination/three_phase/entry.py +++ b/pollination/three_phase/entry.py @@ -5,6 +5,8 @@ from pollination.honeybee_radiance.sun import CreateSunMatrix, ParseSunUpHours from pollination.honeybee_radiance.multiphase import PrepareDynamic +from pollination.path.read import ReadJSONList + from .two_phase.entry import TwoPhaseEntryPoint from .two_phase.dynamic.entry import DynamicGroup from .three_phase.preparation import ThreePhaseInputsPreparation @@ -243,10 +245,12 @@ def prepare_three_phase( ): return [ { - 'from': ThreePhaseInputsPreparation()._outputs.multiplication_info + 'from': ThreePhaseInputsPreparation()._outputs.multiplication_info, + 'to': '../../calcs/3_phase/info/multiplication_info.json' }, { - 'from': ThreePhaseInputsPreparation()._outputs.grouped_apertures_info + 'from': ThreePhaseInputsPreparation()._outputs.grouped_apertures_info, + 'to': '../../calcs/3_phase/info/grouped_apertures_info.json' }, { 'from': ThreePhaseInputsPreparation()._outputs.grouped_apertures_folder, @@ -258,12 +262,18 @@ def prepare_three_phase( } ] + @task(template=ReadJSONList, needs=[prepare_three_phase]) + def multiplication_info_to_json( + self, src=prepare_three_phase._outputs.multiplication_info + ): + return [{'from': ReadJSONList()._outputs.data}] + @task( template=ThreePhaseMatrixCalculation, needs=[ create_rad_folder, prepare_dynamic, create_total_sky, create_sky_dome, - prepare_three_phase + prepare_three_phase, multiplication_info_to_json ], sub_folder='calcs/3_phase', sub_paths={ @@ -273,9 +283,8 @@ def prepare_three_phase( def calculate_three_phase_matrix_total( self, model_folder=create_rad_folder._outputs.model_folder, - grouped_apertures=prepare_three_phase._outputs.grouped_apertures_info, grouped_apertures_folder=prepare_three_phase._outputs.grouped_apertures_folder, - multiplication_info=prepare_three_phase._outputs.multiplication_info, + multiplication_info=multiplication_info_to_json._outputs.data, receivers=create_rad_folder._outputs.receivers, view_mtx_rad_params=view_mtx_rad_params, daylight_mtx_rad_params=daylight_mtx_rad_params, diff --git a/pollination/three_phase/three_phase/calculation.py b/pollination/three_phase/three_phase/calculation.py index 52ae7c5..2bacdd9 100644 --- a/pollination/three_phase/three_phase/calculation.py +++ b/pollination/three_phase/three_phase/calculation.py @@ -1,6 +1,8 @@ +from dataclasses import dataclass + from pollination_dsl.dag import Inputs, DAG, task, Outputs from pollination_dsl.dag.inputs import ItemType -from dataclasses import dataclass +from pollination.path.read import ReadJSONList from ._view_matrix import ViewMatrixRayTracing from ._daylight_matrix import DaylightMtxRayTracing @@ -14,15 +16,11 @@ class ThreePhaseMatrixCalculation(DAG): model_folder = Inputs.folder( description='Radiance model folder', path='model' ) - - grouped_apertures = Inputs.list( - description='List fo grouped apertures for daylight matrix calculation.', - items_type=ItemType.JSONObject - ) grouped_apertures_folder = Inputs.folder( description='A folder with all the grouped apertures for daylight matrix ' - 'calculation. Use ThreePhaseInputsPreparation to generate this folder.' + 'calculation. Use ThreePhaseInputsPreparation to generate this folder. ' + 'This folder also includes an _info.json file for aperture info.' ) multiplication_info = Inputs.list( @@ -89,10 +87,17 @@ def calculate_view_matrix( ): pass + @task(template=ReadJSONList, sub_paths={'src': '_info.json'}) + def grouped_apertures_info_to_json( + self, src=grouped_apertures_folder + ): + return [{'from': ReadJSONList()._outputs.data}] + @task( template=DaylightMtxRayTracing, sub_folder='daylight_mtx', - loop=grouped_apertures, + needs=[grouped_apertures_info_to_json], + loop=grouped_apertures_info_to_json._outputs.data, sub_paths={ 'sender_file': '{{item.identifier}}.rad', 'senders_folder': 'aperture_group' diff --git a/pollination/three_phase/three_phase/preparation.py b/pollination/three_phase/three_phase/preparation.py index ce954b5..6294fde 100644 --- a/pollination/three_phase/three_phase/preparation.py +++ b/pollination/three_phase/three_phase/preparation.py @@ -97,15 +97,14 @@ def get_three_phase_combinations( 'calculation.', source='model/sender' ) - grouped_apertures_info = Outputs.list( - description='List fo grouped apertures for daylight matrix calculation.', - source=daylight_matrix_aperture_grouping._outputs.grouped_apertures_file, - items_type=ItemType.JSONObject + grouped_apertures_info = Outputs.file( + description='A JSON file with List of grouped apertures for daylight matrix ' + 'calculation.', source='model/sender/_info.json' ) - multiplication_info = Outputs.list( + multiplication_info = Outputs.file( description='A JSON file with matrix multiplication information.', - source='multiplication_info.json', items_type=ItemType.JSONObject + source='multiplication_info.json' ) results_info = Outputs.file( diff --git a/requirements.txt b/requirements.txt index 382d11e..3ae50dc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ pollination-honeybee-radiance==0.22.2 +pollination-path==0.3.1