{"id":22468316,"url":"https://github.com/pollination/pollination-dsl","last_synced_at":"2025-08-02T08:32:11.056Z","repository":{"id":43901678,"uuid":"324384998","full_name":"pollination/pollination-dsl","owner":"pollination","description":"A Python library for creating Pollination plugins and recipes.","archived":false,"fork":false,"pushed_at":"2024-10-22T20:07:26.000Z","size":763,"stargazers_count":6,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-15T20:41:23.319Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pollination.github.io/pollination-dsl/docs/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pollination.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-25T15:16:50.000Z","updated_at":"2024-10-22T20:06:29.000Z","dependencies_parsed_at":"2024-06-21T17:41:17.079Z","dependency_job_id":"743496b2-4609-481e-8809-baa8e672ba50","html_url":"https://github.com/pollination/pollination-dsl","commit_stats":{"total_commits":133,"total_committers":3,"mean_commits":"44.333333333333336","dds":"0.12030075187969924","last_synced_commit":"f521460de7121596c830cd346dfb0f71ef320394"},"previous_names":["pollination/queenbee-python-dsl"],"tags_count":61,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pollination%2Fpollination-dsl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pollination%2Fpollination-dsl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pollination%2Fpollination-dsl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pollination%2Fpollination-dsl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pollination","download_url":"https://codeload.github.com/pollination/pollination-dsl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228453987,"owners_count":17922585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-06T11:16:19.246Z","updated_at":"2024-12-06T11:16:20.030Z","avatar_url":"https://github.com/pollination.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pollination-dsl\nA Python Domain Specific Language (DSL) to create Pollination Plugins and Recipes.\n\nPollination uses [Queenbee](https://github.com/pollination/queenbee) as its workflow\nlanguage. Pollination-dsl makes it easy to create Queenbee object without the need to\nlearn Queenbee.\n\n![pollination-dsl](https://user-images.githubusercontent.com/2915573/106669142-36d04880-6579-11eb-9763-a718aec27166.jpg)\n\n# API docs\n[Pollination-DSL API docs](https://pollination.github.io/pollination-dsl/docs/pollination_dsl.html#subpackages)\n\n# Requirements\nPython \u003e=3.7\n\n# Installation\n\nUsing pip:\n\n`pip install pollination-dsl`\n\nFor local development:\n\n1. Clone this repository.\n2. Change directory to root folder of the repository.\n3. `pip install -e .`\n\n## Function\n\n```python\nfrom dataclasses import dataclass\nfrom pollination_dsl.function import Function, command, Inputs, Outputs\n\n\n@dataclass\nclass CreateOctreeWithSky(Function):\n    \"\"\"Generate an octree from a Radiance folder and sky!\"\"\"\n\n    # inputs\n    include_aperture = Inputs.str(\n        default='include',\n        description='A value to indicate if the static aperture should be included in '\n        'octree. Valid values are include and exclude. Default is include.',\n        spec={'type': 'string', 'enum': ['include', 'exclude']}\n    )\n\n    black_out = Inputs.str(\n        default='default',\n        description='A value to indicate if the black material should be used. Valid '\n        'values are default and black. Default value is default.',\n        spec={'type': 'string', 'enum': ['black', 'default']}\n    )\n\n    model = Inputs.folder(description='Path to Radiance model folder.', path='model')\n\n    sky = Inputs.file(description='Path to sky file.', path='sky.sky')\n\n    @command\n    def create_octree(self):\n        return 'honeybee-radiance octree from-folder model --output scene.oct ' \\\n            '--{{self.include_aperture}}-aperture --{{self.black_out}} ' \\\n            '--add-before sky.sky'\n\n    # outputs\n    scene_file = Outputs.file(description='Output octree file.', path='scene.oct')\n\n```\n\nIf you want to access the `Queenbee` objects you can use `queenbee` property. For example\ntry `print(CreateOctreeWithSky().queenbee.yaml())` and you should see the full Queenbee\ndefinition:\n\n```yaml\ntype: Function\nannotations: {}\ninputs:\n- type: FunctionStringInput\n  annotations: {}\n  name: black-out\n  description: A value to indicate if the black material should be used. Valid values\n    are default and black. Default value is default.\n  default: default\n  alias: []\n  required: false\n  spec:\n    type: string\n    enum:\n    - black\n    - default\n- type: FunctionStringInput\n  annotations: {}\n  name: include-aperture\n  description: A value to indicate if the static aperture should be included in octree.\n    Valid values are include and exclude. Default is include.\n  default: include\n  alias: []\n  required: false\n  spec:\n    type: string\n    enum:\n    - include\n    - exclude\n- type: FunctionFolderInput\n  annotations: {}\n  name: model\n  description: Path to Radiance model folder.\n  default: null\n  alias: []\n  required: true\n  spec: null\n  path: model\n- type: FunctionFileInput\n  annotations: {}\n  name: sky\n  description: Path to sky file.\n  default: null\n  alias: []\n  required: true\n  spec: null\n  path: sky.sky\n  extensions: null\noutputs:\n- type: FunctionFileOutput\n  annotations: {}\n  name: scene-file\n  description: Output octree file.\n  path: scene.oct\nname: create-octree-with-sky\ndescription: Generate an octree from a Radiance folder and sky!\ncommand: honeybee-radiance octree from-folder model --output scene.oct --{{inputs.include-aperture}}-aperture\n  --{{inputs.black-out}} --add-before sky.sky\n```\n\nSince the functions are standard Python classes you can also subclass them from one\nanother as long as you use the same name for the `@command` method. Otherwise it will\ncreate an invalid function with two commands.\n\n## Plugin\n\nTo create a Pollination plugin use the functions to create a standard Python module.\nThe only change is that you need to provide the information for Pollination plugin in\nthe `__init__.py` file as dictionary assigned to `__pollination__` variable.\n\nFollow the standard way to install a Python package. Once the package is installed you\ncan use `pollination-dsl` to load the package or write it to a folder.\n\n```python\nfrom pollination_dsl.package import load, write\n\n# name of the pollination package\npython_package = 'pollination_honeybee_radiance'\n\n# load this package as Pollination Plugin\nplugin = load(python_package)\n\n# or write the package as a Pollination plugin to a folder directly\nwrite(python_package, './pollination-honeybee-radiance')\n\n```\n\nHere are two real world examples of Pollination plugins:\n\n- [`pollination-honeybee-radiance` plugin](https://github.com/pollination/honeybee-radiance)\n- [`pollination-honeybee-energy` plugin](https://github.com/pollination/honeybee-energy)\n\n## Recipe\n\n`Recipe` is a collection of `DAG`s. Each `DAG` is a collection of interrelated `task`s.\nYou can use pollination-dsl to create complex recipes with minimum code by reusing the\n`functions` as templates for each task.\n\nPackaging a plugin is exactly the same as packaging a plugin.\n\n```python\nfrom pollination_dsl.package import load, translate\n\n# name of the pollination package\npython_package = 'daylight-factor'\n\n# load this package as Pollination Recipe\nrecipe = load(python_package, baked=True)\n\n# or translate and write the package as a Pollination plugin to a folder directly\ntranslate(python_package, './daylight-factor')\n\n```\n\nHere are number of real world examples of Pollination recipes:\n\n- [`Annual energy use` recipe](https://github.com/pollination/annual-energy-use)\n- [`Daylight factor` recipe](https://github.com/pollination/daylight-factor)\n- [`Annual daylight` recipe](https://github.com/pollination/annual-daylight)\n\n\n# How to create a pollination-dsl package\n\nPollination-dsl uses Python's standard packaging to package pollination plugins and recipes.\nIt parses most of the data from inputs in `setup.py` file and some Pollination specific\ninformation from `__init__.py` file. Below is an example of how these file should look\nlike.\n\nBy taking advantage of [Python's native namespace packaging](https://packaging.python.org/guides/packaging-namespace-packages/#native-namespace-packages)\nwe keep all the packages under the `pollination` namespace.\n\n## setup.py\n\nHere is an example `setup.py` file. You can see the latest version of the file [here](https://github.com/pollination/honeybee-radiance/blob/master/setup.py).\n\n```python\n\n#!/usr/bin/env python\nimport setuptools\n\nwith open(\"README.md\", \"r\") as fh:\n    long_description = fh.read()\n\nwith open('requirements.txt') as f:\n    requirements = f.read().splitlines()\n\nsetuptools.setup(\n    name='pollination-honeybee-radiance',                                   # required - will be used for package name\n    author='ladybug-tools',                                                 # required - author must match the owner account name on Pollination\n    author_email='info@ladybug.tools',\n    packages=setuptools.find_namespace_packages(include=['pollination.*']), # required - that's how pollination find the package\n    version='0.1.0',                                                        # required - will be used as package tag. you can also use semantic versioning\n    install_requires=requirements,\n    url='https://github.com/pollination/pollination-honeybee-radiance',     # optional - will be translated to home\n    project_urls={\n        'icon': 'https://raw.githubusercontent.com/ladybug-tools/artwork/master/icons_bugs/grasshopper_tabs/HB-Radiance.png',                    # optional but strongly encouraged - link to package icon\n    },\n    description='Honeybee Radiance plugin for Pollination.',                # optional - will be used as package description\n    long_description=long_description,                                      # optional - will be translated to ReadMe content on Pollination\n    long_description_content_type=\"text/markdown\",\n    maintainer='maintainer_1, maintainer_2',                                # optional - will be translated to maintainers. For multiple maintainers\n    maintainer_email='maintainer_1@example.come, maintainer_2@example.com', # use comma inside the string.\n    keywords='honeybee, radiance, ladybug-tools, daylight',                 # optional - will be used as keywords\n    license='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 comma\n    zip_safe=False                                                         # required - set to False to ensure the packaging will always work\n)\n\n```\n\n## __init__.py\n\nHere is an example `__init__.py` for a plugin. The latest version of the file is\naccessible [here](https://github.com/pollination/honeybee-radiance/blob/master/pollination/honeybee_radiance/__init__.py).\n\n\n```python\n\n\"\"\"Honeybee Radiance plugin for Pollination.\"\"\"\nfrom pollination_dsl.common import get_docker_image_from_dependency\n\n# set the version for docker image dynamically based on honeybee-radiance version\n# in dependencies\nimage_id = get_docker_image_from_dependency(\n    __package__, 'honeybee-radiance', 'ladybugtools'\n)\n\n__pollination__ = {\n    'app_version': '5.4',  # optional - tag for version of Radiance\n    'config': {\n        'docker': {\n            'image': image_id,\n            'workdir': '/home/ladybugbot/run'\n        }\n    }\n}\n```\n\nHere is an example `__init__.py` for a recipe. The latest version of the file is\naccessible [here](https://github.com/pollination/annual-daylight/blob/master/pollination/annual_daylight/__init__.py).\n\n```python\nfrom .entry import AnnualDaylightEntryPoint\n\n__pollination__ = {\n    'entry_point': AnnualDaylightEntryPoint\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpollination%2Fpollination-dsl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpollination%2Fpollination-dsl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpollination%2Fpollination-dsl/lists"}