Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
danielballan opened this issue Aug 1, 2021 · 3 comments
Open

Comments

@danielballan
Copy link
Member

danielballan commented Aug 1, 2021

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

No tasks being tracked yet.
@danielballan danielballan changed the title Support fetching only a subset of the metadata Support fetching only a subset of the metadata in the Python client Jan 6, 2022
@danielballan
Copy link
Member Author

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

@danielballan
Copy link
Member Author

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
Copy link
Member Author

danielballan commented Jan 31, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant