Package: pollination-dsl
pollination-dslA Python Domain Specific Language (DSL) to create Pollination Plugins and Recipes.Pollination usesQueenbeeas its workflow
language. Pollination-dsl makes it easy to create Queenbee object without the need to
learn Queenbee.API docsPollination-DSL API docsRequirementsPython >=3.7InstallationUsing pip:pip install pollination-dslFor local development:Clone this repository.Change directory to root folder of the repository.pip install -e .Functionfromdataclassesimportdataclassfrompollination_dsl.functionimportFunction,command,Inputs,Outputs@dataclassclassCreateOctreeWithSky(Function):"""Generate an octree from a Radiance folder and sky!"""# inputsinclude_aperture=Inputs.str(default='include',description='A value to indicate if the static aperture should be included in ''octree. Valid values are include and exclude. Default is include.',spec={'type':'string','enum':['include','exclude']})black_out=Inputs.str(default='default',description='A value to indicate if the black material should be used. Valid ''values are default and black. Default value is default.',spec={'type':'string','enum':['black','default']})model=Inputs.folder(description='Path to Radiance model folder.',path='model')sky=Inputs.file(description='Path to sky file.',path='sky.sky')@commanddefcreate_octree(self):return'honeybee-radiance octree from-folder model --output scene.oct '\'--{{self.include_aperture}}-aperture --{{self.black_out}} '\'--add-before sky.sky'# outputsscene_file=Outputs.file(description='Output octree file.',path='scene.oct')If you want to access theQueenbeeobjects you can usequeenbeeproperty. For example
tryprint(CreateOctreeWithSky().queenbee.yaml())and you should see the full Queenbee
definition:type:Functionannotations:{}inputs:-type:FunctionStringInputannotations:{}name:black-outdescription:A value to indicate if the black material should be used. Valid valuesare default and black. Default value is default.default:defaultalias:[]required:falsespec:type:stringenum:-black-default-type:FunctionStringInputannotations:{}name:include-aperturedescription:A value to indicate if the static aperture should be included in octree.Valid values are include and exclude. Default is include.default:includealias:[]required:falsespec:type:stringenum:-include-exclude-type:FunctionFolderInputannotations:{}name:modeldescription:Path to Radiance model folder.default:nullalias:[]required:truespec:nullpath:model-type:FunctionFileInputannotations:{}name:skydescription:Path to sky file.default:nullalias:[]required:truespec:nullpath:sky.skyextensions:nulloutputs:-type:FunctionFileOutputannotations:{}name:scene-filedescription:Output octree file.path:scene.octname:create-octree-with-skydescription:Generate an octree from a Radiance folder and sky!command:honeybee-radiance octree from-folder model --output scene.oct --{{inputs.include-aperture}}-aperture--{{inputs.black-out}} --add-before sky.skySince the functions are standard Python classes you can also subclass them from one
another as long as you use the same name for the@commandmethod. Otherwise it will
create an invalid function with two commands.PluginTo create a Pollination plugin use the functions to create a standard Python module.
The only change is that you need to provide the information for Pollination plugin in
the__init__.pyfile as dictionary assigned to__pollination__variable.Follow the standard way to install a Python package. Once the package is installed you
can usepollination-dslto load the package or write it to a folder.frompollination_dsl.packageimportload,write# name of the pollination packagepython_package='pollination_honeybee_radiance'# load this package as Pollination Pluginplugin=load(python_package)# or write the package as a Pollination plugin to a folder directlywrite(python_package,'./pollination-honeybee-radiance')Here are two real world examples of Pollination plugins:pollination-honeybee-radiancepluginpollination-honeybee-energypluginRecipeRecipeis a collection ofDAGs. EachDAGis a collection of interrelatedtasks.
You can use pollination-dsl to create complex recipes with minimum code by reusing thefunctionsas templates for each task.Packaging a plugin is exactly the same as packaging a plugin.frompollination_dsl.packageimportload,translate# name of the pollination packagepython_package='daylight-factor'# load this package as Pollination Reciperecipe=load(python_package,baked=True)# or translate and write the package as a Pollination plugin to a folder directlytranslate(python_package,'./daylight-factor')Here are number of real world examples of Pollination recipes:Annual energy userecipeDaylight factorrecipeAnnual daylightrecipeHow to create a pollination-dsl packagePollination-dsl uses Python's standard packaging to package pollination plugins and recipes.
It parses most of the data from inputs insetup.pyfile and some Pollination specific
information from__init__.pyfile. Below is an example of how these file should look
like.By taking advantage ofPython's native namespace packagingwe keep all the packages under thepollinationnamespace.setup.pyHere is an examplesetup.pyfile. You can see the latest version of the filehere.#!/usr/bin/env pythonimportsetuptoolswithopen("README.md","r")asfh:long_description=fh.read()withopen('requirements.txt')asf:requirements=f.read().splitlines()setuptools.setup(name='pollination-honeybee-radiance',# required - will be used for package nameauthor='ladybug-tools',# required - author must match the owner account name on Pollinationauthor_email='info@ladybug.tools',packages=setuptools.find_namespace_packages(include=['pollination.*']),# required - that's how pollination find the packageversion='0.1.0',# required - will be used as package tag. you can also use semantic versioninginstall_requires=requirements,url='https://github.com/pollination/pollination-honeybee-radiance',# optional - will be translated to homeproject_urls={'icon':'https://raw.githubusercontent.com/ladybug-tools/artwork/master/icons_bugs/grasshopper_tabs/HB-Radiance.png',# optional but strongly encouraged - link to package icon},description='Honeybee Radiance plugin for Pollination.',# optional - will be used as package descriptionlong_description=long_description,# optional - will be translated to ReadMe content on Pollinationlong_description_content_type="text/markdown",maintainer='maintainer_1, maintainer_2',# optional - will be translated to maintainers. For multiple maintainersmaintainer_email='maintainer_1@example.come, maintainer_2@example.com',# use comma inside the string.keywords='honeybee, radiance, ladybug-tools, daylight',# optional - will be used as keywordslicense='PolyForm Shield License 1.0.0, https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt',# optional - the license link should be separated by a commazip_safe=False# required - set to False to ensure the packaging will always work)init.pyHere is an example__init__.pyfor a plugin. The latest version of the file is
accessiblehere."""Honeybee Radiance plugin for Pollination."""frompollination_dsl.commonimportget_docker_image_from_dependency# set the version for docker image dynamically based on honeybee-radiance version# in dependenciesimage_id=get_docker_image_from_dependency(__package__,'honeybee-radiance','ladybugtools')__pollination__={'app_version':'5.4',# optional - tag for version of Radiance'config':{'docker':{'image':image_id,'workdir':'/home/ladybugbot/run'}}}Here is an example__init__.pyfor a recipe. The latest version of the file is
accessiblehere.from.entryimportAnnualDaylightEntryPoint__pollination__={'entry_point':AnnualDaylightEntryPoint}