mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-27 18:50:41 +00:00
chore: force ellipsis in API webmethods (#2141)
# What does this PR do? This new check will fail if some webmethods are missing the ellipsis: ``` API Method Return Type Validation Errors: Method Api.eval.job_result does not contain ellipsis (...) in its implementation Method Api.agents.create_agent_turn does not contain ellipsis (...) in its implementation Method Api.agents.create_openai_response does not contain ellipsis (...) in its implementation Method Api.eval.evaluate_rows does not contain ellipsis (...) in its implementation Method Api.eval.run_eval does not contain ellipsis (...) in its implementation ``` Unless not implemented. Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
parent
43e623eea6
commit
53b7f50828
2 changed files with 12 additions and 1 deletions
|
@ -44,7 +44,7 @@ def main(output_dir: str):
|
||||||
if return_type_errors:
|
if return_type_errors:
|
||||||
print("\nAPI Method Return Type Validation Errors:\n")
|
print("\nAPI Method Return Type Validation Errors:\n")
|
||||||
for error in return_type_errors:
|
for error in return_type_errors:
|
||||||
print(error)
|
print(error, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
now = str(datetime.now())
|
now = str(datetime.now())
|
||||||
print(
|
print(
|
||||||
|
|
|
@ -174,14 +174,25 @@ def _validate_list_parameters_contain_data(method) -> str | None:
|
||||||
return "does not have a mandatory data attribute containing the list of objects"
|
return "does not have a mandatory data attribute containing the list of objects"
|
||||||
|
|
||||||
|
|
||||||
|
def _validate_has_ellipsis(method) -> str | None:
|
||||||
|
source = inspect.getsource(method)
|
||||||
|
if "..." not in source and not "NotImplementedError" in source:
|
||||||
|
return "does not contain ellipsis (...) in its implementation"
|
||||||
|
|
||||||
|
|
||||||
_VALIDATORS = {
|
_VALIDATORS = {
|
||||||
"GET": [
|
"GET": [
|
||||||
_validate_api_method_return_type,
|
_validate_api_method_return_type,
|
||||||
_validate_list_parameters_contain_data,
|
_validate_list_parameters_contain_data,
|
||||||
_validate_api_method_doesnt_return_list,
|
_validate_api_method_doesnt_return_list,
|
||||||
|
_validate_has_ellipsis,
|
||||||
],
|
],
|
||||||
"DELETE": [
|
"DELETE": [
|
||||||
_validate_api_delete_method_returns_none,
|
_validate_api_delete_method_returns_none,
|
||||||
|
_validate_has_ellipsis,
|
||||||
|
],
|
||||||
|
"POST": [
|
||||||
|
_validate_has_ellipsis,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue