vrl-python
VRL Python SDK Project
基于PyO3封装的Vector Remap Language (VRL) Python SDK
Python 开发者快速使用指南 / Quick Start for Python Developers
包名(PyPI):
vrl-python;导入模块:vrl_python
安装 / Install
# 使用 pip(推荐) / Use pip (recommended)
pip install vrl-python
# 使用 uv / Use uv
uv add vrl-python
# 使用 Poetry / Use Poetry
poetry add vrl-python
运行环境 / Requirements:Python >= 3.8
快速开始 / Quick Start
# 中文:从 vrl_python 导入 VRLRuntime,并运行一个最小示例
# English: Import VRLRuntime from vrl_python and run a minimal example
from vrl_python import VRLRuntime
runtime = VRLRuntime() # 中文:使用默认UTC;English: uses UTC by default
program = ".field = \"value\"" # 中文:设置字段;English: set a field
event = {} # 中文:输入事件;English: input event
result = runtime.execute(program, event)
print(result.processed_event) # {'field': 'value'}
一次性执行(便捷方法) / One-shot execution (convenience)
# 中文:无需先创建实例,直接编译+执行
# English: compile+execute in one call without creating an instance
from vrl_python import VRLRuntime
result = VRLRuntime.run('.greeting = "hello"', {})
print(result.processed_event) # {'greeting': 'hello'}
语法检查 / Syntax Check
# 中文:仅检查语法,不执行
# English: check syntax only, no execution
from vrl_python import VRLRuntime
diagnostic = VRLRuntime.check_syntax('.parsed = parse_json(.message)')
if diagnostic is None:
print('✅ 语法正确 / Syntax OK')
else:
print('❌ 发现错误 / Errors found:', diagnostic.messages)
print(diagnostic.formatted_message)
项目概述
本项目旨在为Vector的VRL语言提供一个Python SDK封装,使Python开发者能够直接在Python环境中使用VRL的强大数据处理能力。封装基于PyO3实现,提供高性能的Rust底层实现和友好的Python API。
功能特性
• ✅ 编译和执行VRL程序
• ✅ 支持事件数据处理和转换
• ✅ 完整的错误处理和诊断信息
• ✅ VRL语法检查和诊断 (新增)
• ✅ 完整的类型提示支持 (新增)
• ✅ 时区支持
• ✅ 性能监控(执行时间统计)
• ✅ 预编译和缓存支持
快速开始
安装
pip install vrl-python
基本用法
from vrl_python import VRLRuntime
初始化运行时
runtime = VRLRuntime()
定义VRL程序
program = """ .message = parse_json!(.message) .new_field = "new value" """
准备输入事件
event = { "message": '{"key": "value"}', "timestamp": "2023-01-01T00:00:00Z" }
执行VRL程序
result = runtime.execute(program, event)
print(result.processed_event)
输出: {'message': {'key': 'value'}, 'timestamp': '2023-01-01T00:00:00Z', 'new_field': 'new value'}
VRL语法检查
from vrl_python import VRLRuntime
检查VRL程序语法
program = """ .parsed = parse_json(.message) """
diagnostic = VRLRuntime.check_syntax(program) if diagnostic is None: print("✅ 语法正确") else: print(f"❌ 发现错误: {diagnostic.messages}") print(diagnostic.formatted_message) # 详细的错误信息,包含位置和建议
版本管理
本项目使用 bump-my-version 管理版本号,确保 Rust 和 Python 版本同步。
常用命令
make version # 查看当前版本 make check-version # 检查版本一致性 make bump-patch # 升级补丁版本 (0.1.0 -> 0.1.1) make bump-minor # 升级次版本 (0.1.0 -> 0.2.0) make bump-major # 升级主版本 (0.1.0 -> 1.0.0)
详细文档:VERSION_MANAGEMENT.md
开发计划
阶段1: 核心功能实现 ✅ (已完成) • ✅ 项目初始化与PyO3配置
• ✅ 基本VRL编译执行功能
• ✅ 错误处理与诊断信息
• ✅ 单元测试框架搭建(11个测试全部通过)
• ✅ 示例代码和文档
阶段2: 高级功能扩展 自定义函数支持
时区配置支持
性能优化与缓存
文档生成
阶段3: 生产准备 CI/CD流水线
性能基准测试
PyPI发布准备
开发环境
• Rust 1.70+
• Python 3.8+
• RustRover IDE (推荐)
• maturin (构建工具)
CI/CD
• ✅ GitHub Actions 自动化测试
• ✅ 多平台支持 (Linux, macOS, Windows)
• ✅ 自动发布到 PyPI/TestPyPI
• ✅ Trusted Publishing (安全发布)
构建与测试
使用 Makefile(推荐)
查看所有可用命令
make help
安装开发环境
make install
开发模式构建
make dev
运行测试
make test
运行示例
make examples
完整检查(格式化 + 检查 + 测试)
make check
手动命令
创建虚拟环境
uv venv source .venv/bin/activate
安装依赖
uv pip install maturin pytest pytest-cov
开发模式构建
maturin develop
发布模式构建
maturin develop --release
运行测试
pytest tests/ -v
运行示例
python examples/basic_usage.py
贡献指南
欢迎贡献!请遵循以下步骤:
- Fork仓库并创建分支
- 提交代码变更
- 添加/更新测试用例
- 运行测试确保通过
- 提交Pull Request
技术参考
• https://vector.dev/docs/reference/vrl/
• https://github.com/vectordotdev/vrl
许可证
MIT
Metadata
Release files for vrl-python 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| vrl_python-0.1.0.tar.gz | 128.5 kB | With provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| vrl_python-0.1.0-cp38-abi3-win_amd64.whl | CPython 3.8 | abi3 | Windows x86-64 | Details |
| vrl_python-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.8 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| vrl_python-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.8 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| vrl_python-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl | CPython 3.8 | abi3 | macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64 | Details |
Total release size: 35.1 MB
Release files / vrl_python-0.1.0.tar.gz
| Download URL | vrl_python-0.1.0.tar.gz |
|---|---|
| Size | 128.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c0cc0fc4e576117fcf056c177f0cb29db24b8f576b79d88feff518fd5d38deb
|
|
BLAKE2b-256 checksum How to use checksums |
030d2067b301055a7f9216ac8403d990e31c5e1f18b1e7149b6d292c604c4a76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2025.
Transparency logRelease files / vrl_python-0.1.0-cp38-abi3-win_amd64.whl
| Download URL | vrl_python-0.1.0-cp38-abi3-win_amd64.whl |
|---|---|
| Size | 6.8 MB |
| Tags | CPython 3.8 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
bf7dd64cef9796b8ed3c292b62d8fd9da87425a61bf183e5980b3ea54a577591
|
|
BLAKE2b-256 checksum How to use checksums |
e83c94a9056bee5ce58e4e6ce5a52c4c0b8028d5af28b367d0ab1a8cf5865cff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2025.
Transparency logRelease files / vrl_python-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | vrl_python-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.4 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b84144c5337e60ab89751cef56025000b861d4983e3d94f517f8de046ec65787
|
|
BLAKE2b-256 checksum How to use checksums |
3b3db886f5012d94ab9efe715bf59ac11376f6d1d110edd8ef58dd72baf60889
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2025.
Transparency logRelease files / vrl_python-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | vrl_python-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 7.1 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
82ac56f7e9c19a5fb53b8ef87432baac88b685b6ccf2ed3ec9fccd89d7d2f24a
|
|
BLAKE2b-256 checksum How to use checksums |
303ffd0d068a19a3f7608d05368daf76d0a0aaef6b7a3963be1f7f04e86ccfca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2025.
Transparency logRelease files / vrl_python-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | vrl_python-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 13.7 MB |
| Tags | CPython 3.8 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
50239a076f78fa4a9286c181697f1cbd21b54c1b48514931662b7227e922ec7a
|
|
BLAKE2b-256 checksum How to use checksums |
11861395a99e94aeae3a1a929c10e56bf2410640bb3343dd376a2936cb048fde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2025.
Transparency logSecurity for vrl-python 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 5 files in this release have been uploaded with provenance metadata.
Attestation for vrl_python-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.