Skip to content

Commit

Permalink
fix(recipe-dep): add extra checks before collecting dependencies
Browse files Browse the repository at this point in the history
If some cases dependencies are only recipes and there is no operator folder. In those cases queenbee should not try to list the files in a nonresistant folder.
  • Loading branch information
mostaphaRoudsari committed Jun 1, 2020
1 parent f5110c8 commit 17f35af
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions queenbee/recipe/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,22 +458,30 @@ def from_folder(cls, folder_path: str, refresh_deps: bool = True):

templates = []

for operator_dep_name in os.listdir(os.path.join(dependencies_folder, 'operator')):
operator = Operator.from_folder(
folder_path=os.path.join(dependencies_folder, 'operator', operator_dep_name)
)
templates.extend(TemplateFunction.from_operator(operator))
digest_dict[operator_dep_name] = operator.__hash__
operators_folder = os.path.join(dependencies_folder, 'operator')
if os.path.isdir(operators_folder):
for operator_dep_name in os.listdir(operators_folder):
operator = Operator.from_folder(
folder_path=os.path.join(
dependencies_folder, 'operator', operator_dep_name
)
)
templates.extend(TemplateFunction.from_operator(operator))
digest_dict[operator_dep_name] = operator.__hash__

for recipe_dep_name in os.listdir(os.path.join(dependencies_folder, 'recipe')):
sub_baked_recipe = cls.from_folder(
folder_path=os.path.join(dependencies_folder, 'recipe', recipe_dep_name),
refresh_deps=refresh_deps
)
recipes_folder = os.path.join(dependencies_folder, 'recipe')
if os.path.isdir(recipes_folder):
for recipe_dep_name in os.listdir(recipes_folder):
sub_baked_recipe = cls.from_folder(
folder_path=os.path.join(
dependencies_folder, 'recipe', recipe_dep_name
),
refresh_deps=refresh_deps
)

templates.extend(sub_baked_recipe.templates)
templates.extend(sub_baked_recipe.flow)
digest_dict[recipe_dep_name] = sub_baked_recipe.digest
templates.extend(sub_baked_recipe.templates)
templates.extend(sub_baked_recipe.flow)
digest_dict[recipe_dep_name] = sub_baked_recipe.digest

flow = cls.replace_template_refs(
dependencies=recipe.dependencies,
Expand Down

0 comments on commit 17f35af

Please sign in to comment.