uv sync
uv run pre-commit install
To run type checking on the langfuse package, run:
uv run mypy langfuse --no-error-summary- Add .env based on .env.template
-
Run all
uv run --env-file .env pytest -s -v --log-cli-level=INFO -
Run a specific test
uv run --env-file .env pytest -s -v --log-cli-level=INFO tests/test_core_sdk.py::test_flush -
E2E tests involving OpenAI and Serp API are usually skipped, remove skip decorators in tests/test_langchain.py to run them.
- Generate Fern Python SDK in langfuse and copy the files generated in
generated/pythoninto thelangfuse/apifolder in this repo. - Execute the linter by running
uv run ruff format . - Rebuild and deploy the package to PyPi.
Releases are automated via GitHub Actions using PyPI Trusted Publishing (OIDC).
To create a release:
- Go to Actions > Release Python SDK
- Click "Run workflow"
- Select the version bump type:
patch- Bug fixes (1.0.0 → 1.0.1)minor- New features (1.0.0 → 1.1.0)major- Breaking changes (1.0.0 → 2.0.0)prepatch,preminor, orpremajor- Pre-release versions (for example 1.0.0 → 1.0.1a1)
- For pre-releases, select the type:
alpha,beta, orrc - Click "Run workflow"
The workflow will automatically:
- Bump the version in
pyproject.toml - Build the package
- Publish to PyPI
- Create a git tag and GitHub release with auto-generated release notes
Note: The generated SDK reference is currently work in progress.
The SDK reference is generated via pdoc. The docs dependency group is installed on demand when you run the documentation commands.
To update the reference, run the following command:
uv run --group docs pdoc -o docs/ --docformat google --logo "https://langfuse.com/langfuse_logo.svg" langfuseTo run the reference locally, you can use the following command:
uv run --group docs pdoc --docformat google --logo "https://langfuse.com/langfuse_logo.svg" langfuseThanks to the PostHog team for the awesome work on posthog-python. This project is based on it as it was the best starting point to build an async Python SDK.