rerun-catalog-queries
它能做什么
这个技能为你的 AI 提供从 Python 读取 Rerun 目录数据的性能建议。适合数据集查询感觉缓慢,或构建需要查询大量片段的流水线的开发者。
适用场景
- ✓从 Python 查询 Rerun 目录比预期慢的时候。
- ✓你在探索 Rerun 目录中不熟悉的数据集的时候。
- ✓你在构建按每个片段调用目录多次的流水线的时候。
技能链接
https://github.com/rerun-io/rerun/blob/main/skills/rerun-catalog-queries/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我从 Python 读取 Rerun 目录的脚本非常慢。怎样才能加快它?”
每周 5 个新技能,1 分钟读完。
工作原理
这个技能说明每次读取都是一次云端往返,并展示如何减少往返次数以及返回的数据量。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Rerun catalog queries
Practical performance patterns for querying a Rerun catalog
from Python (rerun.catalog.CatalogClient →
dataset.reader(...) → DataFusion DataFrame). The DataFusion side of
the stack is covered by the datafusion-python skill — load that
for DataFrame / SessionContext / expression-API references. This
skill focuses on catalog-specific behaviors and the round-trip costs
that catch teams off guard.
Connect with a rerun:// URL
from rerun.catalog import CatalogClient
client = CatalogClient("rerun+https://api.example.cloud.rerun.io:443")
dataset = client.get_dataset(id=dataset_id)
CatalogClient takes a rerun:// or rerun+https:// URL, or
rerun+http:// for a local server. Do not pass a plain https:// URL.
A segment URL such as
rerun://host:443/dataset/<dataset-id>?segment_id=<segment-id> gives
the server, the dataset id and the segment id.
The client reads the token from REDAP_TOKEN, or from the stored
credentials of rerun auth login, so token= is usually not needed.
The query cost model in one sentence
Every materialization of a dataset.reader(...) DataFrame is one
cloud round-trip, with most of the cost being the network/decode
pair, not the compute. Plan for round-trip count and payload bytes, in
that order.
A typical catalog round-trip is a few seconds even for a tiny result. So:
- 30 segments × 1 query each ≈ 90s. (Naive per-segment loop.)
- 30 segments × 4 queries each ≈ 6 minutes. (A splitter that runs
count+collect_columnfor both starts and stops.) - 1 query covering all 30 segments ≈ 3s.
The same fan-out happens along the entity axis: 10 entities ×
1 filter_contents([one_entity]).reader() each ≈ 30s, vs one
filter_contents([all_entities]).reader() ≈ 3s. Push as much as you
can into one round-trip — across segments and across entities.
Always apply filter_contents and time-window filters before .reader(...)
The single biggest lever:
filter_contents([entity_globs])restricts which entity-path columns the reader produces. Without it, every entity in the dataset is read.- Time-window filters push down to storage and dramatically reduce
bytes scanned when they compare the bare index column with a literal:
df.filter(col(index) >= lit(start)).filter(col(index) <= lit(end)). Integer, timestamp and duration literals of any unit work. Acastor arithmetic on the index column is not pushed down.
Combined: dataset.filter_segments(seg).filter_contents(entities).reader(...) .filter(in_window).select(...).
df.cache() is your friend for repeated probes
When the same materialization gets used by multiple downstream
filter/count/collect calls, materialize once with DataFrame.cache()
and operate on the cached frame:
cached = (
dataset
.filter_segments(seg)
.filter_contents([entity])
.reader(index=index_col)
.select(col(index_col).cast(pa.int64()).alias(index_col), value.alias("v"))
.cache() # one network round-trip, materializes into in-memory batches
)
starts = cached.filter(col("v") == start_val).collect_column(index_col)
stops = cached.filter(stop_pred(col("v"))).collect_column(index_col)
Without cache(), each count() / collect_column() re-executes the
whole reader chain.
When NOT to cache. cache() forces materialization into Arrow
batches, breaking laziness. If downstream code keeps composing more
DataFusion ops on top (joins, windows, further filters) and only
materializes once at the end, caching mid-pipeline turns one execution
into two and pre-empts whatever physical-plan optimizations the engine
could have done across the boundary. Reach for cache() when the
consumers are terminal (count(), collect_column(), to_arrow_table()),
not when they're another lazy DataFrame.
Cross-segment batching: drop filter_segments, group by rerun_segment_id
For pipelines that need the same query on many segments, omit
filter_segments(...) entirely and pull a single cross-segment table.
Every reader row carries a rerun_segment_id column — group locally:
df = dataset.filter_contents(entities).reader(index=index_col)
cached = df.select(
"rerun_segment_id",
col(index_col).cast(pa.int64()).alias(index_col),
value.alias("v"),
).cache()
# Now N filter/aggregate calls are local, not network.
starts = cached.filter(col("v") == start_val).select("rerun_segment_id", index_col).
常见问题
应该如何连接目录?
使用 rerun:// 或 rerun+https:// 网址,而不是普通的 https 地址。客户端可以从 REDAP_TOKEN 读取令牌。
哪个库负责 DataFrame 工作?
这个技能指向 datafusion-python 技能,以了解 DataFrame 和 SessionContext 的细节。
为什么查询很慢?
这个技能说明一次典型往返需要几秒钟,因此读取次数最为关键。
详情
作者的原始描述
Performance patterns and gotchas for querying a Rerun catalog from Python. Reach for this when exploring an unfamiliar dataset, when a CatalogClient/dataset query is unexpectedly slow, or when shaping a per-segment / per-episode pipeline that hits the catalog from many places.
repo: rerun-io/rerun
热度
- GitHub 星标
- 12k
- 排名
- #11549
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
investigate-puffin
12k帮你的智能体分析 Puffin 性能分析录制文件(.puffin 文件),找出耗时较长的代码段,并比较变更前后的跟踪记录。
rerun-blueprint
12k教你的智能体通过为录制或表格编写蓝图,改变 Rerun 查看器的外观,包括布局、视图和隐藏的列。
rerun-chunk-processing
12k教你的智能体使用读取器和 lens 构建 Rerun 数据流水线,将 MCAP、Parquet、视频或 RRD 文件转换为录制。
rerun-data-model
12k帮你的智能体把机器人或多模态数据映射到 Rerun 的数据模型上,先确定实体、组件,以及静态值还是随时间变化的值。