Skip to content

Commit

Permalink
fix(pit-view): Ensure recipe can run with spaces in path
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Apr 17, 2022
1 parent dac314e commit 5172d5f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
import pathlib
from queenbee_local import QueenbeeTask
from queenbee_local import load_input_param as qb_load_input_param


_default_inputs = { 'bsdfs': None,
Expand Down Expand Up @@ -77,7 +78,7 @@ def initiation_folder(self):

@property
def params_folder(self):
return pathlib.Path(self.initiation_folder, self._input_params['params_folder']).resolve().as_posix()
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def command(self):
return 'honeybee-radiance view merge input_folder view {extension} --scale-factor {scale_factor} --name {name} --view original-view.vf'.format(extension=self.extension, scale_factor=self.scale_factor, name=self.name)
Expand Down Expand Up @@ -182,7 +183,7 @@ def initiation_folder(self):

@property
def params_folder(self):
return pathlib.Path(self.initiation_folder, self._input_params['params_folder']).resolve().as_posix()
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def command(self):
return 'honeybee-radiance rpict rpict scene.oct view.vf --rad-params "{radiance_parameters}" --metric {metric} --resolution {resolution} --scale-factor {scale_factor} --output view.HDR'.format(radiance_parameters=self.radiance_parameters, metric=self.metric, resolution=self.resolution, scale_factor=self.scale_factor)
Expand Down Expand Up @@ -230,10 +231,10 @@ def views_list(self):
def items(self):
try:
# assume the input is a file
return QueenbeeTask.load_input_param(self.views_list)
return qb_load_input_param(self.views_list)
except:
# it is a parameter
return pathlib.Path(self.input()['SplitView']['views_list'].path).as_posix()
return self.input()['SplitView']['views_list'].path

def run(self):
yield [RayTracingLoop(item=item, _input_params=self._input_params) for item in self.items]
Expand All @@ -251,7 +252,7 @@ def execution_folder(self):

@property
def params_folder(self):
return pathlib.Path(self.initiation_folder, self._input_params['params_folder']).resolve().as_posix()
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def requires(self):
return {'SplitView': SplitView(_input_params=self._input_params)}
Expand Down Expand Up @@ -323,10 +324,10 @@ def initiation_folder(self):

@property
def params_folder(self):
return pathlib.Path(self.initiation_folder, self._input_params['params_folder']).resolve().as_posix()
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def command(self):
return 'honeybee-radiance view split view.vf {view_count} --resolution {resolution} --{overture} --octree {scene_file} --rad-params "{radiance_parameters}" --folder output --log-file output/views_info.json'.format(view_count=self.view_count, resolution=self.resolution, overture=self.overture, scene_file=self.scene_file, radiance_parameters=self.radiance_parameters)
return 'honeybee-radiance view split view.vf {view_count} --resolution {resolution} --{overture} --octree scene.oct --rad-params "{radiance_parameters}" --folder output --log-file output/views_info.json'.format(view_count=self.view_count, resolution=self.resolution, overture=self.overture, radiance_parameters=self.radiance_parameters)

def output(self):
return {
Expand Down Expand Up @@ -374,7 +375,7 @@ def output_parameters(self):
return [{'name': 'views-list', 'from': 'output/views_info.json', 'to': pathlib.Path(self.params_folder, 'output/views_info.json').resolve().as_posix()}]


class _PointInTimeViewRayTracing_f677f6a5Orchestrator(luigi.WrapperTask):
class _PointInTimeViewRayTracing_49541c51Orchestrator(luigi.WrapperTask):
"""Runs all the tasks in this module."""
# user input for this module
_input_params = luigi.DictParameter()
Expand Down
34 changes: 16 additions & 18 deletions lbt_recipes/point_in_time_view/flow/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import os
import pathlib
from queenbee_local import QueenbeeTask
from .dependencies.point_in_time_view_ray_tracing import _PointInTimeViewRayTracing_f677f6a5Orchestrator as PointInTimeViewRayTracing_f677f6a5Workerbee
from queenbee_local import load_input_param as qb_load_input_param
from .dependencies.point_in_time_view_ray_tracing import _PointInTimeViewRayTracing_49541c51Orchestrator as PointInTimeViewRayTracing_49541c51Workerbee


_default_inputs = { 'cpu_count': 12,
Expand Down Expand Up @@ -61,7 +62,7 @@ def initiation_folder(self):

@property
def params_folder(self):
return pathlib.Path(self.initiation_folder, self._input_params['params_folder']).resolve().as_posix()
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def command(self):
return 'honeybee-radiance sky adjust-for-metric input.sky --metric {metric}'.format(metric=self.metric)
Expand Down Expand Up @@ -119,7 +120,7 @@ def initiation_folder(self):

@property
def params_folder(self):
return pathlib.Path(self.initiation_folder, self._input_params['params_folder']).resolve().as_posix()
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def command(self):
return 'honeybee-radiance view split-count view_info.json {cpu_count} --output-file view-split-count.txt'.format(cpu_count=self.cpu_count)
Expand Down Expand Up @@ -178,7 +179,7 @@ def initiation_folder(self):

@property
def params_folder(self):
return pathlib.Path(self.initiation_folder, self._input_params['params_folder']).resolve().as_posix()
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

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)
Expand Down Expand Up @@ -237,7 +238,7 @@ def initiation_folder(self):

@property
def params_folder(self):
return pathlib.Path(self.initiation_folder, self._input_params['params_folder']).resolve().as_posix()
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def command(self):
return 'honeybee-radiance translate model-to-rad-folder model.hbjson --view "{view_filter}" --view-check'.format(view_filter=self.view_filter)
Expand Down Expand Up @@ -318,7 +319,7 @@ def initiation_folder(self):

@property
def params_folder(self):
return pathlib.Path(self.initiation_folder, self._input_params['params_folder']).resolve().as_posix()
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def command(self):
return 'honeybee-radiance sky {sky_string} --name output.sky'.format(sky_string=self.sky_string)
Expand Down Expand Up @@ -366,12 +367,9 @@ def radiance_parameters(self):

@property
def view_count(self):
return QueenbeeTask.load_input_param(
pathlib.Path(
self.params_folder,
os.path.split(self.input()['ComputeViewSplitCount']['split_count'].path)[-1]
).resolve().as_posix()
)
return qb_load_input_param(
self.input()['ComputeViewSplitCount']['split_count'].path
)

@property
def view_name(self):
Expand Down Expand Up @@ -416,7 +414,7 @@ def initiation_folder(self):

@property
def params_folder(self):
return pathlib.Path(self.initiation_folder, self._input_params['params_folder']).resolve().as_posix()
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

@property
def map_dag_inputs(self):
Expand All @@ -442,7 +440,7 @@ def map_dag_inputs(self):
return inputs

def run(self):
yield [PointInTimeViewRayTracing_f677f6a5Workerbee(_input_params=self.map_dag_inputs)]
yield [PointInTimeViewRayTracing_49541c51Workerbee(_input_params=self.map_dag_inputs)]
done_file = pathlib.Path(self.execution_folder, 'point_in_time_view_ray_tracing.done')
done_file.parent.mkdir(parents=True, exist_ok=True)
done_file.write_text('done!')
Expand Down Expand Up @@ -470,10 +468,10 @@ def views(self):
def items(self):
try:
# assume the input is a file
return QueenbeeTask.load_input_param(self.views)
return qb_load_input_param(self.views)
except:
# it is a parameter
return pathlib.Path(self.input()['CreateRadFolder']['views'].path).as_posix()
return self.input()['CreateRadFolder']['views'].path

def run(self):
yield [PointInTimeViewRayTracingLoop(item=item, _input_params=self._input_params) for item in self.items]
Expand All @@ -491,7 +489,7 @@ def execution_folder(self):

@property
def params_folder(self):
return pathlib.Path(self.initiation_folder, self._input_params['params_folder']).resolve().as_posix()
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def requires(self):
return {'CreateRadFolder': CreateRadFolder(_input_params=self._input_params), 'CreateOctree': CreateOctree(_input_params=self._input_params), 'ComputeViewSplitCount': ComputeViewSplitCount(_input_params=self._input_params)}
Expand All @@ -502,7 +500,7 @@ def output(self):
}


class _Main_f677f6a5Orchestrator(luigi.WrapperTask):
class _Main_49541c51Orchestrator(luigi.WrapperTask):
"""Runs all the tasks in this module."""
# user input for this module
_input_params = luigi.DictParameter()
Expand Down
2 changes: 1 addition & 1 deletion lbt_recipes/point_in_time_view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "MetaData",
"annotations": {},
"name": "point-in-time-view",
"tag": "0.3.1",
"tag": "0.3.2",
"app_version": null,
"keywords": [
"honeybee",
Expand Down
8 changes: 6 additions & 2 deletions lbt_recipes/point_in_time_view/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LetPointInTimeViewFly(luigi.WrapperTask):
_input_params = luigi.DictParameter()

def requires(self):
yield [point_in_time_view_workerbee._Main_f677f6a5Orchestrator(_input_params=self._input_params)]
yield [point_in_time_view_workerbee._Main_49541c51Orchestrator(_input_params=self._input_params)]


def start(project_folder, user_values, workers):
Expand Down Expand Up @@ -78,13 +78,17 @@ def start(project_folder, user_values, workers):
with cfg_file.open('w') as lf:
lf.write(LOGS_CONFIG.replace('WORKFLOW.LOG', log_file))

luigi.build(
summary = luigi.build(
[LetPointInTimeViewFly(_input_params=input_params)],
local_scheduler=local_scheduler(),
workers=workers,
detailed_summary=True,
logging_conf_file=cfg_file.as_posix()
)

print(summary.summary_text)
print(f'More info:\n{log_file}')


if __name__ == '__main__':
project_folder, user_values, workers = parse_input_args(sys.argv)
Expand Down

0 comments on commit 5172d5f

Please sign in to comment.