Export/Import of Recipe Runs¶
Recipe runs can be exported to a file for for later analysis. For example, to gather data like CPU and iperf statistic when onboarding a new recipe.
The data that is exported is the instance of lnst.Controller.Recipe.RecipeRun
that was run.
The RecipeRun
object is “pickled” and compressed with LZMA/XZ compression using lzma
.
By default the file will be contain a file extension .lrc which stands for “LNST Run, Compressed”.
Use export_recipe_run()
to export and import_recipe_run()
to import.
-
lnst.Controller.Recipe.
export_recipe_run
(run: lnst.Controller.Recipe.RecipeRun, export_dir: str = None, name: str = None) → str¶ Export a recipe run to a file.
RecipeRun
is pickled and compressed.Parameters: - run (
RecipeRun
) – RecipeRun object to export. - export_dir (str) – Directory to export file to. Defaults to
run.log_dir
- name (str) – Name of output (exclusive of directory). Defaults to <recipename>-run-<timestamp>.lrc.
Returns: Path of output file.
Return type: str
Example:
ctl = Controller(...) recipe = BondRecipe(...) ctl.run(recipe) ... >>> from lnst.Controller.Recipe import export_recipe_run >>> path = export_recipe_run(recipe.run[0]) 2020-10-02 15:20:58 (localhost) - INFO: Exported BondRecipe run data to /tmp/lnst-logs/2020-10-02_15:20:18/BondRecipe_match_0/BondRecipe-run-2020-10-02_15:20:58.lrc >>> print(path) /tmp/lnst-logs/2020-10-02_15:20:18/BondRecipe_match_0/BondRecipe-run-2020-10-02_15:20:58.lrc
- run (
-
lnst.Controller.Recipe.
import_recipe_run
(path: str) → lnst.Controller.Recipe.RecipeRun¶ Import a recipe run that was exported using
export_recipe_run()
Parameters: path (str) – Path to file to import Returns: object which contains the imported recipe run Return type: RecipeRun
Example:
>>> from lnst.Controller.Recipe import import_recipe_run >>> run = import_recipe_run("/tmp/lnst-logs/2020-10-02_15:20:18/BondRecipe_match_0/BondRecipe-run-2020-10-02_15:20:58.lrc") >>> type(run) <class 'lnst.Controller.Recipe.RecipeRun'> >>> run.recipe.__class__ <class 'lnst.Recipes.ENRT.BondRecipe.BondRecipe'> >>> run.results[38] <lnst.Controller.RecipeResults.Result object at 0x7f20727e1e20> >>> run.results[38].data {'cpu': [[[<lnst.RecipeCommon.Perf.Results.PerfInterval object at 0x7f20727e1e50>,...]]], ... } >>> print(run.results[38].description) CPU Utilization on host host1: cpu 'cpu': 45.40 +-0.00 time units per second cpu 'cpu0': 45.40 +-0.00 time units per second