Skip to content

Commit

Permalink
Merge branch 'tickets/DM-34261' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
n8pease committed Apr 1, 2022
2 parents 1114478 + 0bd8a5f commit 29afa99
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 36 deletions.
1 change: 1 addition & 0 deletions doc/changes/DM-34261.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The `click.Path` API should mostly be used with keyword arguments, change from ordered arguments to keyword arguments when calling it.
38 changes: 2 additions & 36 deletions python/lsst/ctrl/mpexec/cli/opt/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,6 @@
import click
from lsst.daf.butler.cli.utils import MWOptionDecorator, MWPath, split_commas, unwrap


def _split_commas_int(context, param, values):
"""Special callback that handles comma-separated list of integers.
Parameters
----------
context : `click.Context` or `None`
The current execution context.
param : `click.core.Option` or `None`
The parameter being handled.
values : `list` [ `str` ]
All the values passed for this option. Strings may contain commas,
which will be treated as delimiters for separate values.
Returns
-------
numbers : `tuple` [ `int` ]
The passed in values separated by commas and combined into a single
list.
"""

def _to_int(value):
"""Convert string to integer, handle errors."""
try:
return int(value)
except ValueError:
raise click.BadParameter(f"'{value}' is not a valid integer", context, param)

values = split_commas(context, param, values)
if values is None:
return values
return tuple(_to_int(value) for value in values)


butler_config_option = MWOptionDecorator(
"-b", "--butler-config", help="Location of the gen3 butler/registry config file."
)
Expand Down Expand Up @@ -201,7 +167,7 @@ def _to_int(value):
('unstore') or by removing them and the RUN completely
('purge'). Requires --replace-run."""
),
type=click.Choice(("unstore", "purge"), case_sensitive=False),
type=click.Choice(choices=("unstore", "purge"), case_sensitive=False),
)


Expand Down Expand Up @@ -401,7 +367,7 @@ def _to_int(value):
start_method_option = MWOptionDecorator(
"--start-method",
default=None,
type=click.Choice(["spawn", "fork", "forkserver"]),
type=click.Choice(choices=["spawn", "fork", "forkserver"]),
help="Multiprocessing start method, default is platform-specific.",
)

Expand Down

0 comments on commit 29afa99

Please sign in to comment.