Skip to content

Schema harmonization#139

Merged
AntoineDao merged 16 commits intopollination:masterfrom
AntoineDao:schema-harmonization
Sep 22, 2020
Merged

Schema harmonization#139
AntoineDao merged 16 commits intopollination:masterfrom
AntoineDao:schema-harmonization

Conversation

@AntoineDao
Copy link
Copy Markdown
Member

This PR aims to enhance the existing repository primitives in Queenbee so they can be used by queenbee-luigi, queenbee-argo, pollination-server and other client libraries to manage, find and use Queenbee packages (ie: recipes and operators).

… operators

This cleans up the codebase a bit and means the JSON schema and OpenAPI models don't overlap and
rename themselves through pydantic.
@AntoineDao AntoineDao marked this pull request as draft September 17, 2020 17:06
@AntoineDao AntoineDao self-assigned this Sep 17, 2020
@AntoineDao AntoineDao added the enhancement New feature or request label Sep 17, 2020
…ackage metadata

The package metadata object can now be loaded with the manifest, readme and license inside of the
tgz file used to package recipes and operators. This primite can then be re-used by other queenbee
clients to make sense of packages (be it locally or from pollination for example).
When package is fetched using the `latest` tag from a repository Queenbee will look for the package
with the mosted recent `created` date

fix pollination#140
This metadata should help make native Queenbee primitives re-usable accross multiple UIs when
searching through indices and packages.

close pollination#141
Users can now add repositories to their queenbee config to make packages searchable through the CLI.
Removing use of two different words that mean the same thing. The folder that contains an index file + queenbee packages is called a "repository" not a "registry"
@AntoineDao AntoineDao marked this pull request as ready for review September 18, 2020 10:20
@AntoineDao
Copy link
Copy Markdown
Member Author

AntoineDao commented Sep 18, 2020

I have copy/pasted an excerpt from the documentation I have added to explain repository management and package fetching using the CLI. This should help @MingboPeng and @chriswmackey get a better idea of what's going on without reading through the PEP8 hell hole that is my code 😄

Manage Repositories

In order to make use of Queenbee packages on you local machine you must manage
a local index of repositories that you can reference.

The Queenbee CLI can be used to add, list and remove repositories from your local
index. Once a repository has been added to your local index you can search through the available
Queenbee packages (both operators and recipes) and fetch specific package versions for
use in a workflow.

Local Index Management

This sections walks through the basic management commands.

  1. Add a remote repository
> queenbee repo add ladybug https://api.pollination.cloud/registries/ladybug-tools
  1. Add a local repository. We will use the local-queenbee-repo from the previous section
> queenbee repo add local-repo path/to/local-queenbee-repo
  1. View the repositories that are listed in your local index
    > queenbee repo list

    [
      {
        "name": "local-repo",
        "description": "A Queenbee package repository",
        "source": "file:C:\path\to\local-queenbee-repo",
        "operator_count": 1,
        "recipe_count": 0
      },
      {
        "name": "ladybug",
        "description": "The official Ladybug-Tools Queenbee repository",
        "source": "https://api.pollination.cloud/registries/ladybug-tools",
        "operator_count": 3,
        "recipe_count": 8
      }
    ]
  1. Search for packages
    > queenbee repo search -s energy-plus

    [
        {
            "name": "honeybee-energy",
            "tag": "0.1.0",
            "app_version": "1.57.1",
            "keywords": [
              "ladybug-tools",
              "honeybee",
              "energy-plus",
              "openstudio",
              "energy"
            ],
            "maintainers": null,
            "home": "https://app.pollination.cloud/operators/ladybug-tools/honeybee-energy",
            "sources": [
              "https://github.com/ladybug-tools/honeybee-energy"
            ],
            "icon": "https://www.ladybug.tools/assets/img/logo.png",
            "deprecated": null,
            "description": "An operator to run energyplus using Honeybee and OpenStudio",
            "url": "operator/honeybee-energy/36dec1c7b2c169f62ae08d64f6cac6de4b3c192320ed10a0f8283a3be03aa4af",
            "created": "2020-06-30T11:07:15.744710",
            "digest": "36dec1c7b2c169f62ae08d64f6cac6de4b3c192320ed10a0f8283a3be03aa4af",
            "slug": "ladybug/honeybee-energy",
            "type": "operator"
        },
        {
            "name": "annual-energy-use",
            "tag": "0.2.3",
            "app_version": null,
            "keywords": [
              "ladybug-tools",
              "energy-plus",
              "openstudio",
              "energy",
              "default"
            ],
            "maintainers": [
              {
                "name": "chris",
                "email": "chris@ladybug.tools"
              }
            ],
            "home": null,
            "sources": null,
            "icon": "https://raw.githubusercontent.com/ladybug-tools/artwork/master/icons_components/honeybee/png/toidf.png",
            "deprecated": null,
            "description": "Run an annual energy simulation with default simulation parameters for reporting energy use",
            "url": "recipe/annual-energy-use/845b304acc1e1c45df6f6122e4b4955b97d610f3dc51b9e677fab664c6e91679",
            "created": "2020-09-02T04:43:10.034394",
            "digest": "845b304acc1e1c45df6f6122e4b4955b97d610f3dc51b9e677fab664c6e91679",
            "slug": "ladybug/annual-energy-use",
            "type": "recipe"
        },
        {
            "name": "energy-plus",
            "tag": "0.1.0",
            "app_version": "9.0.1",
            "keywords": [
                "energyplus"
            ],
            "maintainers": null,
            "home": "https://energyplus.net",
            "sources": [
                "https://github.com/nrel/energyplus"
            ],
            "icon": "https://energyplus.net/sites/default/files/eplus_logo.png",
            "deprecated": null,
            "description": "An operator to run EnergyPlus functions",
            "url": "operators/energy-plus-0.1.0.tgz",
            "created": "2020-05-19T07:42:20.496003",
            "digest": "bff20aae42e62aa084f0f08bf3833674e2bfccd0c6309f65848f089f402716f5",
            "slug": "local-repo/energy-plus",
            "type": "operator"
        }
    ]
  1. Get a specific package by its repository, name and tag

Note

Using the "latest" tag automatically fetches the most recent version of a given package.

    > queenbee repo get recipe ladybug daylight-factor latest

    {
      "name": "daylight-factor",
      "tag": "0.3.4",
      "app_version": null,
      "keywords": [
        "ladybug-tools",
        "radiance"
      ],
      "maintainers": [
        {
          "name": "mostapha",
          "email": "mostapha@ladybug.tools"
        }
      ],
      "home": null,
      "sources": null,
      "icon": "https://raw.githubusercontent.com/ladybug-tools/artwork/master/icons_components/honeybee/png/dfrecipe.png",
      "deprecated": null,
      "description": "Run daylight factor for a single model.",
      "license": "",
      "url": "daylight-factor-latest.tgz",
      "created": "2020-09-16T20:56:00.628852",
      "digest": "daa96cfcc530e12615af362fafe135c8f2af8b45906bfb1d9f223d5764d269a4",
      "slug": "ladybug/daylight-factor",
      "type": "recipe",
      "readme": "",
      "manifest": {
          "metatada": {},
          "dependencies": [],
          "flow": [{
              "name": "main",
              "inputs": [],
              "tasks": [],
              "outputs": []
          }]
      }
    }

@AntoineDao
Copy link
Copy Markdown
Member Author

@cdriesler I'm tagging you here as I can't add you as a reviewer on this PR yet.

@chriswmackey
Copy link
Copy Markdown
Contributor

@cdriesler still has to accept his invitation to the ladybug-tools/pollination team. Then, we should be able to add him as a reviewer.

@cdriesler cdriesler self-requested a review September 18, 2020 19:15
@cdriesler
Copy link
Copy Markdown

done! ty both

Copy link
Copy Markdown
Contributor

@chriswmackey chriswmackey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It generally looks good. My only major feedback is that you should add some more tests before we merge.

Comment thread queenbee/base/metadata.py
@click.command('add')
@click.argument('name')
@click.argument('path')
@click.option('-f', '--force', help='Boolean toggle to overwrite existing repository with same name', default=False, type=bool, is_flag=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8 👮 says "The speed limit is 89 characters per line."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep... I'm counting on running a big autopep8 lint on this. Was wanting to let you guys read through it first so the linting changes don't make the PR changes unmanageable 🙃

Comment thread queenbee/cli/repository/manage.py
@AntoineDao AntoineDao mentioned this pull request Sep 21, 2020
Copy link
Copy Markdown
Member

@mostaphaRoudsari mostaphaRoudsari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntoineDao, thanks! Looks good to me. Let's merge this in and try to update the local repository for the recipes for the plugins as the real testing process. 😁


return v

def fetch(self, auth_header: str = '') -> 'RepositoryIndex':
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unfamiliar with this arrow notation. It looks like it's a type annotation?

Is there a difference between 'returning' a string here and a reference to the actual type? You consistently do strings, and the document says that would have to be interpreted by a third party library, so I'm assuming not. Figured it's still worth learning/confirming here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep this is type annotations introduced in PEP 484.

You normally would us a class directly rather than a string indeed but in this case I use a string because importing the class in question would either lead to recursive imports or because this is a classmethod (and therefore the class isn't fully declared yet within the scope of this type declaration).

Copy link
Copy Markdown

@cdriesler cdriesler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unhelpful review from me here: all looks well, as far as I understand it. I appreciate the chance to get a closer look, though.

Just left one clarification question on something new I came across.

@AntoineDao AntoineDao merged commit 14763b1 into pollination:master Sep 22, 2020
@ladybugbot
Copy link
Copy Markdown

🎉 This PR is included in version 1.17.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants