Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonRunSummaryFormatter: format all results #333

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions lnst/Controller/RunSummaryFormatters/JsonRunSummaryFormatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
import json

from lnst.Controller.Recipe import RecipeRun
from lnst.Controller.RecipeResults import DeviceMethodCallResult, JobResult, JobStartResult, MeasurementResult, Result
from lnst.Controller.RecipeResults import (
DeviceMethodCallResult,
JobResult,
JobStartResult,
MeasurementResult,
BaseResult,
)
from .RunSummaryFormatter import RunSummaryFormatter


Expand Down Expand Up @@ -32,7 +38,7 @@ def format_run(self, run: RecipeRun) -> str:
indent=4 if self.pretty else None,
)

def _transform_result(self, result: Result) -> Optional[dict]:
def _transform_result(self, result: BaseResult) -> Optional[dict]:
ret = {
"result": str(result.result),
}
Expand Down Expand Up @@ -85,23 +91,20 @@ def _transform_result(self, result: Result) -> Optional[dict]:
}
elif result.measurement_type == "linuxperf":
# linuxperf measurement just generates files
return None
measurement_data = {}
else:
logging.warning(f"unhandled measurement result type: {result.measurement_type}")
return None
measurement_data = None
return ret | {
"type": "measurement",
"measurement_type": result.measurement_type,
"data": measurement_data,
}
elif isinstance(result, Result):
if result.data is None:
return ret | {
"type": "unknown",
"description": result.description,
}
else:
logging.warning(f"unhandled recipe result type: {repr(result)} with data of type {type(result.data)}")
else:
logging.warning(f"unhandled recipe result type: {repr(result)}")
return None
if result.data is not None:
Kuba314 marked this conversation as resolved.
Show resolved Hide resolved
logging.warning(f"unhandled recipe result type: {repr(result)}, can't format its data")

return ret | {
"type": "unknown",
"description": result.description,
}