-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce APIs for list_recordings and update_metadata (#8223)
### Related - rerun-io/dataplatform#17 ### What - Python API support for the list / update APIs - Example script that uses them for a simple CLI app
- Loading branch information
Showing
11 changed files
with
575 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""Script to show how to interact with a remote storage node via python APIs.""" | ||
|
||
from __future__ import annotations | ||
|
||
import argparse | ||
|
||
import polars as pl | ||
import pyarrow as pa | ||
import rerun as rr | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
|
||
subparsers = parser.add_subparsers(dest="subcommand") | ||
|
||
print_cmd = subparsers.add_parser("print", help="Print everything") | ||
update_cmd = subparsers.add_parser("update", help="Update metadata for a recording") | ||
|
||
update_cmd.add_argument("id", help="ID of the recording to update") | ||
update_cmd.add_argument("key", help="Key of the metadata to update") | ||
update_cmd.add_argument("value", help="Value of the metadata to update") | ||
|
||
args = parser.parse_args() | ||
|
||
# Register the new rrd | ||
conn = rr.remote.connect("http://0.0.0.0:51234") | ||
|
||
catalog = pl.from_arrow(conn.list_recordings()) | ||
|
||
if args.subcommand == "print": | ||
print(catalog) | ||
|
||
if args.subcommand == "update": | ||
id = catalog.filter(catalog["id"].str.starts_with(args.id)).select(pl.first("id")).item() | ||
|
||
if id is None: | ||
print("ID not found") | ||
exit(1) | ||
print(f"Updating metadata for {id}") | ||
|
||
conn.update_metadata(id, {args.key: pa.array([args.value])}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.