From c20388c42462370ea950d1c5b53885ea4a404650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 19 Jun 2025 15:27:32 +0200 Subject: [PATCH] ci: add python package build test (#2457) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # What does this PR do? We now test a package build on every PRs. Closes: https://github.com/meta-llama/llama-stack/issues/2406 Signed-off-by: Sébastien Han --- .github/workflows/python-build-test.yml | 45 +++++++++++++++++++ .pre-commit-config.yaml | 8 ++++ .../ui/page/distribution/__init__.py | 5 +++ llama_stack/models/llama/llama3_3/__init__.py | 5 +++ .../llama/llama4/prompt_templates/__init__.py | 5 +++ .../models/llama/llama4/vision/__init__.py | 5 +++ .../huggingface/recipes/__init__.py | 5 +++ .../inline/scoring/basic/utils/__init__.py | 5 +++ .../providers/utils/responses/__init__.py | 5 +++ .../providers/utils/sqlstore/__init__.py | 5 +++ llama_stack/providers/utils/tools/__init__.py | 5 +++ scripts/check-init-py.sh | 45 +++++++++++++++++++ 12 files changed, 143 insertions(+) create mode 100644 .github/workflows/python-build-test.yml create mode 100644 llama_stack/distribution/ui/page/distribution/__init__.py create mode 100644 llama_stack/models/llama/llama3_3/__init__.py create mode 100644 llama_stack/models/llama/llama4/prompt_templates/__init__.py create mode 100644 llama_stack/models/llama/llama4/vision/__init__.py create mode 100644 llama_stack/providers/inline/post_training/huggingface/recipes/__init__.py create mode 100644 llama_stack/providers/inline/scoring/basic/utils/__init__.py create mode 100644 llama_stack/providers/utils/responses/__init__.py create mode 100644 llama_stack/providers/utils/sqlstore/__init__.py create mode 100644 llama_stack/providers/utils/tools/__init__.py create mode 100755 scripts/check-init-py.sh diff --git a/.github/workflows/python-build-test.yml b/.github/workflows/python-build-test.yml new file mode 100644 index 000000000..6433c6e52 --- /dev/null +++ b/.github/workflows/python-build-test.yml @@ -0,0 +1,45 @@ +name: Python Package Build Test + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.11', '3.12', '3.13'] + + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Install uv + uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1 + with: + python-version: ${{ matrix.python-version }} + activate-environment: true + version: 0.7.6 + + - name: Build Llama Stack package + run: | + uv build + + - name: Install Llama Stack package + run: | + uv pip install dist/*.whl + + - name: Verify Llama Stack package + run: | + uv pip list + uv pip show llama-stack + command -v llama + llama model prompt-format -m Llama3.2-90B-Vision-Instruct + llama model list + llama stack list-apis + llama stack list-providers inference diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aaec469e4..40900abe5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -112,6 +112,14 @@ repos: require_serial: true always_run: true files: ^\.github/workflows/.*\.ya?ml$ + - id: check-init-py + name: Check for missing __init__.py files + entry: ./scripts/check-init-py.sh + language: system + pass_filenames: false + require_serial: true + always_run: true + files: ^llama_stack/.*$ ci: autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks diff --git a/llama_stack/distribution/ui/page/distribution/__init__.py b/llama_stack/distribution/ui/page/distribution/__init__.py new file mode 100644 index 000000000..756f351d8 --- /dev/null +++ b/llama_stack/distribution/ui/page/distribution/__init__.py @@ -0,0 +1,5 @@ +# 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. diff --git a/llama_stack/models/llama/llama3_3/__init__.py b/llama_stack/models/llama/llama3_3/__init__.py new file mode 100644 index 000000000..756f351d8 --- /dev/null +++ b/llama_stack/models/llama/llama3_3/__init__.py @@ -0,0 +1,5 @@ +# 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. diff --git a/llama_stack/models/llama/llama4/prompt_templates/__init__.py b/llama_stack/models/llama/llama4/prompt_templates/__init__.py new file mode 100644 index 000000000..756f351d8 --- /dev/null +++ b/llama_stack/models/llama/llama4/prompt_templates/__init__.py @@ -0,0 +1,5 @@ +# 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. diff --git a/llama_stack/models/llama/llama4/vision/__init__.py b/llama_stack/models/llama/llama4/vision/__init__.py new file mode 100644 index 000000000..756f351d8 --- /dev/null +++ b/llama_stack/models/llama/llama4/vision/__init__.py @@ -0,0 +1,5 @@ +# 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. diff --git a/llama_stack/providers/inline/post_training/huggingface/recipes/__init__.py b/llama_stack/providers/inline/post_training/huggingface/recipes/__init__.py new file mode 100644 index 000000000..756f351d8 --- /dev/null +++ b/llama_stack/providers/inline/post_training/huggingface/recipes/__init__.py @@ -0,0 +1,5 @@ +# 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. diff --git a/llama_stack/providers/inline/scoring/basic/utils/__init__.py b/llama_stack/providers/inline/scoring/basic/utils/__init__.py new file mode 100644 index 000000000..756f351d8 --- /dev/null +++ b/llama_stack/providers/inline/scoring/basic/utils/__init__.py @@ -0,0 +1,5 @@ +# 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. diff --git a/llama_stack/providers/utils/responses/__init__.py b/llama_stack/providers/utils/responses/__init__.py new file mode 100644 index 000000000..756f351d8 --- /dev/null +++ b/llama_stack/providers/utils/responses/__init__.py @@ -0,0 +1,5 @@ +# 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. diff --git a/llama_stack/providers/utils/sqlstore/__init__.py b/llama_stack/providers/utils/sqlstore/__init__.py new file mode 100644 index 000000000..756f351d8 --- /dev/null +++ b/llama_stack/providers/utils/sqlstore/__init__.py @@ -0,0 +1,5 @@ +# 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. diff --git a/llama_stack/providers/utils/tools/__init__.py b/llama_stack/providers/utils/tools/__init__.py new file mode 100644 index 000000000..756f351d8 --- /dev/null +++ b/llama_stack/providers/utils/tools/__init__.py @@ -0,0 +1,5 @@ +# 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. diff --git a/scripts/check-init-py.sh b/scripts/check-init-py.sh new file mode 100755 index 000000000..41205a5eb --- /dev/null +++ b/scripts/check-init-py.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# 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. +# +# Check for missing __init__.py files in Python packages +# This script finds directories that contain Python files but are missing __init__.py + +set -euo pipefail + +# Use mapfile to get a faster way to iterate over directories +if (( BASH_VERSINFO[0] < 4 )); then + echo "This script requires Bash 4.0 or higher for mapfile support." + exit 1 +fi + +PACKAGE_DIR="${1:-llama_stack}" + +if [ ! -d "$PACKAGE_DIR" ]; then + echo "ERROR: Package directory '$PACKAGE_DIR' does not exist" + exit 1 +fi + +# Get all directories with Python files (excluding __init__.py) +mapfile -t py_dirs < <( + find "$PACKAGE_DIR" \ + -type f \ + -name "*.py" ! -name "__init__.py" \ + ! -path "*/.venv/*" \ + -exec dirname {} \; | sort -u +) + +missing_init_files=0 + +for dir in "${py_dirs[@]}"; do + if [ ! -f "$dir/__init__.py" ]; then + echo "ERROR: Missing __init__.py in directory: $dir" + echo "This directory contains Python files but no __init__.py, which may cause packaging issues." + missing_init_files=1 + fi +done + +exit $missing_init_files