mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-06 02:32:40 +00:00
format as table'
This commit is contained in:
parent
958225a44c
commit
b22cc3e1fa
1 changed files with 36 additions and 55 deletions
|
@ -15,7 +15,7 @@ from llama_models.sku_list import all_registered_models
|
||||||
from pytest_html.basereport import _process_outcome
|
from pytest_html.basereport import _process_outcome
|
||||||
|
|
||||||
|
|
||||||
INFERNECE_APIS = ["chat_completion"]
|
INFERENCE_APIS = ["chat_completion"]
|
||||||
FUNCTIONALITIES = ["streaming", "structured_output", "tool_calling"]
|
FUNCTIONALITIES = ["streaming", "structured_output", "tool_calling"]
|
||||||
SUPPORTED_MODELS = {
|
SUPPORTED_MODELS = {
|
||||||
"ollama": set(
|
"ollama": set(
|
||||||
|
@ -119,27 +119,35 @@ class Report:
|
||||||
|
|
||||||
report.append("\n### Tests:")
|
report.append("\n### Tests:")
|
||||||
|
|
||||||
for provider in SUPPORTED_MODELS.items():
|
for provider in SUPPORTED_MODELS.keys():
|
||||||
if provider not in self.inference_tests:
|
if provider not in self.inference_tests:
|
||||||
continue
|
continue
|
||||||
|
report.append(f"\n #### {provider}")
|
||||||
test_table = [
|
test_table = [
|
||||||
"| Area | Model | API / Functionality | Test name | Test Result |",
|
"| Area | Model | API | Functionality Test | Status |",
|
||||||
"|:-----|:-----|:-----|:-----|:-----|",
|
"|:-----|:-----|:-----|:-----|:-----|",
|
||||||
]
|
]
|
||||||
for api in INFERNECE_APIS:
|
for api in INFERENCE_APIS:
|
||||||
tests = self.inference_tests[provider][api]
|
tests = self.inference_tests[provider][api]
|
||||||
|
for test_nodeid in tests:
|
||||||
# report.append("\n - **APIs:**")
|
row = "|{area} | {model} | {api} | {test} | {result} ".format(
|
||||||
# for api in INFERNECE_APIS:
|
area="Text" if "text" in test_nodeid else "Vision",
|
||||||
# test_nodeids = self.inference_tests[provider][api]
|
model=(
|
||||||
# report.append(f"\n - /{api}:")
|
"Llama-3.1-8B-Instruct"
|
||||||
# report.extend(self._generate_test_result_short(test_nodeids))
|
if "text" in test_nodeid
|
||||||
|
else "Llama3.2-11B-Vision-Instruct"
|
||||||
# report.append("\n - **Functionality:**")
|
),
|
||||||
# for functionality in FUNCTIONALITIES:
|
api=f"/{api}",
|
||||||
# test_nodeids = self.inference_tests[provider][functionality]
|
test=self.get_simple_function_name(test_nodeid),
|
||||||
# report.append(f"\n - {functionality}:")
|
result=(
|
||||||
# report.extend(self._generate_test_result_short(test_nodeids))
|
"✅"
|
||||||
|
if self.test_data[test_nodeid]["outcome"] == "passed"
|
||||||
|
else "❌"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
test_table += [row]
|
||||||
|
report.extend(test_table)
|
||||||
|
report.append("\n")
|
||||||
|
|
||||||
output_file = Path("pytest_report.md")
|
output_file = Path("pytest_report.md")
|
||||||
output_file.write_text("\n".join(report))
|
output_file.write_text("\n".join(report))
|
||||||
|
@ -150,51 +158,24 @@ class Report:
|
||||||
for item in items:
|
for item in items:
|
||||||
inference = item.callspec.params.get("inference_stack")
|
inference = item.callspec.params.get("inference_stack")
|
||||||
if "inference" in item.nodeid:
|
if "inference" in item.nodeid:
|
||||||
api, functionality = self._process_function_name(item.nodeid)
|
func_name = getattr(item, "originalname", item.name)
|
||||||
api_tests = self.inference_tests[inference].get(api, set())
|
for api in INFERENCE_APIS:
|
||||||
# functionality_tests = self.inference_tests[inference].get(
|
if api in func_name:
|
||||||
# functionality, set()
|
api_tests = self.inference_tests[inference].get(api, set())
|
||||||
# )
|
api_tests.add(item.nodeid)
|
||||||
api_tests.add(item.nodeid)
|
self.inference_tests[inference][api] = api_tests
|
||||||
# functionality_tests.add(item.nodeid)
|
|
||||||
self.inference_tests[inference][api] = api_tests
|
|
||||||
# self.inference_tests[inference][functionality] = functionality_tests
|
|
||||||
|
|
||||||
def _process_function_name(self, function_name):
|
def get_simple_function_name(self, nodeid):
|
||||||
api, functionality = None, None
|
|
||||||
for val in INFERNECE_APIS:
|
|
||||||
if val in function_name:
|
|
||||||
api = val
|
|
||||||
for val in FUNCTIONALITIES:
|
|
||||||
if val in function_name:
|
|
||||||
functionality = val
|
|
||||||
return api, functionality
|
|
||||||
|
|
||||||
def _print_result_icon(self, result):
|
|
||||||
if result == "Passed":
|
|
||||||
return "✅"
|
|
||||||
else:
|
|
||||||
# result == "Failed" or result == "Error":
|
|
||||||
return "❌"
|
|
||||||
|
|
||||||
def get_function_name(self, nodeid):
|
|
||||||
"""Extract function name from nodeid.
|
"""Extract function name from nodeid.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
- 'tests/test_math.py::test_addition' -> 'test_addition'
|
- 'tests/test_math.py::test_addition' -> 'test_addition'
|
||||||
- 'tests/test_math.py::TestClass::test_method' -> 'TestClass.test_method'
|
- 'tests/test_math.py::TestClass::test_method' -> test_method'
|
||||||
"""
|
"""
|
||||||
parts = nodeid.split("::")
|
parts = nodeid.split("::")
|
||||||
|
func_name = nodeid # Fallback to full nodeid if pattern doesn't match
|
||||||
if len(parts) == 2: # Simple function
|
if len(parts) == 2: # Simple function
|
||||||
return parts[1]
|
func_name = parts[1]
|
||||||
elif len(parts) == 3: # Class method
|
elif len(parts) == 3: # Class method
|
||||||
return f"{parts[1]}.{parts[2]}"
|
func_name = parts[2]
|
||||||
return nodeid # Fallback to full nodeid if pattern doesn't match
|
return func_name.split("[")[0]
|
||||||
|
|
||||||
def _generate_test_result_short(self, test_nodeids):
|
|
||||||
report = []
|
|
||||||
for nodeid in test_nodeids:
|
|
||||||
name = self.get_function_name(self.test_data[nodeid]["name"])
|
|
||||||
result = self.test_data[nodeid]["outcome"]
|
|
||||||
report.append(f" - {name}. Result: {result}")
|
|
||||||
return report
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue