Skip to content

Commit 892c843

Browse files
committed
save all
Signed-off-by: Teo <teocns@gmail.com>
1 parent d81c53d commit 892c843

File tree

4 files changed

+151
-84
lines changed

4 files changed

+151
-84
lines changed

.github/workflows/codecov.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ jobs:
3131

3232
- name: Install dependencies
3333
run: |
34-
uv pip install -e ".[test]"
34+
uv pip install -e ".[test-langchain,ci]"
3535
3636
- name: Run tests
3737
run: |
38-
uv pip install coverage
3938
coverage run --source . -m pytest
4039
coverage report -m
4140
coverage xml

CONTRIBUTING.md

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,23 @@ Even if you're not ready to contribute code, we'd love to hear your thoughts. Dr
7070
```
7171

7272
2. **Virtual Environment**:
73-
We recommend using `poetry` or `venv`:
73+
We use UV for dependency management:
7474
```bash
75-
python -m venv venv
76-
source venv/bin/activate # Unix
77-
.\venv\Scripts\activate # Windows
75+
# Install dependencies for development
76+
uv sync
77+
78+
# For testing with LangChain
79+
uv sync --extra='test-langchain'
80+
81+
# For CI environment
82+
uv sync --extra='ci'
83+
84+
# For multiple extras
85+
uv sync --extra='test-langchain' --extra='ci'
7886
```
7987

8088
3. **Pre-commit Setup**:
81-
We use pre-commit hooks to automatically format and lint code. Set them up with:
89+
We use pre-commit hooks to automatically format and lint code:
8290
```bash
8391
pip install pre-commit
8492
pre-commit install
@@ -89,32 +97,46 @@ Even if you're not ready to contribute code, we'd love to hear your thoughts. Dr
8997
pre-commit run --all-files
9098
```
9199

92-
3. **Test Environment Setup**:
100+
## Testing
101+
102+
We maintain comprehensive testing documentation in [tests/README.md](tests/README.md). Here's a quick start:
103+
104+
1. **Install Test Dependencies**:
105+
```bash
106+
# Install core development dependencies
107+
uv sync
108+
109+
# For LangChain testing
110+
uv sync --extra='test-langchain'
111+
```
112+
113+
2. **Run Tests**:
93114
```bash
94-
uv pip install -e ".[test]" # Install with test dependencies
95-
pytest # Run tests for current Python version
115+
# Run all tests
116+
pytest
117+
118+
# Run specific test file
119+
pytest tests/test_file.py
120+
121+
# Run specific test
122+
pytest tests/test_file.py::test_name
96123
```
97124

98-
For testing across multiple Python versions:
125+
3. **Testing Across Python Versions**:
126+
UV makes it easy to test across different Python versions:
99127
```bash
100128
for ver in 3.7 3.8 3.9 3.10 3.11 3.12 3.13; do
101129
uv venv -p $ver .venv-$ver
102-
.venv-$ver/bin/pip install -e ".[test]"
130+
.venv-$ver/bin/uv sync --extra='test-langchain'
103131
.venv-$ver/bin/pytest
104132
done
105133
```
106134

107-
## Testing
108-
109-
We maintain comprehensive testing documentation in [tests/README.md](tests/README.md). This includes:
110-
111-
- Test structure and organization
112-
- How to run tests
113-
- Using VCR.py for HTTP interaction testing
114-
- Writing new tests
115-
- Test dependencies and setup
116-
117-
For detailed testing instructions and best practices, please refer to the testing documentation.
135+
4. **Coverage Reports**:
136+
```bash
137+
coverage run --source . -m pytest
138+
coverage report -m
139+
```
118140

119141
## Adding LLM Providers
120142

pyproject.toml

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ readme = "README.md"
1717
requires-python = ">=3.7"
1818
classifiers = [
1919
"Programming Language :: Python :: 3",
20+
"Programming Language :: Python :: 3.8",
21+
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
23+
"Programming Language :: Python :: 3.11",
24+
"Programming Language :: Python :: 3.12",
25+
"Programming Language :: Python :: 3.13",
2026
"License :: OSI Approved :: MIT License",
2127
"Operating System :: OS Independent",
2228
]
@@ -25,76 +31,78 @@ dependencies = [
2531
"psutil>=5.9.8,<6.1.0",
2632
"termcolor>=2.3.0,<2.5.0",
2733
"PyYAML>=5.3,<7.0",
28-
"opentelemetry-api>=1.22.0,<2.0.0", # API for interfaces
29-
"opentelemetry-sdk>=1.22.0,<2.0.0", # SDK for implementation
30-
"opentelemetry-exporter-otlp-proto-http>=1.22.0,<2.0.0", # For OTLPSpanExporter
31-
]
32-
33-
[dependency-groups]
34-
dev = [
35-
"pytest==7.4.0",
36-
"pytest-depends",
37-
"pytest-asyncio",
38-
"pytest-vcr",
39-
"pytest-mock",
40-
"pyfakefs",
41-
"requests_mock==1.11.0",
42-
"ruff",
43-
"vcrpy>=6.0.0,<7.0.0; python_version >= '3.8'",
44-
"urllib3<2.0.0; python_version >= '3.8'", # Required for vcrpy compatibility
45-
"python-dotenv"
46-
]
47-
ci = [
48-
"tach~=0.9",
34+
"opentelemetry-api>=1.22.0,<2.0.0",
35+
"opentelemetry-sdk>=1.22.0,<2.0.0",
36+
"opentelemetry-exporter-otlp-proto-http>=1.22.0,<2.0.0",
37+
"typing-extensions>=4.9.0; python_version >= '3.8'",
38+
"pydantic>=2.7.4,<3.0.0; python_version < '3.13'",
39+
"pydantic-core>=2.23.4; python_version >= '3.8' and python_version < '3.13'"
4940
]
5041

5142
[project.optional-dependencies]
52-
dev = [
53-
"pytest==7.4.0",
54-
"pytest-depends",
55-
"pytest-asyncio",
56-
"pytest-vcr",
57-
"pytest-mock",
58-
"pyfakefs",
59-
"requests_mock==1.11.0",
60-
"ruff",
61-
"vcrpy>=6.0.0,<7.0.0; python_version >= '3.8'",
62-
"urllib3<2.0.0; python_version >= '3.8'", # Required for vcrpy compatibility
63-
"python-dotenv"
64-
]
43+
# Optional LangChain integration for end users
6544
langchain = [
66-
"langchain==0.2.14; python_version >= '3.8.1'"
45+
"langchain>=0.2.14; python_version >= '3.8.1' and python_version < '3.13'",
46+
"langchain-core>=0.3.0; python_version >= '3.8.1' and python_version < '3.13'",
47+
"openai>=1.58.1; python_version < '3.13'"
6748
]
49+
50+
# LangChain testing dependencies
51+
test-langchain = [
52+
"langchain-core>=0.3.0; python_version >= '3.8.1' and python_version < '3.13'",
53+
"langchain>=0.2.14; python_version >= '3.8.1' and python_version < '3.13'"
54+
]
55+
56+
[dependency-groups]
6857
test = [
69-
"pytest==7.4.0",
70-
"pytest-depends",
71-
"pytest-asyncio",
72-
"pytest-vcr",
73-
"pytest-mock",
74-
"pyfakefs",
75-
"requests_mock==1.11.0",
76-
"coverage",
77-
"mypy",
78-
"types-requests",
79-
"psutil",
8058
"openai",
81-
"langchain-core",
8259
"langchain",
83-
"termcolor",
84-
"python-dotenv",
8560
]
86-
87-
[project.scripts]
88-
agentops = "agentops.cli:main"
61+
# CI dependencies
62+
ci = [
63+
"tach~=0.9" # Task runner for CI/CD pipelines
64+
]
8965

9066
[project.urls]
9167
Homepage = "https://github.com/AgentOps-AI/agentops"
9268
Issues = "https://github.com/AgentOps-AI/agentops/issues"
9369

70+
[tool.uv]
71+
compile-bytecode = true # Enable bytecode compilation for better performance
72+
73+
# Core development dependencies
74+
dev-dependencies = [
75+
# Testing essentials
76+
"pytest==7.4.0", # Testing framework with good async support
77+
"pytest-depends", # For testing complex agent workflows
78+
"pytest-asyncio", # Async test support for testing concurrent agent operations
79+
"pytest-vcr", # HTTP interaction testing
80+
"pytest-mock", # Mocking capabilities for isolating agent components
81+
"pyfakefs", # File system testing
82+
83+
# Code quality and type checking
84+
"ruff", # Fast Python linter for maintaining code quality
85+
"coverage", # Code coverage tracking for quality assurance
86+
"mypy", # Static type checking for better reliability
87+
"types-requests", # Type stubs for requests library
88+
89+
# HTTP mocking and environment
90+
"requests_mock==1.11.0", # Mock HTTP requests for testing agent external communications
91+
"vcrpy>=6.0.0,<7.0.0; python_version >= '3.8'", # HTTP interaction recording for Python 3.8+
92+
"urllib3<2.0.0; python_version >= '3.8'", # Required for vcrpy compatibility
93+
"python-dotenv", # Environment management for secure testing
94+
95+
# Agent integration testing
96+
"psutil", # System resource monitoring for agent performance
97+
"termcolor" # Output formatting for test results
98+
]
99+
100+
[tool.uv.pip]
101+
strict = true # Enforce strict dependency resolution for reliability
102+
94103
[tool.autopep8]
95104
max_line_length = 120
96105

97-
98106
[tool.pytest.ini_options]
99107
asyncio_mode = "strict"
100108
asyncio_default_fixture_loop_scope = "function" # WARNING: Changing this may break tests. A `module`-scoped session might be faster, but also unstable.
@@ -153,11 +161,3 @@ exclude = [
153161

154162
[tool.setuptools]
155163
packages = ["agentops"]
156-
157-
[tool.uv]
158-
default-groups = ["dev"]
159-
python = "3.7" # Minimum supported version
160-
compile-bytecode = true
161-
162-
[tool.uv.pip]
163-
strict = true

test_python_versions.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
# Colors for output
4+
GREEN='\033[0;32m'
5+
RED='\033[0;31m'
6+
NC='\033[0m' # No Color
7+
8+
# Function to test a Python version
9+
test_python_version() {
10+
version=$1
11+
echo "Testing Python $version..."
12+
13+
# Remove existing venv if it exists
14+
rm -rf .venv
15+
16+
# Try to create venv and sync
17+
if uv venv -p "python$version" 2>/dev/null && \
18+
source .venv/bin/activate && \
19+
uv sync --dev; then
20+
echo -e "${GREEN}✓ Python $version: Success${NC}"
21+
deactivate
22+
return 0
23+
else
24+
echo -e "${RED}✗ Python $version: Failed${NC}"
25+
deactivate 2>/dev/null
26+
return 1
27+
fi
28+
}
29+
30+
# Array of Python versions to test
31+
versions=("3.7" "3.8" "3.9" "3.10" "3.11" "3.12" "3.13")
32+
33+
# Track overall success
34+
success_count=0
35+
total_count=${#versions[@]}
36+
37+
# Test each version
38+
for version in "${versions[@]}"; do
39+
if test_python_version "$version"; then
40+
((success_count++))
41+
fi
42+
echo "----------------------------------------"
43+
done
44+
45+
# Print summary
46+
echo "Summary: $success_count/$total_count versions succeeded"

0 commit comments

Comments
 (0)