tiled icon indicating copy to clipboard operation
tiled copied to clipboard

Support fetching only a subset of the metadata in the Python client

Open danielballan opened this issue 4 years ago • 3 comments

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

danielballan avatar Aug 01 '21 13:08 danielballan

This is supported in the HTTP API (?select_metadata) but not yet exposed in the Python API.

danielballan avatar Jan 06 '22 18:01 danielballan

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_

danielballan avatar Jun 22 '23 20:06 danielballan

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_metadata that only are supportable on raw_items() and those like page_size() that make sense of items() generally.

This issue may be of interest to @cjtitus.

danielballan avatar Jan 31 '24 11:01 danielballan