Skip to content

Commit 307dd92

Browse files
authored
Merge branch 'main' into responses_object
2 parents 9b3f374 + 55e9959 commit 307dd92

File tree

64 files changed

+263
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+263
-174
lines changed

.github/workflows/pre-commit.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ jobs:
3636
**/requirements*.txt
3737
.pre-commit-config.yaml
3838
39+
# npm ci may fail -
40+
# npm error `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
41+
# npm error Invalid: lock file's [email protected] does not satisfy [email protected]
42+
43+
# - name: Set up Node.js
44+
# uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
45+
# with:
46+
# node-version: '20'
47+
# cache: 'npm'
48+
# cache-dependency-path: 'llama_stack/ui/'
49+
50+
# - name: Install npm dependencies
51+
# run: npm ci
52+
# working-directory: llama_stack/ui
53+
3954
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
4055
continue-on-error: true
4156
env:

.pre-commit-config.yaml

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,50 @@ repos:
146146
pass_filenames: false
147147
require_serial: true
148148
files: ^.github/workflows/.*$
149-
- id: ui-prettier
150-
name: Format UI code with Prettier
151-
entry: bash -c 'cd llama_stack/ui && npm run format'
152-
language: system
153-
files: ^llama_stack/ui/.*\.(ts|tsx)$
154-
pass_filenames: false
155-
require_serial: true
156-
- id: ui-eslint
157-
name: Lint UI code with ESLint
158-
entry: bash -c 'cd llama_stack/ui && npm run lint -- --fix --quiet'
149+
# ui-prettier and ui-eslint are disabled until we can avoid `npm ci`, which is slow and may fail -
150+
# npm error `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
151+
# npm error Invalid: lock file's [email protected] does not satisfy [email protected]
152+
# and until we have infra for installing prettier and next via npm -
153+
# Lint UI code with ESLint.....................................................Failed
154+
# - hook id: ui-eslint
155+
# - exit code: 127
156+
157+
# > next lint --fix --quiet
158+
# sh: line 1: next: command not found
159+
#
160+
# - id: ui-prettier
161+
# name: Format UI code with Prettier
162+
# entry: bash -c 'cd llama_stack/ui && npm ci && npm run format'
163+
# language: system
164+
# files: ^llama_stack/ui/.*\.(ts|tsx)$
165+
# pass_filenames: false
166+
# require_serial: true
167+
# - id: ui-eslint
168+
# name: Lint UI code with ESLint
169+
# entry: bash -c 'cd llama_stack/ui && npm run lint -- --fix --quiet'
170+
# language: system
171+
# files: ^llama_stack/ui/.*\.(ts|tsx)$
172+
# pass_filenames: false
173+
# require_serial: true
174+
175+
- id: check-log-usage
176+
name: Ensure 'llama_stack.log' usage for logging
177+
entry: bash
159178
language: system
160-
files: ^llama_stack/ui/.*\.(ts|tsx)$
161-
pass_filenames: false
162-
require_serial: true
179+
types: [python]
180+
pass_filenames: true
181+
args:
182+
- -c
183+
- |
184+
matches=$(grep -EnH '^[^#]*\b(import\s+logging|from\s+logging\b)' "$@" | grep -v -e '#\s*allow-direct-logging' || true)
185+
if [ -n "$matches" ]; then
186+
# GitHub Actions annotation format
187+
while IFS=: read -r file line_num rest; do
188+
echo "::error file=$file,line=$line_num::Do not use 'import logging' or 'from logging import' in $file. Use the custom log instead: from llama_stack.log import get_logger; logger = get_logger(). If direct logging is truly needed, add: # allow-direct-logging"
189+
done <<< "$matches"
190+
exit 1
191+
fi
192+
exit 0
163193
164194
ci:
165195
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks

docs/source/distributions/k8s-benchmark/benchmark.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python3
21
# Copyright (c) Meta Platforms, Inc. and affiliates.
32
# All rights reserved.
43
#

llama_stack/core/build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# the root directory of this source tree.
66

77
import importlib.resources
8-
import logging
98
import sys
109

1110
from pydantic import BaseModel
@@ -17,9 +16,10 @@
1716
from llama_stack.core.utils.exec import run_command
1817
from llama_stack.core.utils.image_types import LlamaStackImageType
1918
from llama_stack.distributions.template import DistributionTemplate
19+
from llama_stack.log import get_logger
2020
from llama_stack.providers.datatypes import Api
2121

22-
log = logging.getLogger(__name__)
22+
log = get_logger(name=__name__, category="core")
2323

2424
# These are the dependencies needed by the distribution server.
2525
# `llama-stack` is automatically installed by the installation script.

llama_stack/core/configure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#
44
# This source code is licensed under the terms described in the LICENSE file in
55
# the root directory of this source tree.
6-
import logging
76
import textwrap
87
from typing import Any
98

@@ -21,9 +20,10 @@
2120
from llama_stack.core.utils.config_dirs import EXTERNAL_PROVIDERS_DIR
2221
from llama_stack.core.utils.dynamic import instantiate_class_type
2322
from llama_stack.core.utils.prompt_for_config import prompt_for_config
23+
from llama_stack.log import get_logger
2424
from llama_stack.providers.datatypes import Api, ProviderSpec
2525

26-
logger = logging.getLogger(__name__)
26+
logger = get_logger(name=__name__, category="core")
2727

2828

2929
def configure_single_provider(registry: dict[str, ProviderSpec], provider: Provider) -> Provider:

llama_stack/core/library_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import asyncio
88
import inspect
99
import json
10-
import logging
10+
import logging # allow-direct-logging
1111
import os
1212
import sys
1313
from concurrent.futures import ThreadPoolExecutor
@@ -48,14 +48,15 @@
4848
from llama_stack.core.utils.config import redact_sensitive_fields
4949
from llama_stack.core.utils.context import preserve_contexts_async_generator
5050
from llama_stack.core.utils.exec import in_notebook
51+
from llama_stack.log import get_logger
5152
from llama_stack.providers.utils.telemetry.tracing import (
5253
CURRENT_TRACE_CONTEXT,
5354
end_trace,
5455
setup_logger,
5556
start_trace,
5657
)
5758

58-
logger = logging.getLogger(__name__)
59+
logger = get_logger(name=__name__, category="core")
5960

6061
T = TypeVar("T")
6162

llama_stack/core/request_headers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
import contextvars
88
import json
9-
import logging
109
from contextlib import AbstractContextManager
1110
from typing import Any
1211

1312
from llama_stack.core.datatypes import User
13+
from llama_stack.log import get_logger
1414

1515
from .utils.dynamic import instantiate_class_type
1616

17-
log = logging.getLogger(__name__)
17+
log = get_logger(name=__name__, category="core")
1818

1919
# Context variable for request provider data and auth attributes
2020
PROVIDER_DATA_VAR = contextvars.ContextVar("provider_data", default=None)

llama_stack/core/server/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import functools
1010
import inspect
1111
import json
12-
import logging
12+
import logging # allow-direct-logging
1313
import os
1414
import ssl
1515
import sys

llama_stack/core/utils/exec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
# This source code is licensed under the terms described in the LICENSE file in
55
# the root directory of this source tree.
66

7-
import logging
7+
import importlib
88
import os
99
import signal
1010
import subprocess
1111
import sys
1212

1313
from termcolor import cprint
1414

15-
log = logging.getLogger(__name__)
15+
from llama_stack.log import get_logger
1616

17-
import importlib
17+
log = get_logger(name=__name__, category="core")
1818

1919

2020
def formulate_run_args(image_type: str, image_name: str) -> list:

llama_stack/core/utils/prompt_for_config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66

77
import inspect
88
import json
9-
import logging
109
from enum import Enum
1110
from typing import Annotated, Any, Literal, Union, get_args, get_origin
1211

1312
from pydantic import BaseModel
1413
from pydantic.fields import FieldInfo
1514
from pydantic_core import PydanticUndefinedType
1615

17-
log = logging.getLogger(__name__)
16+
from llama_stack.log import get_logger
17+
18+
log = get_logger(name=__name__, category="core")
1819

1920

2021
def is_list_of_primitives(field_type):

0 commit comments

Comments
 (0)