mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-27 18:50:41 +00:00
# What does this PR do? - Enable mypy to run in the CI on a subset of the repository - Fix a few mypy errors - Run mypy from pre-commit Signed-off-by: Sébastien Han <seb@redhat.com> [//]: # (If resolving an issue, uncomment and update the line below) [//]: # (Closes #[issue-number]) ## Test Plan [Describe the tests you ran to verify your changes with result summaries. *Provide clear instructions so the plan can be easily re-executed.*] [//]: # (## Documentation) Signed-off-by: Sébastien Han <seb@redhat.com>
66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the terms described in the LICENSE file in
|
|
# the root directory of this source tree.
|
|
|
|
import argparse
|
|
import os
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
"""
|
|
Script for running client-sdk on AsyncLlamaStackAsLibraryClient with templates
|
|
|
|
Assuming directory structure:
|
|
- llama-stack
|
|
- llama_stack
|
|
- scripts
|
|
- tests
|
|
- client-sdk
|
|
|
|
Example command:
|
|
|
|
cd llama-stack
|
|
EXPORT TOGETHER_API_KEY=<..>
|
|
EXPORT FIREWORKS_API_KEY=<..>
|
|
python llama_stack/scripts/run_client_sdk_tests.py --templates together fireworks --report
|
|
"""
|
|
|
|
REPO_ROOT = Path(__file__).parent.parent.parent
|
|
CLIENT_SDK_TESTS_RELATIVE_PATH = "tests/client-sdk/"
|
|
|
|
|
|
def main(parser: argparse.ArgumentParser):
|
|
args = parser.parse_args()
|
|
templates_dir = REPO_ROOT / "llama_stack" / "templates"
|
|
user_specified_templates = [templates_dir / t for t in args.templates] if args.templates else []
|
|
for d in templates_dir.iterdir():
|
|
if d.is_dir() and d.name != "__pycache__":
|
|
template_configs = list(d.rglob("run.yaml"))
|
|
if len(template_configs) == 0:
|
|
continue
|
|
config = template_configs[0]
|
|
if user_specified_templates:
|
|
if not any(config.parent == t for t in user_specified_templates):
|
|
continue
|
|
os.environ["LLAMA_STACK_CONFIG"] = str(config)
|
|
pytest_args = "--report" if args.report else ""
|
|
pytest.main(
|
|
[
|
|
pytest_args,
|
|
"-s",
|
|
"-v",
|
|
str(REPO_ROOT / CLIENT_SDK_TESTS_RELATIVE_PATH),
|
|
]
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(
|
|
prog="llama_test",
|
|
)
|
|
parser.add_argument("--templates", nargs="+")
|
|
parser.add_argument("--report", action="store_true")
|
|
main(parser)
|