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
packages
are 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, volume: str = 'xval_det', verbose: int = 0) -> RecipeNode
Reconstruct a Golden Volume Recipe from its ID.
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, 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.
-
volume
(str
, default:'xval_det'
) –Specify the golden volume (xval_det, bdd100k, chemistrylab, wheat, carsimple, insects) you want to check the ID in. Defaults to - xval_det volume.
-
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:
# load the recipe and bring it up to date so you can execute tasks on it:
from leip_recipe_designer import Pantry
from leip_recipe_designer.create import from_recipe_id
pantry = Pantry.build("./local_pantry")
recipe = from_recipe_id("GRDBCAR-9", pantry, allow_upgrade=True)
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 the LEIP Compiler Framework
leip_recipe_designer.create.empty_compiler_recipe
¶
empty_compiler_recipe(pantry: IngredientCache) -> RecipeNode