Compare commits

..

8 Commits

Author SHA1 Message Date
Clelia (Astra) Bertelli acfc90d0a8 fix: change name to test_index in unit_tests 2025-08-05 19:26:30 +02:00
Clelia (Astra) Bertelli e80376c97e chore: moving tests 2025-08-05 19:17:28 +02:00
Clelia (Astra) Bertelli 5acca1fc98 ci: run all tests using explicit patterns 2025-08-05 11:16:06 +02:00
Clelia (Astra) Bertelli 68cb4dacd3 chore: differentiate between e2e and non-e2e tests 2025-08-05 11:09:51 +02:00
Clelia (Astra) Bertelli 0b16edf058 fix: test e2e only on PR 2025-08-04 12:29:33 +02:00
Clelia (Astra) Bertelli 5bb9816f04 ci: job name correction 🤦 2025-08-04 12:28:00 +02:00
Clelia (Astra) Bertelli d55f8cf153 ci: workflow name and linting 2025-08-04 12:24:50 +02:00
Clelia (Astra) Bertelli 09a911ee62 fix: run e2e only on 3.12 2025-08-04 12:20:11 +02:00
26 changed files with 4417 additions and 3503 deletions
-95
View File
@@ -1,95 +0,0 @@
name: Claude Code
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
steps:
- name: Check repository access
id: check-access
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get the user who triggered the event
case "${{ github.event_name }}" in
"issue_comment")
USER="${{ github.event.comment.user.login }}"
;;
"pull_request_review_comment")
USER="${{ github.event.comment.user.login }}"
;;
"pull_request_review")
USER="${{ github.event.review.user.login }}"
;;
"issues")
USER="${{ github.event.issue.user.login }}"
;;
esac
echo "Checking repository access for user: $USER"
# Check if user has write access to the repository
REPO="${{ github.repository }}"
if gh api repos/$REPO/collaborators/$USER/permission --jq '.permission' | grep -E "(admin|write)" > /dev/null 2>&1; then
echo "User $USER has write access to the repository"
echo "authorized=true" >> $GITHUB_OUTPUT
else
echo "User $USER does not have write access to the repository"
echo "authorized=false" >> $GITHUB_OUTPUT
exit 1
fi
- name: Checkout repository
if: steps.check-access.outputs.authorized == 'true'
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Run Claude Code
if: steps.check-access.outputs.authorized == 'true'
id: claude
uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_GITHUB_API_KEY }}
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
# model: "claude-opus-4-20250514"
# Optional: Customize the trigger phrase (default: @claude)
# trigger_phrase: "/claude"
# Optional: Trigger when specific user is assigned to an issue
# assignee_trigger: "claude-bot"
# Optional: Allow Claude to run specific commands
# Allow bash commands to be run, for things like running tests, linting, etc.
allowed_tools: "Bash(rg:*),Bash(find:*),Bash(grep:*),Bash(pnpm:*),Bash(npm:*),Bash(uv:*),Bash(pip:*),Bash(pipx:*),Bash(make:*),Bash(cd:*),WebFetch"
# Optional: Add custom instructions for Claude to customize its behavior for your project
# custom_instructions: |
# Follow our coding standards
# Ensure all new code has tests
# Use TypeScript for new files
# Optional: Custom environment variables for Claude
# claude_env: |
# NODE_ENV: test
+1
View File
@@ -28,6 +28,7 @@ jobs:
with:
node-version-file: "ts/llama_cloud_services/.nvmrc"
- name: Install dependencies
working-directory: ts/llama_cloud_services/
run: pnpm install --no-frozen-lockfile
- name: Run lint
working-directory: ts/llama_cloud_services/
+1
View File
@@ -22,6 +22,7 @@ jobs:
node-version-file: "ts/llama_cloud_services/.nvmrc"
- name: Install dependencies
working-directory: ts/llama_cloud_services
run: pnpm install --no-frozen-lockfile
- name: Build tarball
+38
View File
@@ -0,0 +1,38 @@
name: Test end-to-end - Python
on:
pull_request:
paths:
- "py/**"
env:
UV_VERSION: "0.7.20"
LLAMA_CLOUD_API_KEY: ${{ secrets.LLAMA_CLOUD_API_KEY }}
jobs:
test_e2e:
runs-on: ubuntu-latest
strategy:
# You can use PyPy versions in python-version.
# For example, pypy-2.7 and pypy-3.8
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: ${{ env.UV_VERSION }}
- name: Set up Python
run: uv python install ${{ matrix.python-version }} && uv python pin ${{ matrix.python-version }}
- name: Run Tests
working-directory: py
run: uv run pytest unit_tests/ tests/ -v
- name: Remove virtual environment
working-directory: py
run: rm -rf .venv/
+1 -2
View File
@@ -12,7 +12,6 @@ on:
env:
UV_VERSION: "0.7.20"
LLAMA_CLOUD_API_KEY: ${{ secrets.LLAMA_CLOUD_API_KEY }}
jobs:
test:
@@ -36,7 +35,7 @@ jobs:
- name: Run Tests
working-directory: py
run: uv run -- pytest tests/**/test_*.py
run: uv run pytest unit_tests/ -v
- name: Remove virtual environment
working-directory: py
+2 -7
View File
@@ -30,13 +30,8 @@ jobs:
with:
node-version-file: "ts/llama_cloud_services/.nvmrc"
- name: Install dependencies
working-directory: ts/llama_cloud_services/
run: pnpm install --no-frozen-lockfile
- name: Run Build
working-directory: ts/llama_cloud_services/
run: pnpm build
- name: Run Tests
- name: Run tests
working-directory: ts/llama_cloud_services/
run: pnpm test
- name: Run e2e tests
working-directory: ts/e2e-tests/
run: pnpm test
+1 -1
View File
@@ -33,7 +33,7 @@ repos:
rev: v1.0.1
hooks:
- id: mypy
exclude: ^py/tests/
exclude: ^py/tests|^py/unit_tests
additional_dependencies:
[
"types-requests",
+790 -3229
View File
File diff suppressed because it is too large Load Diff
-2
View File
@@ -1,2 +0,0 @@
packages:
- "ts/**"
+2 -2
View File
@@ -124,8 +124,8 @@ def extraction_agent(test_case: TestCase, extractor: LlamaExtract):
@pytest.mark.skipif(
"CI" in os.environ,
reason="CI environment is not suitable for benchmarking",
"CI" in os.environ or not LLAMA_CLOUD_API_KEY,
reason="LLAMA_CLOUD_API_KEY not set or CI environment not suitable for benchmarking",
)
@pytest.mark.parametrize("test_case", get_test_cases(), ids=lambda x: x.name)
@pytest.mark.asyncio(loop_scope="session")
-11
View File
@@ -16,7 +16,6 @@ from llama_cloud import (
from llama_cloud.client import LlamaCloud
from llama_index.core.bridge.pydantic import BaseModel
from llama_index.core.constants import DEFAULT_BASE_URL
from llama_index.core.indices.managed.base import BaseManagedIndex
from llama_index.core.schema import Document, ImageNode
from llama_cloud_services.index import (
LlamaCloudIndex,
@@ -93,16 +92,6 @@ def _setup_index_with_file(
return pipeline
def test_class():
names_of_base_classes = [b.__name__ for b in LlamaCloudIndex.__mro__]
assert BaseManagedIndex.__name__ in names_of_base_classes
def test_conflicting_index_identifiers():
with pytest.raises(ValueError):
LlamaCloudIndex(name="test", pipeline_id="test", index_id="test")
@pytest.mark.skipif(
not base_url or not api_key, reason="No platform base url or api key set"
)
View File
+16
View File
@@ -0,0 +1,16 @@
import pytest
from llama_index.core.indices.managed.base import BaseManagedIndex
from llama_cloud_services.index import (
LlamaCloudIndex,
)
def test_class():
names_of_base_classes = [b.__name__ for b in LlamaCloudIndex.__mro__]
assert BaseManagedIndex.__name__ in names_of_base_classes
def test_conflicting_index_identifiers():
with pytest.raises(ValueError):
LlamaCloudIndex(name="test", pipeline_id="test", index_id="test")
-23
View File
@@ -1,23 +0,0 @@
{
"name": "@llamaindex/llama-cloud-services-e2e-tests",
"private": true,
"version": "0.0.1",
"type": "module",
"scripts": {
"test": "pnpm run test:node16 && pnpm run test:nodenext && pnpm run test:bundler",
"build": "pnpm run build:node16 && pnpm run build:nodenext && pnpm run build:bundler",
"build:node16": "tsc -p src/tsconfig.node16.json --outDir dist/node16",
"test:node16": "pnpm run build:node16 && node --test dist/node16/index.e2e.js",
"build:nodenext": "tsc -p src/tsconfig.nodenext.json --outDir dist/nodenext",
"test:nodenext": "pnpm run build:nodenext && node --test dist/nodenext/index.e2e.js",
"build:bundler": "tsc -p src/tsconfig.bundler.json --outDir dist/bundler",
"test:bundler": "pnpm run build:bundler && node --test dist/bundler/index.e2e.js",
"build:node": "tsc -p src/tsconfig.node.json --outDir dist/node",
"test:node": "pnpm run build:node && node --test dist/node/index.e2e.js"
},
"devDependencies": {
"@types/node": "^24.0.13",
"llama-cloud-services": "workspace:*",
"typescript": "^5.9.2"
}
}
-38
View File
@@ -1,38 +0,0 @@
import { ok } from "node:assert";
import { test } from "node:test";
import { LlamaCloudIndex } from "llama-cloud-services";
import { LlamaParseReader } from "llama-cloud-services";
test("LlamaIndex module resolution test", async (t) => {
await t.test("works with ES module", () => {
const index = new LlamaCloudIndex({
name: "test-index",
projectName: "Default",
});
const reader = new LlamaParseReader({
resultType: "markdown",
verbose: false,
});
ok(index !== undefined);
ok(reader !== undefined);
});
await t.test("works with dynamic imports", async () => {
const mod = await import("llama-cloud-services"); // simulates commonjs
ok(mod !== undefined);
const index = new mod.LlamaCloudIndex({
name: "test-index",
projectName: "Default",
});
ok(index !== undefined);
});
await t.test("all imports work", () => {
const allImports = [
LlamaCloudIndex,
];
ok(allImports.filter(Boolean).length === allImports.length);
});
});
-14
View File
@@ -1,14 +0,0 @@
{
"compilerOptions": {
"module": "esnext",
"moduleResolution": "bundler",
"target": "esnext",
"outDir": "dist",
"rootDir": ".",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["**/*.ts"],
"exclude": ["node_modules", "dist"]
}
-14
View File
@@ -1,14 +0,0 @@
{
"compilerOptions": {
"module": "esnext",
"moduleResolution": "node",
"target": "esnext",
"outDir": "dist",
"rootDir": ".",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["**/*.ts"],
"exclude": ["node_modules", "dist"]
}
-14
View File
@@ -1,14 +0,0 @@
{
"compilerOptions": {
"module": "node16",
"moduleResolution": "node16",
"target": "esnext",
"outDir": "dist",
"rootDir": ".",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["**/*.ts"],
"exclude": ["node_modules", "dist"]
}
-14
View File
@@ -1,14 +0,0 @@
{
"compilerOptions": {
"module": "nodenext",
"moduleResolution": "nodenext",
"target": "esnext",
"outDir": "dist",
"rootDir": ".",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["**/*.ts"],
"exclude": ["node_modules", "dist"]
}
-34
View File
@@ -1,34 +0,0 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"verbatimModuleSyntax": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"noUncheckedIndexedAccess": true,
"strictNullChecks": true,
"exactOptionalPropertyTypes": true,
"strict": true,
"skipLibCheck": true,
"rootDir": "./src",
"outDir": "./dist/type",
"tsBuildInfoFile": "./dist/.tsbuildinfo",
"incremental": true,
"lib": [
"ES2022",
"DOM",
"DOM.Iterable",
"DOM.AsyncIterable"
],
"types": [
"node"
]
},
"include": [
"./src"
],
"exclude": [
"node_modules"
]
}
File diff suppressed because it is too large Load Diff
@@ -16350,7 +16350,7 @@ export const PromptConfSchema = {
default: `
Provide a brief explanation for how you arrived at the extracted value based on the source text provided.
- For inferred values, explain the reasoning behind the extraction briefly.
- For simple verbatim extraction, output 'VERBATIM EXTRACTION'.
- For simple verbatim extraction, output 'VERBATIM EXTRACTION'.
- When supporting data is not present in the source text, output 'INSUFFICIENT DATA' and emit blank or null values for the value__ field.
`,
},
@@ -17689,7 +17689,7 @@ export const StructParseConfSchema = {
reasoning_prompt: `
Provide a brief explanation for how you arrived at the extracted value based on the source text provided.
- For inferred values, explain the reasoning behind the extraction briefly.
- For simple verbatim extraction, output 'VERBATIM EXTRACTION'.
- For simple verbatim extraction, output 'VERBATIM EXTRACTION'.
- When supporting data is not present in the source text, output 'INSUFFICIENT DATA' and emit blank or null values for the value__ field.
`,
cite_sources_prompt: {
@@ -3219,7 +3219,7 @@ export const zPromptConf = z.object({
reasoning_prompt: z.string().optional().default(`
Provide a brief explanation for how you arrived at the extracted value based on the source text provided.
- For inferred values, explain the reasoning behind the extraction briefly.
- For simple verbatim extraction, output 'VERBATIM EXTRACTION'.
- For simple verbatim extraction, output 'VERBATIM EXTRACTION'.
- When supporting data is not present in the source text, output 'INSUFFICIENT DATA' and emit blank or null values for the value__ field.
`),
cite_sources_prompt: z