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-25196 make query-collections and query-dataset-types butler commands #304

Merged
merged 11 commits into from Jun 6, 2020

Conversation

n8pease
Copy link
Contributor

@n8pease n8pease commented Jun 4, 2020

No description provided.

@n8pease
Copy link
Contributor Author

n8pease commented Jun 4, 2020

I've asked in Slack if query-dataset-types --components option is useful without expression. I'll drop the commit "remove components arg from queryDatasetTypes" if Jim (or anyone) says that parameter is still useful.

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 good. Some minor comments only.

def makeCollectionType(self, context, param, value):
if value is None:
return value
value = value.upper()
Copy link
Member

Choose a reason for hiding this comment

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

Click doesn't normalize case on choice options if you say case_sensitive=False ? Does click do minimum matching so that "chain" would work as well as "chained"?


Returns
-------
collections : [`str`, [`str`]]
Copy link
Member

Choose a reason for hiding this comment

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

I'm trying to parse this return type indicator. Is that how we show that a dict is returned?



def queryDatasetTypes(repo):
"""Get the dataset types in a repository.
Copy link
Member

Choose a reason for hiding this comment

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

Please add Returns section.

"""
butler = Butler(repo)
datasetTypes = butler.registry.queryDatasetTypes()
return {'dataset-types': [datasetType.name for datasetType in datasetTypes]}
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 I prefer "datasetTypes" as the key.

expected = {"collections": ["ingest/run", "ingest"]}
runner = click.testing.CliRunner()
with runner.isolated_filesystem():
_ = Butler.makeRepo("here")
Copy link
Member

Choose a reason for hiding this comment

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

Why are you assigning anyything at all to the return value?

The more common idiom though is for the return value from Butler.makeRepo and pass it to the first argument of the Butler constructor in the next line.

runner = click.testing.CliRunner()
with runner.isolated_filesystem():
_ = Butler.makeRepo("here")
_ = Butler("here", run=run, tags=[tag], collections=[tag])
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment here to say that the purpose of this call is to create some collections?

def testGetCollections(self):
run = "ingest/run"
tag = "ingest"
expected = {"collections": ["ingest/run", "ingest"]}
Copy link
Member

Choose a reason for hiding this comment

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

Don't repeat yourself here. use [run, tag] here

runner = click.testing.CliRunner()
with runner.isolated_filesystem():
Butler.makeRepo("here")
butler = Butler("here", writeable=True)
Copy link
Member

Choose a reason for hiding this comment

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

Again I have a slight preference for the return value of makeRepo being used here.

@n8pease n8pease merged commit 10c5662 into master Jun 6, 2020
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