From df19d7b4a298de12569f8cbe5d77e3fb1a27fccc Mon Sep 17 00:00:00 2001 From: Mostapha Date: Fri, 19 Feb 2021 20:18:04 -0500 Subject: [PATCH] fix: remove the luigi version of the recipe --- direct_sun_hours/flow/__init__.py | 1 - .../flow/dependencies/__init__.py | 1 - .../direct_sun_hours_ray_tracing.py | 281 ------------ direct_sun_hours/flow/main.py | 412 ------------------ direct_sun_hours/package.json | 212 --------- direct_sun_hours/run.py | 55 --- 6 files changed, 962 deletions(-) delete mode 100644 direct_sun_hours/flow/__init__.py delete mode 100644 direct_sun_hours/flow/dependencies/__init__.py delete mode 100644 direct_sun_hours/flow/dependencies/direct_sun_hours_ray_tracing.py delete mode 100644 direct_sun_hours/flow/main.py delete mode 100644 direct_sun_hours/package.json delete mode 100644 direct_sun_hours/run.py diff --git a/direct_sun_hours/flow/__init__.py b/direct_sun_hours/flow/__init__.py deleted file mode 100644 index 8b13789..0000000 --- a/direct_sun_hours/flow/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/direct_sun_hours/flow/dependencies/__init__.py b/direct_sun_hours/flow/dependencies/__init__.py deleted file mode 100644 index 8b13789..0000000 --- a/direct_sun_hours/flow/dependencies/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/direct_sun_hours/flow/dependencies/direct_sun_hours_ray_tracing.py b/direct_sun_hours/flow/dependencies/direct_sun_hours_ray_tracing.py deleted file mode 100644 index 1a758bf..0000000 --- a/direct_sun_hours/flow/dependencies/direct_sun_hours_ray_tracing.py +++ /dev/null @@ -1,281 +0,0 @@ -import luigi -import os -from queenbee_local import QueenbeeTask - - -_default_inputs = { 'grid_name': None, - 'octree_file': None, - 'params_folder': '__params', - 'sensor_count': 200, - 'sensor_grid': None, - 'simulation_folder': '.', - 'sun_modifiers': None} - - -class DirectSunlightLoop(QueenbeeTask): - """Calculate daylight contribution for a grid of sensors from a series of modifiers - using rcontrib command.""" - - # DAG Input parameters - _input_params = luigi.DictParameter() - - # Task inputs - @property - def fixed_radiance_parameters(self): - return '-aa 0.0 -I -faa -ab 0 -dc 1.0 -dt 0.0 -dj 0.0 -dr 0' - - @property - def sensor_count(self): - return self.item['count'] - - calculate_values = luigi.Parameter(default='value') - - radiance_parameters = luigi.Parameter(default='') - - @property - def modifiers(self): - value = self._input_params['sun_modifiers'].replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def sensor_grid(self): - value = os.path.join(self.input()['SplitGrid']['output_folder'].path, self.item['path']).replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def scene_file(self): - value = self._input_params['octree_file'].replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - # get item for loop - try: - item = luigi.DictParameter() - except Exception: - item = luigi.Parameter() - - @property - def execution_folder(self): - return os.path.join(self._input_params['simulation_folder'], 'direct_sunlight').replace('\\', '/') - - @property - def initiation_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def params_folder(self): - return os.path.join(self.execution_folder, self._input_params['params_folder']).replace('\\', '/') - - def command(self): - return 'honeybee-radiance dc scontrib scene.oct grid.pts suns.mod --{calculate_values} --sensor-count {sensor_count} --rad-params "{radiance_parameters}" --rad-params-locked "{fixed_radiance_parameters}" --output results.ill'.format(calculate_values=self.calculate_values, sensor_count=self.sensor_count, radiance_parameters=self.radiance_parameters, fixed_radiance_parameters=self.fixed_radiance_parameters) - - def requires(self): - return {'SplitGrid': SplitGrid(_input_params=self._input_params)} - - def output(self): - return { - 'result_file': luigi.LocalTarget( - os.path.join(self.execution_folder, '{item_name}.ill'.format(item_name=self.item['name'])) - ) - } - - @property - def input_artifacts(self): - return [ - {'name': 'modifiers', 'to': 'suns.mod', 'from': self.modifiers}, - {'name': 'sensor_grid', 'to': 'grid.pts', 'from': self.sensor_grid}, - {'name': 'scene_file', 'to': 'scene.oct', 'from': self.scene_file}] - - @property - def output_artifacts(self): - return [ - { - 'name': 'result-file', 'from': 'results.ill', - 'to': os.path.join(self.execution_folder, '{item_name}.ill'.format(item_name=self.item['name'])) - }] - - -class DirectSunlight(luigi.Task): - """Calculate daylight contribution for a grid of sensors from a series of modifiers - using rcontrib command.""" - # global parameters - _input_params = luigi.DictParameter() - @property - def grids_list(self): - value = self.input()['SplitGrid']['grids_list'].path.replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def items(self): - try: - # assume the input is a file - return QueenbeeTask.load_input_param(self.grids_list) - except: - # it is a parameter - return self.input()['SplitGrid']['grids_list'].path - - def run(self): - yield [DirectSunlightLoop(item=item, _input_params=self._input_params) for item in self.items] - with open(os.path.join(self.execution_folder, 'direct_sunlight.done'), 'w') as out_file: - out_file.write('done!\n') - - @property - def initiation_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def execution_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def params_folder(self): - return os.path.join(self.execution_folder, self._input_params['params_folder']).replace('\\', '/') - - def requires(self): - return {'SplitGrid': SplitGrid(_input_params=self._input_params)} - - def output(self): - return { - 'is_done': luigi.LocalTarget(os.path.join(self.execution_folder, 'direct_sunlight.done')) - } - - -class MergeResults(QueenbeeTask): - """Merge several files with similar starting name into one.""" - - # DAG Input parameters - _input_params = luigi.DictParameter() - - # Task inputs - @property - def name(self): - return self._input_params['grid_name'] - - @property - def extension(self): - return '.ill' - - @property - def folder(self): - value = 'direct_sunlight'.replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def execution_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def initiation_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def params_folder(self): - return os.path.join(self.execution_folder, self._input_params['params_folder']).replace('\\', '/') - - def command(self): - return 'honeybee-radiance grid merge input_folder grid {extension} --name {name}'.format(extension=self.extension, name=self.name) - - def requires(self): - return {'DirectSunlight': DirectSunlight(_input_params=self._input_params)} - - def output(self): - return { - 'result_file': luigi.LocalTarget( - os.path.join(self.execution_folder, '../../results/{name}.ill'.format(name=self.name)) - ) - } - - @property - def input_artifacts(self): - return [ - {'name': 'folder', 'to': 'input_folder', 'from': self.folder}] - - @property - def output_artifacts(self): - return [ - { - 'name': 'result-file', 'from': '{name}{extension}'.format(name=self.name, extension=self.extension), - 'to': os.path.join(self.execution_folder, '../../results/{name}.ill'.format(name=self.name)) - }] - - -class SplitGrid(QueenbeeTask): - """Split a single sensor grid file into multiple smaller grids.""" - - # DAG Input parameters - _input_params = luigi.DictParameter() - - # Task inputs - @property - def sensor_count(self): - return self._input_params['sensor_count'] - - @property - def input_grid(self): - value = self._input_params['sensor_grid'].replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def execution_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def initiation_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def params_folder(self): - return os.path.join(self.execution_folder, self._input_params['params_folder']).replace('\\', '/') - - def command(self): - return 'honeybee-radiance grid split grid.pts {sensor_count} --folder output --log-file output/grids_info.json'.format(sensor_count=self.sensor_count) - - def output(self): - return { - - 'output_folder': luigi.LocalTarget( - os.path.join(self.execution_folder, 'sub_grids') - ), - 'grids_list': luigi.LocalTarget( - os.path.join( - self.params_folder, - 'output/grids_info.json') - ) - } - - @property - def input_artifacts(self): - return [ - {'name': 'input_grid', 'to': 'grid.pts', 'from': self.input_grid}] - - @property - def output_artifacts(self): - return [ - { - 'name': 'output-folder', 'from': 'output', - 'to': os.path.join(self.execution_folder, 'sub_grids') - }] - - @property - def output_parameters(self): - return [{'name': 'grids-list', 'from': 'output/grids_info.json', 'to': os.path.join(self.params_folder, 'output/grids_info.json')}] - - -class _DirectSunHoursEntryLoopOrchestrator(luigi.WrapperTask): - """Runs all the tasks in this module.""" - # user input for this module - _input_params = luigi.DictParameter() - - @property - def input_values(self): - params = dict(_default_inputs) - params.update(dict(self._input_params)) - return params - - def requires(self): - return [MergeResults(_input_params=self.input_values)] diff --git a/direct_sun_hours/flow/main.py b/direct_sun_hours/flow/main.py deleted file mode 100644 index ed51680..0000000 --- a/direct_sun_hours/flow/main.py +++ /dev/null @@ -1,412 +0,0 @@ -import luigi -import os -from queenbee_local import QueenbeeTask -from .dependencies.direct_sun_hours_ray_tracing import _DirectSunHoursEntryLoopOrchestrator as DirectSunHoursEntryLoopWorkerbee - - -_default_inputs = { 'model': None, - 'north': 0.0, - 'params_folder': '__params', - 'sensor_count': 200, - 'simulation_folder': '.', - 'wea': None} - - -class CreateOctree(QueenbeeTask): - """Generate an octree from a Radiance folder and a sky!""" - - # DAG Input parameters - _input_params = luigi.DictParameter() - - # Task inputs - black_out = luigi.Parameter(default='default') - - include_aperture = luigi.Parameter(default='include') - - @property - def model(self): - value = self.input()['CreateRadFolder']['model_folder'].path.replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def sky(self): - value = self.input()['GenerateSunpath']['sunpath'].path.replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def execution_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def initiation_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def params_folder(self): - return os.path.join(self.execution_folder, self._input_params['params_folder']).replace('\\', '/') - - def command(self): - return 'honeybee-radiance octree from-folder model --output scene.oct --{include_aperture}-aperture --{black_out} --add-before sky.sky'.format(include_aperture=self.include_aperture, black_out=self.black_out) - - def requires(self): - return {'GenerateSunpath': GenerateSunpath(_input_params=self._input_params), 'CreateRadFolder': CreateRadFolder(_input_params=self._input_params)} - - def output(self): - return { - 'scene_file': luigi.LocalTarget( - os.path.join(self.execution_folder, 'resources/scene_with_suns.oct') - ) - } - - @property - def input_artifacts(self): - return [ - {'name': 'model', 'to': 'model', 'from': self.model}, - {'name': 'sky', 'to': 'sky.sky', 'from': self.sky}] - - @property - def output_artifacts(self): - return [ - { - 'name': 'scene-file', 'from': 'scene.oct', - 'to': os.path.join(self.execution_folder, 'resources/scene_with_suns.oct') - }] - - -class CreateRadFolder(QueenbeeTask): - """Create a Radiance folder from a HBJSON input file.""" - - # DAG Input parameters - _input_params = luigi.DictParameter() - - # Task inputs - @property - def input_model(self): - value = self._input_params['model'].replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def execution_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def initiation_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def params_folder(self): - return os.path.join(self.execution_folder, self._input_params['params_folder']).replace('\\', '/') - - def command(self): - return 'honeybee-radiance translate model-to-rad-folder model.hbjson' - - def output(self): - return { - - 'model_folder': luigi.LocalTarget( - os.path.join(self.execution_folder, 'model') - ), - - 'sensor_grids_file': luigi.LocalTarget( - os.path.join(self.execution_folder, 'results/grids_info.json') - ), - 'sensor_grids': luigi.LocalTarget( - os.path.join( - self.params_folder, - 'model/grid/_info.json') - ) - } - - @property - def input_artifacts(self): - return [ - {'name': 'input_model', 'to': 'model.hbjson', 'from': self.input_model}] - - @property - def output_artifacts(self): - return [ - { - 'name': 'model-folder', 'from': 'model', - 'to': os.path.join(self.execution_folder, 'model') - }, - - { - 'name': 'sensor-grids-file', 'from': 'model/grid/_info.json', - 'to': os.path.join(self.execution_folder, 'results/grids_info.json') - }] - - @property - def output_parameters(self): - return [{'name': 'sensor-grids', 'from': 'model/grid/_info.json', 'to': os.path.join(self.params_folder, 'model/grid/_info.json')}] - - -class DirectSunHoursEntryLoopLoop(luigi.Task): - """No description is provided.""" - - # DAG Input parameters - _input_params = luigi.DictParameter() - - # Task inputs - @property - def sensor_count(self): - return self._input_params['sensor_count'] - - @property - def grid_name(self): - return self.item['name'] - - @property - def octree_file(self): - value = self.input()['CreateOctree']['scene_file'].path.replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def sensor_grid(self): - value = os.path.join(self.input()['CreateRadFolder']['model_folder'].path, 'grid/{item_name}.pts'.format(item_name=self.item['name'])).replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def sunpath(self): - value = self.input()['GenerateSunpath']['sunpath'].path.replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def sun_modifiers(self): - value = self.input()['GenerateSunpath']['sun_modifiers'].path.replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - # get item for loop - try: - item = luigi.DictParameter() - except Exception: - item = luigi.Parameter() - - @property - def execution_folder(self): - return os.path.join(self._input_params['simulation_folder'], 'initial_results/{item_name}'.format(item_name=self.item['name'])).replace('\\', '/') - - @property - def initiation_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def params_folder(self): - return os.path.join(self.execution_folder, self._input_params['params_folder']).replace('\\', '/') - - @property - def map_dag_inputs(self): - """Map task inputs to DAG inputs.""" - inputs = { - 'simulation_folder': self.execution_folder, - 'sensor_count': self.sensor_count, - 'octree_file': self.octree_file, - 'grid_name': self.grid_name, - 'sensor_grid': self.sensor_grid, - 'sunpath': self.sunpath, - 'sun_modifiers': self.sun_modifiers - } - try: - inputs['__debug__'] = self._input_params['__debug__'] - except KeyError: - # not debug mode - pass - - return inputs - - def run(self): - yield [DirectSunHoursEntryLoopWorkerbee(_input_params=self.map_dag_inputs)] - with open(os.path.join(self.execution_folder, 'direct_sun_hours_raytracing.done'), 'w') as out_file: - out_file.write('done!\n') - - def requires(self): - return {'CreateOctree': CreateOctree(_input_params=self._input_params), 'GenerateSunpath': GenerateSunpath(_input_params=self._input_params), 'CreateRadFolder': CreateRadFolder(_input_params=self._input_params)} - - def output(self): - return { - 'is_done': luigi.LocalTarget(os.path.join(self.execution_folder, 'direct_sun_hours_raytracing.done')) - } - - -class DirectSunHoursEntryLoop(luigi.Task): - """No description is provided.""" - # global parameters - _input_params = luigi.DictParameter() - @property - def sensor_grids(self): - value = self.input()['CreateRadFolder']['sensor_grids'].path.replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def items(self): - try: - # assume the input is a file - return QueenbeeTask.load_input_param(self.sensor_grids) - except: - # it is a parameter - return self.input()['CreateRadFolder']['sensor_grids'].path - - def run(self): - yield [DirectSunHoursEntryLoopLoop(item=item, _input_params=self._input_params) for item in self.items] - with open(os.path.join(self.execution_folder, 'direct_sun_hours_raytracing.done'), 'w') as out_file: - out_file.write('done!\n') - - @property - def initiation_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def execution_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def params_folder(self): - return os.path.join(self.execution_folder, self._input_params['params_folder']).replace('\\', '/') - - def requires(self): - return {'CreateOctree': CreateOctree(_input_params=self._input_params), 'GenerateSunpath': GenerateSunpath(_input_params=self._input_params), 'CreateRadFolder': CreateRadFolder(_input_params=self._input_params)} - - def output(self): - return { - 'is_done': luigi.LocalTarget(os.path.join(self.execution_folder, 'direct_sun_hours_raytracing.done')) - } - - -class GenerateSunpath(QueenbeeTask): - """Generate a Radiance sun matrix (AKA sun-path).""" - - # DAG Input parameters - _input_params = luigi.DictParameter() - - # Task inputs - @property - def north(self): - return self._input_params['north'] - - @property - def output_type(self): - return '1' - - @property - def wea(self): - value = self._input_params['wea'].replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def execution_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def initiation_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def params_folder(self): - return os.path.join(self.execution_folder, self._input_params['params_folder']).replace('\\', '/') - - def command(self): - return 'gendaymtx -n -D sunpath.mtx -M suns.mod -O{output_type} -r {north} -v sky.wea'.format(output_type=self.output_type, north=self.north) - - def output(self): - return { - 'sunpath': luigi.LocalTarget( - os.path.join(self.execution_folder, 'resources/sunpath.mtx') - ), - - 'sun_modifiers': luigi.LocalTarget( - os.path.join(self.execution_folder, 'resources/suns.mod') - ) - } - - @property - def input_artifacts(self): - return [ - {'name': 'wea', 'to': 'sky.wea', 'from': self.wea}] - - @property - def output_artifacts(self): - return [ - { - 'name': 'sunpath', 'from': 'sunpath.mtx', - 'to': os.path.join(self.execution_folder, 'resources/sunpath.mtx') - }, - - { - 'name': 'sun-modifiers', 'from': 'suns.mod', - 'to': os.path.join(self.execution_folder, 'resources/suns.mod') - }] - - -class ParseSunUpHours(QueenbeeTask): - """Parse sun up hours from sun modifiers file.""" - - # DAG Input parameters - _input_params = luigi.DictParameter() - - # Task inputs - @property - def sun_modifiers(self): - value = self.input()['GenerateSunpath']['sun_modifiers'].path.replace('\\', '/') - return value if os.path.isabs(value) \ - else os.path.join(self.initiation_folder, value) - - @property - def execution_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def initiation_folder(self): - return self._input_params['simulation_folder'].replace('\\', '/') - - @property - def params_folder(self): - return os.path.join(self.execution_folder, self._input_params['params_folder']).replace('\\', '/') - - def command(self): - return 'honeybee-radiance sunpath parse-hours suns.mod --name sun-up-hours.txt' - - def requires(self): - return {'GenerateSunpath': GenerateSunpath(_input_params=self._input_params)} - - def output(self): - return { - 'sun_up_hours': luigi.LocalTarget( - os.path.join(self.execution_folder, 'results/sun-up-hours.txt') - ) - } - - @property - def input_artifacts(self): - return [ - {'name': 'sun_modifiers', 'to': 'suns.mod', 'from': self.sun_modifiers}] - - @property - def output_artifacts(self): - return [ - { - 'name': 'sun-up-hours', 'from': 'sun-up-hours.txt', - 'to': os.path.join(self.execution_folder, 'results/sun-up-hours.txt') - }] - - -class _MainOrchestrator(luigi.WrapperTask): - """Runs all the tasks in this module.""" - # user input for this module - _input_params = luigi.DictParameter() - - @property - def input_values(self): - params = dict(_default_inputs) - params.update(dict(self._input_params)) - return params - - def requires(self): - return [DirectSunHoursEntryLoop(_input_params=self.input_values), ParseSunUpHours(_input_params=self.input_values)] diff --git a/direct_sun_hours/package.json b/direct_sun_hours/package.json deleted file mode 100644 index 28b94d2..0000000 --- a/direct_sun_hours/package.json +++ /dev/null @@ -1,212 +0,0 @@ -{ - "type": "RecipeInterface", - "annotations": {}, - "api_version": "v1beta1", - "metadata": { - "type": "MetaData", - "annotations": {}, - "name": "direct-sun-hours", - "tag": "0.0.0", - "app_version": null, - "keywords": [ - "honeybee", - "radiance", - "ladybug-tools", - "daylight", - "direct-sun-hours" - ], - "maintainers": [ - { - "type": "Maintainer", - "annotations": {}, - "name": "mostapha", - "email": "mostapha@ladybug.tools" - }, - { - "type": "Maintainer", - "annotations": {}, - "name": "ladybug-tools", - "email": "info@ladybug.tools" - } - ], - "home": "https://github.com/pollination/direct-sun-hours", - "sources": [ - "https://hub.docker.com/r/ladybugtools/honeybee-radiance" - ], - "icon": "https://raw.githubusercontent.com/ladybug-tools/artwork/master/icons_components/honeybee/png/annualrecipe.png", - "deprecated": null, - "description": "Direct sun hours recipe for Pollination.", - "license": { - "type": "License", - "annotations": {}, - "name": "PolyForm Shield License 1.0.0", - "url": "https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt" - } - }, - "source": null, - "inputs": [ - { - "type": "DAGFileInput", - "annotations": {}, - "name": "model", - "description": "A Honeybee model in HBJSON file format.", - "default": null, - "alias": [ - { - "type": "DAGGenericInputAlias", - "annotations": {}, - "name": "model", - "description": "A path to a HBJSON file or a HB model object built with Python or dotnet libraries.", - "platform": [ - "grasshopper" - ], - "handler": [ - { - "type": "IOAliasHandler", - "annotations": {}, - "language": "python", - "module": "pollination_handlers.inputs.model", - "function": "model_to_json" - }, - { - "type": "IOAliasHandler", - "annotations": {}, - "language": "csharp", - "module": "HoneybeeSchema.Handlers", - "function": "HBModelToJSON" - } - ], - "default": null, - "required": true, - "spec": null - }, - { - "type": "DAGLinkedInputAlias", - "annotations": {}, - "name": "model", - "description": "This input links the model to Rhino model.", - "platform": [ - "rhino" - ], - "handler": [ - { - "type": "IOAliasHandler", - "annotations": {}, - "language": "csharp", - "module": "HoneybeeRhino.Handlers", - "function": "RhinoHBModelToJSON" - } - ], - "default": null, - "required": true, - "spec": null - } - ], - "required": true, - "spec": null, - "extensions": [ - "json", - "hbjson" - ] - }, - { - "type": "DAGNumberInput", - "annotations": {}, - "name": "north", - "description": "A number for rotation from north.", - "default": 0.0, - "alias": [ - { - "type": "DAGGenericInputAlias", - "annotations": {}, - "name": "north", - "description": "Either a Vector2D for the north direction or a number between -360 and 360 for the counterclockwise difference between the North and the positive Y-axis in degrees.", - "platform": [ - "grasshopper" - ], - "handler": [ - { - "type": "IOAliasHandler", - "annotations": {}, - "language": "python", - "module": "pollination_handlers.inputs.north", - "function": "north_vector_to_angle" - } - ], - "default": null, - "required": true, - "spec": null - } - ], - "required": false, - "spec": { - "type": "number", - "minimum": 0, - "maximum": 360 - } - }, - { - "type": "DAGIntegerInput", - "annotations": {}, - "name": "sensor-count", - "description": "The maximum number of grid points per parallel execution.", - "default": 200, - "alias": [], - "required": false, - "spec": { - "type": "integer", - "minimum": 1 - } - }, - { - "type": "DAGFileInput", - "annotations": {}, - "name": "wea", - "description": "Wea file.", - "default": null, - "alias": [ - { - "type": "DAGGenericInputAlias", - "annotations": {}, - "name": "wea", - "description": "Either a Wea python object or the path to a wea or an epw file.", - "platform": [ - "grasshopper" - ], - "handler": [ - { - "type": "IOAliasHandler", - "annotations": {}, - "language": "python", - "module": "pollination_handlers.inputs.wea", - "function": "wea_handler" - } - ], - "default": null, - "required": true, - "spec": null - } - ], - "required": true, - "spec": null, - "extensions": [ - "wea" - ] - } - ], - "outputs": [ - { - "type": "DAGFolderOutput", - "annotations": {}, - "name": "results", - "description": null, - "from": { - "type": "FolderReference", - "annotations": {}, - "path": "results" - }, - "alias": [], - "required": true - } - ] -} \ No newline at end of file diff --git a/direct_sun_hours/run.py b/direct_sun_hours/run.py deleted file mode 100644 index b3d065d..0000000 --- a/direct_sun_hours/run.py +++ /dev/null @@ -1,55 +0,0 @@ -import sys -import luigi -import os -import time -from multiprocessing import freeze_support -from queenbee_local import local_scheduler, _copy_artifacts, update_params, parse_input_args - -import flow.main as direct_sun_hours_workerbee - - -_recipe_default_inputs = {'model': None, 'north': 0.0, 'sensor_count': 200, 'wea': None} - - -class LetDirectSunHoursFly(luigi.WrapperTask): - # global parameters - _input_params = luigi.DictParameter() - - def requires(self): - yield [direct_sun_hours_workerbee._MainOrchestrator(_input_params=self._input_params)] - - -def start(project_folder, user_values, workers): - freeze_support() - - input_params = update_params(_recipe_default_inputs, user_values) - - if 'simulation_folder' not in input_params or not input_params['simulation_folder']: - if 'simulation_id' not in input_params or not input_params['simulation_id']: - simulation_id = 'direct_sun_hours_%d' % int(round(time.time(), 2) * 100) - else: - simulation_id = input_params['simulation_id'] - - simulation_folder = os.path.join(project_folder, simulation_id) - input_params['simulation_folder'] = simulation_folder - else: - simulation_folder = input_params['simulation_folder'] - - # copy project folder content to simulation folder - artifacts = ['model', 'wea'] - for artifact in artifacts: - from_ = os.path.join(project_folder, input_params[artifact]) - to_ = os.path.join(simulation_folder, input_params[artifact]) - _copy_artifacts(from_, to_) - - luigi.build( - [LetDirectSunHoursFly(_input_params=input_params)], - local_scheduler=local_scheduler(), - workers=workers - ) - - - -if __name__ == '__main__': - project_folder, user_values, workers = parse_input_args(sys.argv) - start(project_folder, user_values, workers)