poetry self add poetry-dotenv-plugin
poetry install --all-extras
poetry run pre-commit install
To run type checking on the langfuse package, run:
poetry run mypy langfuse --no-error-summary- Add .env based on .env.template
-
Run all
poetry run pytest -s -v --log-cli-level=INFO -
Run a specific test
poetry run 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
poetry 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, please:
- 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)prerelease- Pre-release versions (1.0.0 → 1.0.0a1)
- For pre-releases, select the type:
alpha,beta, orrc - Click "Run workflow"
The workflow will automatically:
- Bump the version in
pyproject.tomlandlangfuse/version.py - 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. You need to have all extra dependencies installed to generate the reference.
poetry install --all-extrasTo update the reference, run the following command:
poetry run pdoc -o docs/ --docformat google --logo "https://langfuse.com/langfuse_logo.svg" langfuseTo run the reference locally, you can use the following command:
poetry run 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.