Recipe Creators
To add or modify a recipe's ingredients, you need to get a Pantry of ingredients. This can be done easily by building the Pantry:
leip_recipe_designer.Pantry.build
staticmethod
¶
build(pantry_store_dir: Union[str, Path], packages: Optional[Union[str, List[str]]] = None, force_rebuild: bool = False) -> IngredientCache
Builds a pantry of ingredients for each of the specified packages.
Parameters:
-
pantry_store_dir(Union[str, Path]) –The path to store the pantry of ingredients.
-
packages(Optional[Union[str, List[str]]], default:None) –The names of the packages to which you want to build pantries for. If
packagesare not specified, it detects the precense of compatible packages in your environment and builds the pantry for each. -
force_rebuild(bool, default:False) –If true, it will rebuild even if the pantry already exists.
Returns:
-
pantry(IngredientCache) –A pantry consisting of ingredients from all the packages specified or found in the environment.
Examples:
from leip_recipe_designer import Pantry
pantry = Pantry.build("./local_pantry")
# build a pantry for the Application Framework only
from leip_recipe_designer import Pantry
pantry = Pantry.build("./local_pantry", packages=["leip_af"])
Load a Saved Recipe¶
Info
You can optionally pass a pantry to load the recipes in "editable" mode. Not passing a pantry will still allow you to execute tasks on these recipes, but you wont be able to make any modifications.
leip_recipe_designer.create.from_recipe_id
¶
from_recipe_id(recipe_id: str, pantry: Optional[IngredientCache] = None, allow_upgrade: bool = False, allow_deprecated: bool = False, task: str = 'vision.detection.2d', volume: str = 'xval_det', verbose: int = 0, default: bool = False) -> RecipeNode
Reconstruct a Golden Volume Recipe from its ID.
This function allows reconstructing a recipe from the given ID within a specified Golden Volume. The recipe can optionally be upgraded, use deprecated ingredients, or default to specific task configurations.
Parameters:
-
recipe_id(str) –ID of the recipe in any of the Golden Volume dataframes.
-
pantry(Optional[IngredientCache], default:None) –The ingredients storage to use during the recipe creation. If not provided, a limited pantry will be recreated from the serialized information. Note: this limited pantry includes only ingredients that are assigned to the recipe when
pickle.dump()was called. -
allow_upgrade(bool, default:False) –This applies only if the pantry was provided. If True, the removed and updated by major change ingredients are translated to their latest variants.
-
allow_deprecated(bool, default:False) –This applies only if the pantry was provided. If True, the deprecated ingredients are used instead of their latest variants.
-
task(str, default:'vision.detection.2d') –The task associated with the recipe. Supported options: - "vision.detection.2d" (default) - "vision.classification.2d"
-
volume(str, default:'xval_det') –Specify the golden volume in which to look up the recipe ID. - For detection tasks: Defaults to
xval_det. Other options includebdd100k,chemistrylab,wheat, etc. - For classification tasks: Usexval_cls. -
verbose(int, default:0) –An integer specifying the verbosity level. Verbose Levels: 0: No output. 1: Shows the summary of the upgraded ingredients. 2: Additionally shows detailed information about rules selection and translation process.
-
default(bool, default:False) –If True, applies default task-related settings for the recipe.
Returns:
-
recipe(RecipeNode) –The reconstructed recipe instance.
Examples:
For detection tasks (default volume: xval_det):
from leip_recipe_designer import Pantry, create
pantry = Pantry.build("./local_pantry")
recipe = create.from_recipe_id(
recipe_id="59845",
pantry=pantry,
allow_upgrade=True
)
For classification tasks:
from leip_recipe_designer import Pantry, create
pantry = Pantry.build("./local_pantry")
recipe = create.from_recipe_id(
recipe_id="4163",
pantry=pantry,
task="vision.classification.2d",
volume="xval_cls",
default=True
)
Notes
- Detection workflows default to
xval_detunless otherwise specified. - For classification workflows, explicitly use
xval_clsand settask="vision.classification.2d".
leip_recipe_designer.create.from_sppr
¶
from_sppr(serialized: str, pantry: Optional[IngredientCache] = None, allow_upgrade: bool = False, allow_deprecated: bool = False, verbose: int = 0) -> RecipeNode
Reconstruct a recipe from its serialized representation.
Parameters:
-
serialized(str) –A serialized representation of the recipe. For more details about serialization process, refer to
_serialize_portable. -
pantry(Optional[IngredientCache], default:None) –The ingredients storage to use during the recipe creation. If not provided, the limited pantry will be recreated from the serialized information. Note: this limited pantry includes only ingredients that are assigned to the recipe when to_sppr() was called.
-
allow_upgrade(bool, default:False) –This applies only if the pantry was provided. If True, the removed and updated by major change ingredients are translated to their latest variants.
-
allow_deprecated(bool, default:False) –This applies only if the pantry was provided. If True, the deprecated ingredients are used instead of their latest variants.
-
verbose(int, default:0) –An integer specifying the verbosity level. Verbose Levels: 0: No output. 1: Shows the summary of the upgraded ingredients. 2: Additionally shows detailed information about rules selection and translation process.
Returns:
-
recipe(RecipeNode) –The reconstructed recipe instance.
Examples:
This is how a user would save and load a recipe using this method:
with open("my_recipe.sppr", "w") as file:
file.write(recipe.sppr())
with open("my_recipe.sppr", "r") as file:
recovered_recipe = from_sppr(file.read())
leip_recipe_designer.create.from_pickle
¶
from_pickle(path: Union[str, Path], pantry: Optional[IngredientCache] = None, allow_upgrade: bool = False, allow_deprecated: bool = False, verbose: int = 0) -> RecipeNode
Reconstruct a recipe from its a pickle representation.
Parameters:
-
path(Union[str, Path]) –A path to a pickled recipe object.
-
pantry(Optional[IngredientCache], default:None) –The ingredients storage to use during the recipe creation. If not provided, the limited pantry will be recreated from the serialized information. Note: this limited pantry includes only ingredients that are assigned to the recipe when
pickle.dump()was called. -
allow_upgrade(bool, default:False) –This applies only if the pantry was provided. If True, the removed and updated by major change ingredients are translated to their latest variants.
-
allow_deprecated(bool, default:False) –This applies only if the pantry was provided. If True, the deprecated ingredients are used instead of their latest variants.
-
verbose(int, default:0) –An integer specifying the verbosity level. Verbose Levels: 0: No output. 1: Shows the summary of the upgraded ingredients. 2: Additionally shows detailed information about rules selection and translation process.
Returns:
-
recipe(RecipeNode) –The reconstructed recipe instance.
Examples:
recipe.to_pickle("recipe.sppr")
recovered_recipe = rd.create.from_pickle("recipe.sppr")
Initialize an Empty Recipe¶
leip_recipe_designer.create.empty_detection_recipe
¶
empty_detection_recipe(pantry: IngredientCache) -> RecipeNode
Instantiate an empty recipe for a detection task.
Parameters:
-
pantry(IngredientCache) –The ingredients storage to associate with the new recipe.
Returns:
-
recipe(RecipeNode) –A blank recipe to populate with detection ingredients.
leip_recipe_designer.create.empty_classification_recipe
¶
empty_classification_recipe(pantry: IngredientCache) -> RecipeNode
Instantiate an empty recipe for a classification task.
Parameters:
-
pantry(IngredientCache) –The ingredients storage to associate with the new recipe.
Returns:
-
recipe(RecipeNode) –A blank recipe to populate with classification ingredients.
leip_recipe_designer.create.empty_segmentation_recipe
¶
empty_segmentation_recipe(pantry: IngredientCache) -> RecipeNode
Instantiate an empty recipe for a segmentation task.
Parameters:
-
pantry(IngredientCache) –The ingredients storage to associate with the new recipe.
Returns:
-
recipe(RecipeNode) –A blank recipe to populate with segmentation ingredients.
Starting at LEIP 4.0 users will be able to configure and execute compilation tasks from Recipe Designer. Under the hood this is calling LEIP Optimize
leip_recipe_designer.create.empty_compiler_recipe
¶
empty_compiler_recipe(pantry: IngredientCache) -> RecipeNode