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

DM-25760: add --glob to butler query-collections #363

Merged
merged 5 commits into from Sep 2, 2020
Merged

Conversation

n8pease
Copy link
Contributor

@n8pease n8pease commented Sep 1, 2020

No description provided.

@n8pease
Copy link
Contributor Author

n8pease commented Sep 1, 2020

I see the current linter errors. I have to run out for about an hour and will address these when I get back.

@n8pease
Copy link
Contributor Author

n8pease commented Sep 1, 2020

(all checks are passing now)

Copy link
Member

@timj timj left a comment

Choose a reason for hiding this comment

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

Looks okay but I think I'd tweak the final test to check for outcomes and not specifics, and I think we should consider having a special case for * glob.


Returns
-------
expressions : [`str` or `...`]
Copy link
Member

Choose a reason for hiding this comment

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

This docstring is wrong now.

Parameters
----------
expressions : `list` [`str` or `...`]
A glob-style pattern string to convert, or an Ellipsis.
Copy link
Member

Choose a reason for hiding this comment

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

This docstring is now wrong (I saw the code originally had ellipsis and I had a long comment on not understanding that).

@@ -47,7 +51,11 @@ def queryCollections(repo, collection_type, flatten_chains, include_chains):
collection names.
"""
butler = Butler(repo)
kwargs = {}
if glob:
kwargs['expression'] = globToRegex(glob)
Copy link
Member

Choose a reason for hiding this comment

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

From your earlier version handling of ... for this did make me wonder whether there is an efficiency gain for globToRegex to spot * as a specil case -- it probably should warn if * is passed in with other globs and if they just pass in * it should probably return an empty list rather than a regex if we assume that empty list means no constraints (that would save a lot of unnecessary regex processing when we know there is no filtering).

@@ -47,7 +51,11 @@ def queryCollections(repo, collection_type, flatten_chains, include_chains):
collection names.
"""
butler = Butler(repo)
kwargs = {}
if glob:
Copy link
Member

Choose a reason for hiding this comment

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

since globToRegex can take an empty list it might be clearer to write this as:

filter = globToRegex(glob)
if filter:
    kwargs["expression"] = filter

collections = butler.registry.queryCollections(collectionType=collection_type,
flattenChains=flatten_chains,
includeChains=include_chains)
includeChains=include_chains,
**kwargs)
return {'collections': list(collections)}
Copy link
Member

Choose a reason for hiding this comment

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

Single quotes have crept into this file.

globToRegex function api.
"""
testval = ["foo*", "bar"]
self.assertEqual(globToRegex(testval),
Copy link
Member

Choose a reason for hiding this comment

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

I think a better test is to check that the result of globToRegex really does work properly. ie does it return something that matches bar and not bars or abar and matches food and not flood.

@n8pease n8pease merged commit 9d652b4 into master Sep 2, 2020
@timj timj deleted the tickets/DM-25760 branch February 16, 2024 17:17
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.

None yet

2 participants