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

Improve support for Transfer filter params #484

Merged
merged 1 commit into from
Oct 12, 2021

Conversation

sirosen
Copy link
Member

@sirosen sirosen commented Oct 8, 2021

This started from the fact that task_list was missing first-class support for filter. Users would have to pass it via query_params previously.

However, after clearing up some confusion about how to write a filter string, it seems that we could provide a better interface for passing these filters. Rather than an elaborate new TransferFilterDict object -- a briefly considered approach -- this adds support for passing a dict of strings or string lists. Lists get comma-separated, strings get passed unmodified.

The resulting semantics allow for usages like

tc.task_list(filter={"task_id": [...]})
tc.operation_ls(filter={"type": "file"})

which are relatively intuitive to read and are handled correctly by the SDK for the user.

A new test for task_list exercises the various filter behaviors (and, NB, relies a little on cpython 3.6+ having order-preserving dicts).

@sirosen sirosen requested a review from aaschaer October 8, 2021 14:54
This started from the fact that `task_list` was missing first-class
support for `filter`. Users would have to pass it via `query_params`
previously.

However, after clearing up some confusion about how to write a filter
string, it seems that we could provide a better interface for passing
these filters. Rather than an elaborate new ``TransferFilterDict``
object -- a briefly considered approach -- this adds support for
passing a dict of strings or string lists. Lists get comma-separated,
strings get passed unmodified.

The resulting semantics allow for usages like

    tc.task_list(filter={"task_id": [...]})
    tc.operation_ls(filter={"type": "file"})

which are relatively intuitive to read and are handled correctly by
the SDK for the user.

A new test for task_list exercises the various filter behaviors (and,
NB, relies a little on cpython 3.6+ having order-preserving dicts).
Copy link
Contributor

@aaschaer aaschaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach, easier to use than raw filter strings, but not a terribly complex addition to the SDK itself. Looks good to me!

@sirosen sirosen merged commit 5103e1a into globus:main Oct 12, 2021
@sirosen sirosen deleted the better-transfer-filters branch October 12, 2021 19:26
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

Successfully merging this pull request may close these issues.

2 participants