tiled
tiled copied to clipboard
Support fetching only a subset of the metadata in the Python client
Proposed API after several design discussions with @tacaswell:
results = tree.select(metadata=[('start', 'plan_name'), ('stop', 'exit_status)])
for item in results.items():
# type(item) is some limited proxy object that only implements keys(), items(), values(), ... for now
### Tasks
This is supported in the HTTP API (?select_metadata) but not yet exposed in the Python API.
Per discussion with @pbeaucage, maybe the best way to do this it to add a method like this:
for k, v in c.select_metadata(json_path).items():
# k is the key, v is the metadata dict _only_
Another idea:
for k, v in c.raw_items().page_size(10).select_metadata(…):
# k is the string key
# v is the parsed JSON from the server, as a plain dict
Likewise for raw_values().
Compared the suggestions in my previous comments I like that
- This just exposes the parsed JSON from the server, without wrapping it in a special Tiled client class. There could be a lot of uses for that.
- The name is pretty clear.
- This supports chaining methods as shown above, including those like
select_metadatathat only are supportable onraw_items()and those likepage_size()that make sense ofitems()generally.
This issue may be of interest to @cjtitus.