From: Perry Gagne <pgagne(a)redhat.com>
Made recipe pickle-able, export of will still be based on RecipeRuns in the highlevel api
though.
Signed-off-by: Perry Gagne <pgagne(a)redhat.com>
---
lnst/Controller/Recipe.py | 10 ++++++----
lnst/Controller/RecipeRunExport.py | 9 +++++----
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/lnst/Controller/Recipe.py b/lnst/Controller/Recipe.py
index 3bb6793..7fb7006 100644
--- a/lnst/Controller/Recipe.py
+++ b/lnst/Controller/Recipe.py
@@ -155,6 +155,12 @@ class BaseRecipe(object):
self.current_run.add_result(Result(success, description, data,
level, data_level))
+ def __getstate__(self):
+ state = self.__dict__.copy()
+ state['_ctl'] = None
+ return state
+
+
class RecipeRun(object):
def __init__(self, recipe: BaseRecipe, match, desc=None, log_dir=None):
self._match = match
@@ -206,7 +212,3 @@ class RecipeRun(object):
def recipe(self) -> BaseRecipe:
return self._recipe
- def __getstate__(self):
- state = self.__dict__.copy()
- state['_recipe'] = None
- return state
diff --git a/lnst/Controller/RecipeRunExport.py b/lnst/Controller/RecipeRunExport.py
index 9486fe8..fc27284 100644
--- a/lnst/Controller/RecipeRunExport.py
+++ b/lnst/Controller/RecipeRunExport.py
@@ -1,8 +1,10 @@
-"""This module provides an API to export data related to a recipe run.
This export can be used to gather data like CPU and iperf statistic for later analysis,
like when onboarding a new Recipe.
+"""This module provides an API to export data related to a recipe run.
+This export can be used to gather data like CPU and iperf statistic for later analysis,
like when onboarding a new Recipe.
The data that is exported is the instance of :py:class:`lnst.Controller.Recipe.RecipeRun`
that was run.
-Data is encapsuled in an :py:class:`RecipeRunData` object which allows us to include
other metadata. The `RecipeRunData` object is "pickled" and compressed with
LZMA/XZ compression using :py:mod:`lzma`.
+Data is encapsuled in an :py:class:`RecipeRunData` object which allows us to include
other metadata.
+The `RecipeRunData` object is "pickled" and compressed with LZMA/XZ compression
using :py:mod:`lzma`.
By default the file will be contain a file extension `.lrc` which stands for "LNST
Run, Compressed".
@@ -45,7 +47,6 @@ class RecipeRunData:
:type datetime: :py:class:`datetime.datetime`
"""
def __init__(self, run: RecipeRun):
- self.recipe_cls = run.recipe.__class__
self.params = run.recipe.params._to_dict()
self.req = run.recipe.req._to_dict()
self.environ = os.environ.copy()
@@ -105,7 +106,7 @@ def import_recipe_run(path: str) -> RecipeRunData:
>> run_data =
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_data)
<class
'lnst.Controller.RecipeRunExport.RecipeRunData'>
- >>> run_data.recipe_cls
+ >>> run_data.recipe.__class__
<class 'lnst.Recipes.ENRT.BondRecipe.BondRecipe'>
>> run_data.run.results[38]
<lnst.Controller.RecipeResults.Result object at 0x7f20727e1e20>
--
2.26.2