Skip to content

Commit

Permalink
feat(recipe): add RecipeInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
mostaphaRoudsari committed Dec 8, 2020
1 parent 55b5ee3 commit ed3a865
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions queenbee/recipe/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,3 +680,38 @@ def template_by_name(templates: List[Union[DAG, TemplateFunction]], name: str) -
raise ValueError(f'No dependency with reference name {name} found')

return res


class RecipeInfo(BaseModel):
"""Recipe information.
Recipe information only includes metadata, inputs and outputs of a Recipe.
This object is useful for creating user interface for Recipes.
"""
metadata: MetaData = Field(
...,
description='Recipe metadata information.'
)

inputs: List[DAGInputs] = Field(
None,
description='A list of recipe inputs.'
)

outputs: List[DAGOutputs] = Field(
None,
description='A list of recipe outputs.'
)

@validator('inputs', 'outputs')
def create_empty_list(cls, v):
return [] if not v else v

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

0 comments on commit ed3a865

Please sign in to comment.