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-33619: Add unlink option to butler remove-runs #661

Merged
merged 4 commits into from Mar 17, 2022
Merged

Conversation

n8pease
Copy link
Contributor

@n8pease n8pease commented Mar 15, 2022

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@n8pease n8pease force-pushed the tickets/DM-33619 branch 5 times, most recently from 6936dbe to 6e27018 Compare March 15, 2022 22:12
@codecov
Copy link

codecov bot commented Mar 15, 2022

Codecov Report

Merging #661 (3f61768) into main (bc02ca6) will increase coverage by 0.03%.
The diff coverage is 97.59%.

@@            Coverage Diff             @@
##             main     #661      +/-   ##
==========================================
+ Coverage   83.69%   83.72%   +0.03%     
==========================================
  Files         239      239              
  Lines       30457    30528      +71     
  Branches     5110     5120      +10     
==========================================
+ Hits        25492    25561      +69     
  Misses       3811     3811              
- Partials     1154     1156       +2     
Impacted Files Coverage Δ
python/lsst/daf/butler/cli/cmd/_remove_runs.py 96.55% <92.59%> (-3.45%) ⬇️
python/lsst/daf/butler/cli/utils.py 92.83% <100.00%> (+0.02%) ⬆️
python/lsst/daf/butler/script/__init__.py 100.00% <100.00%> (ø)
python/lsst/daf/butler/script/removeRuns.py 100.00% <100.00%> (ø)
tests/test_cliCmdRemoveRuns.py 97.53% <100.00%> (+2.29%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc02ca6...3f61768. Read the comment docs.

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. Very minor comments.

# and exit.
if any(run.parents for run in result.runs) and not force:
_print_requires_confirmation(result.runs, result.datasets)
sys.exit(1)
Copy link
Member

Choose a reason for hiding this comment

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

Is Click okay with calling sys.exit()? I see there is a click.Context.exit().

@@ -196,6 +196,9 @@ def addArgumentHelp(doc, helpText):
# (Lines after the first blank line will be argument help.)
while len(doclines) > 1 and doclines[1]:
doclines[0] = " ".join((doclines[0], doclines.pop(1).strip()))
# Add standard indent to help text for proper alignment with command
# function documentation:
helpText = " " + helpText
Copy link
Member

Choose a reason for hiding this comment

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

Word wrapping in click does seem harder than it should be...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is partially my fault, for modifying how click.argument help is inserted; click says you should add it yourself in the command function doctoring, but I wanted to reuse the help text along with the argument declaration via the argument decorator. I'm kind of fighting the API. If it's a continuous PITA then probably I should back out what I've done & let the wookie win.

"""Perform the remove step."""
butler = Butler(repo, writeable=True)
butler.removeRuns(runs, unstore=True)
for run in runs:
Copy link
Member

Choose a reason for hiding this comment

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

Should this entire loop be in a transaction in case something goes wrong before the removeRuns happens and you may not want some of the chains to have been modified and some unchanged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that seems like a good idea. I think to do that I put the loop inside a block that begins with with butler.transaction():, and that's all, is that right?

@@ -83,8 +95,25 @@ def test_removeRuns(self):
root = "repo1"
MetricTestRepo(root, configFile=os.path.join(TESTDIR, "config/basic/butler.yaml"))

# Execute cmd but say no, check for expected outputs.
# add the run to a CHAINED collection
Copy link
Member

Choose a reason for hiding this comment

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

As a general point comments should be sentences so this should be:

# Add the run to a CHAINED collection.

if run.parents:
print(unlinkMsg.format(run=run.name, parents=", ".join(_quoted(run.parents))))
else:
print(run.name)
Copy link
Member

Choose a reason for hiding this comment

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

Does the coverage report indicating that this line never runs mean that we aren't testing the command without parents?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I changed the tests for CHAINED collections, and didn't consider this case. Will fix.

# Execute cmd with --force
result = self.runner.invoke(
butler.cli, ["remove-runs", root, "ingest*", "--no-confirm", "--force"]
)
Copy link
Member

Choose a reason for hiding this comment

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

Can we also run butler query-collections for the run to show it has disappeared?

When inserting argument help, it needs to have the same indent as
the help text around it. This adds the standard 4 spaces.
@n8pease n8pease merged commit 73c254b into main Mar 17, 2022
@n8pease n8pease deleted the tickets/DM-33619 branch March 17, 2022 16:52
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