Skip to content

Commit

Permalink
fix(recipe): add a new field for source
Browse files Browse the repository at this point in the history
1. added a new field for source of the recipe.
2. renamed the object from RecipeInfo to RecipeInterface
  • Loading branch information
mostaphaRoudsari committed Dec 8, 2020
1 parent ed3a865 commit 8b153fb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions queenbee/recipe/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,17 +682,24 @@ def template_by_name(templates: List[Union[DAG, TemplateFunction]], name: str) -
return res


class RecipeInfo(BaseModel):
"""Recipe information.
class RecipeInterface(BaseModel):
"""An interface object for creating a Recipe.
Recipe information only includes metadata, inputs and outputs of a Recipe.
Recipe information only includes metadata, source, inputs and outputs of a Recipe.
This object is useful for creating user interface for Recipes.
"""
type: constr(regex='^RecipeInterface$') = 'RecipeInterface'

metadata: MetaData = Field(
...,
description='Recipe metadata information.'
)

source: str = Field(
None,
description='A URL to the source this recipe from a registry.'
)

inputs: List[DAGInputs] = Field(
None,
description='A list of recipe inputs.'
Expand All @@ -708,10 +715,11 @@ def create_empty_list(cls, v):
return [] if not v else v

@classmethod
def from_recipe(cls, recipe: Union[Recipe, BakedRecipe]):
def from_recipe(cls, recipe: Union[Recipe, BakedRecipe], source: str = None):
"""Create a Recipe info from a recipe."""
return cls(
metadata=recipe.metadata,
source=source,
inputs=recipe.inputs,
outputs=recipe.outputs
)

0 comments on commit 8b153fb

Please sign in to comment.