Skip to content

Commit c6a44cf

Browse files
authored
Merge branch 'main' into no-logging-config
2 parents a3e4904 + 63a3b62 commit c6a44cf

File tree

653 files changed

+46258
-37479
lines changed

Some content is hidden

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

653 files changed

+46258
-37479
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- uses: actions/checkout@v3
22-
- uses: chartboost/ruff-action@v1
23-
with:
24-
args: check --config ci.ruff.toml
22+
- uses: astral-sh/ruff-action@v3
2523

2624
type-checking:
2725
runs-on: ubuntu-latest
@@ -73,6 +71,7 @@ jobs:
7371
- "3.11"
7472
- "3.12"
7573
- "3.13"
74+
- "3.14"
7675

7776
name: Test on Python version ${{ matrix.python-version }}
7877
steps:

.github/workflows/release.yml

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ on:
1111
- patch
1212
- minor
1313
- major
14-
- prerelease
14+
- prepatch
15+
- preminor
16+
- premajor
1517
prerelease_type:
16-
description: 'Pre-release type (only used if version is "prerelease")'
18+
description: 'Pre-release type (used when version is prepatch/preminor/premajor)'
1719
type: choice
1820
default: ""
1921
options:
@@ -26,7 +28,7 @@ on:
2628
type: string
2729
default: ""
2830
confirm_major:
29-
description: "Type RELEASE MAJOR to confirm a major release"
31+
description: "Type RELEASE MAJOR to confirm a major or premajor release"
3032
required: false
3133
default: ""
3234

@@ -52,10 +54,10 @@ jobs:
5254
fi
5355
5456
- name: Confirm major release
55-
if: ${{ inputs.version == 'major' && inputs.dry_run == false }}
57+
if: ${{ inputs.version == 'major' || inputs.version == 'premajor' }}
5658
run: |
5759
if [ "${{ inputs.confirm_major }}" != "RELEASE MAJOR" ]; then
58-
echo "❌ For major releases, set confirm_major to RELEASE MAJOR"
60+
echo "❌ For major/premajor releases, set confirm_major to RELEASE MAJOR"
5961
exit 1
6062
fi
6163
@@ -108,12 +110,50 @@ jobs:
108110
# Parse version components
109111
IFS='.' read -r major minor patch <<< "$base_version"
110112
111-
if [ "$version_type" = "prerelease" ]; then
113+
if echo "$current_version" | grep -qE '(a|b|rc)[0-9]+$'; then
114+
current_is_prerelease="true"
115+
else
116+
current_is_prerelease="false"
117+
fi
118+
119+
if [ "$version_type" = "premajor" ] || [ "$version_type" = "preminor" ] || [ "$version_type" = "prepatch" ]; then
112120
if [ -z "$prerelease_type" ]; then
113-
echo "❌ Error: prerelease_type must be specified when version is 'prerelease'"
121+
echo "❌ Error: prerelease_type must be specified when version is a prerelease variant"
114122
exit 1
115123
fi
116124
125+
# Determine the prerelease base version target
126+
case "$version_type" in
127+
premajor)
128+
if [ "$current_is_prerelease" = "true" ] && [ "$minor" -eq 0 ] && [ "$patch" -eq 0 ]; then
129+
target_major=$major
130+
else
131+
target_major=$((major + 1))
132+
fi
133+
target_minor=0
134+
target_patch=0
135+
;;
136+
preminor)
137+
target_major=$major
138+
if [ "$current_is_prerelease" = "true" ] && [ "$patch" -eq 0 ] && [ "$minor" -gt 0 ]; then
139+
target_minor=$minor
140+
else
141+
target_minor=$((minor + 1))
142+
fi
143+
target_patch=0
144+
;;
145+
prepatch)
146+
target_major=$major
147+
target_minor=$minor
148+
if [ "$current_is_prerelease" = "true" ] && [ "$patch" -gt 0 ]; then
149+
target_patch=$patch
150+
else
151+
target_patch=$((patch + 1))
152+
fi
153+
;;
154+
esac
155+
target_base_version="${target_major}.${target_minor}.${target_patch}"
156+
117157
# Map prerelease type to Python suffix
118158
case "$prerelease_type" in
119159
alpha) suffix="a" ;;
@@ -126,15 +166,16 @@ jobs:
126166
pre_num="$prerelease_increment"
127167
else
128168
# Check if current version is same type of prerelease, if so increment
129-
if echo "$current_version" | grep -qE "${suffix}[0-9]+$"; then
130-
current_pre_num=$(echo "$current_version" | sed -E "s/.*${suffix}([0-9]+)$/\1/")
169+
escaped_target_base_version=$(echo "$target_base_version" | sed 's/\./\\./g')
170+
if echo "$current_version" | grep -qE "^${escaped_target_base_version}${suffix}[0-9]+$"; then
171+
current_pre_num=$(echo "$current_version" | sed -E "s/^${escaped_target_base_version}${suffix}([0-9]+)$/\1/")
131172
pre_num=$((current_pre_num + 1))
132173
else
133174
pre_num=1
134175
fi
135176
fi
136177
137-
new_version="${base_version}${suffix}${pre_num}"
178+
new_version="${target_base_version}${suffix}${pre_num}"
138179
is_prerelease="true"
139180
else
140181
# Standard version bump

.pre-commit-config.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.14.4
3+
rev: v0.15.2
44
hooks:
55
# Run the linter and fix
6-
- id: ruff
6+
- id: ruff-check
77
types_or: [python, pyi, jupyter]
8-
args: [--fix, --config=ci.ruff.toml]
8+
args: [--fix]
99

1010
# Run the formatter.
1111
- id: ruff-format
1212
types_or: [python, pyi, jupyter]
13-
args: [--config=ci.ruff.toml]
1413

1514
- repo: https://github.com/pre-commit/mirrors-mypy
1615
rev: v1.18.2

CLAUDE.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ Environment variables (defined in `_client/environment_variables.py`):
114114
## Important Files
115115

116116
- `pyproject.toml`: Poetry configuration, dependencies, and tool settings
117-
- `ruff.toml`: Local development linting config (stricter)
118-
- `ci.ruff.toml`: CI linting config (more permissive)
119117
- `langfuse/version.py`: Version string (updated by CI release workflow)
120118

121119
## API Generation

ci.ruff.toml

Lines changed: 0 additions & 6 deletions
This file was deleted.

langfuse/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
LangfuseSpan,
2929
LangfuseTool,
3030
)
31+
from .span_filter import (
32+
KNOWN_LLM_INSTRUMENTATION_SCOPE_PREFIXES,
33+
is_default_export_span,
34+
is_genai_span,
35+
is_known_llm_instrumentor,
36+
is_langfuse_span,
37+
)
3138

3239
Langfuse = _client_module.Langfuse
3340

@@ -55,6 +62,11 @@
5562
"EvaluatorStats",
5663
"BatchEvaluationResumeToken",
5764
"BatchEvaluationResult",
65+
"is_default_export_span",
66+
"is_langfuse_span",
67+
"is_genai_span",
68+
"is_known_llm_instrumentor",
69+
"KNOWN_LLM_INSTRUMENTATION_SCOPE_PREFIXES",
5870
"experiment",
5971
"api",
6072
]

langfuse/_client/attributes.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212

1313
import json
1414
from datetime import datetime
15-
from typing import Any, Dict, List, Literal, Optional, Union
15+
from typing import Any, Dict, Literal, Optional, Union
1616

1717
from langfuse._client.constants import (
1818
ObservationTypeGenerationLike,
1919
ObservationTypeSpanLike,
2020
)
2121
from langfuse._utils.serializer import EventSerializer
22+
from langfuse.api import MapValue
2223
from langfuse.model import PromptClient
23-
from langfuse.types import MapValue, SpanLevel
24+
from langfuse.types import SpanLevel
2425

2526

2627
class LangfuseOtelSpanAttributes:
@@ -73,28 +74,14 @@ class LangfuseOtelSpanAttributes:
7374

7475
def create_trace_attributes(
7576
*,
76-
name: Optional[str] = None,
77-
user_id: Optional[str] = None,
78-
session_id: Optional[str] = None,
79-
version: Optional[str] = None,
80-
release: Optional[str] = None,
8177
input: Optional[Any] = None,
8278
output: Optional[Any] = None,
83-
metadata: Optional[Any] = None,
84-
tags: Optional[List[str]] = None,
8579
public: Optional[bool] = None,
8680
) -> dict:
8781
attributes = {
88-
LangfuseOtelSpanAttributes.TRACE_NAME: name,
89-
LangfuseOtelSpanAttributes.TRACE_USER_ID: user_id,
90-
LangfuseOtelSpanAttributes.TRACE_SESSION_ID: session_id,
91-
LangfuseOtelSpanAttributes.VERSION: version,
92-
LangfuseOtelSpanAttributes.RELEASE: release,
9382
LangfuseOtelSpanAttributes.TRACE_INPUT: _serialize(input),
9483
LangfuseOtelSpanAttributes.TRACE_OUTPUT: _serialize(output),
95-
LangfuseOtelSpanAttributes.TRACE_TAGS: tags,
9684
LangfuseOtelSpanAttributes.TRACE_PUBLIC: public,
97-
**_flatten_and_serialize_metadata(metadata, "trace"),
9885
}
9986

10087
return {k: v for k, v in attributes.items() if v is not None}

0 commit comments

Comments
 (0)