Skip to content

Commit

Permalink
feat(cli): remove --file_key and --prepend-channels arguments (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb authored Jul 3, 2024
1 parent febeb6b commit 1f20a3e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 116 deletions.
30 changes: 0 additions & 30 deletions src/rapids_dependency_file_generator/_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import argparse
import os
import warnings

from ._config import Output, load_config_from_file
from ._constants import default_dependency_file_path
Expand Down Expand Up @@ -38,11 +37,6 @@ def validate_args(argv):
"--file-key",
help="The file key from `dependencies.yaml` to generate.",
)
codependent_args.add_argument(
"--file_key",
dest="file_key_deprecated",
help="The file key from `dependencies.yaml` to generate. DEPRECATED: Use --file-key instead.",
)
codependent_args.add_argument(
"--output",
help="The output file type to generate.",
Expand Down Expand Up @@ -74,26 +68,9 @@ def validate_args(argv):
f"{Output.CONDA.value} or no --output. May be specified multiple times."
),
)
parser.add_argument(
"--prepend-channels",
dest="prepend_channels_deprecated",
help=(
"A string representing a list of conda channels to prepend to the list of "
"channels. Channels should be separated by a semicolon, such as "
'`--prepend-channels "my_channel;my_other_channel"`. This option is '
f"only valid with --output {Output.CONDA.value} or no --output. "
"DEPRECATED: Use --prepend-channel instead."
),
)

args = parser.parse_args(argv)

if args.file_key_deprecated:
if args.file_key:
raise ValueError("The --file_key (deprecated) and --file-key arguments cannot be specified together.")
warnings.warn("The use of --file_key is deprecated. Use -f or --file-key instead.")
args.file_key = args.file_key_deprecated

dependent_arg_keys = ["file_key", "output", "matrix"]
dependent_arg_values = [getattr(args, key) is None for key in dependent_arg_keys]
if any(dependent_arg_values) and not all(dependent_arg_values):
Expand All @@ -102,13 +79,6 @@ def validate_args(argv):
+ "".join([f"\n {x}" for x in ["--file-key", "--output", "--matrix"]])
)

if args.prepend_channels_deprecated:
if args.prepend_channels:
raise ValueError(
"The --prepend-channels (deprecated) and --prepend-channel arguments cannot be specified together."
)
warnings.warn("The use of --prepend-channels is deprecated. Use --prepend-channel instead.")
args.prepend_channels = args.prepend_channels_deprecated.split(";")
if args.prepend_channels and args.output and args.output != Output.CONDA.value:
raise ValueError(f"--prepend-channel is only valid with --output {Output.CONDA.value}")

Expand Down
86 changes: 0 additions & 86 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,89 +106,3 @@ def test_validate_args():
"my_other_channel",
]
)

# Valid but deprecated
with pytest.warns(
Warning,
match=r"^The use of --file_key is deprecated\. Use -f or --file-key instead\.$",
):
assert (
validate_args(
[
"--output",
"conda",
"--matrix",
"cuda=11.5;arch=x86_64",
"--file_key",
"all",
"--prepend-channel",
"my_channel",
"--prepend-channel",
"my_other_channel",
]
).file_key
== "all"
)

# Invalid
with pytest.raises(
ValueError,
match=r"^The --file_key \(deprecated\) and --file-key arguments cannot be specified together\.$",
):
validate_args(
[
"--output",
"conda",
"--matrix",
"cuda=11.5;arch=x86_64",
"--file-key",
"all",
"--file_key",
"deprecated",
"--prepend-channel",
"my_channel",
"--prepend-channel",
"my_other_channel",
]
)

# Valid but deprecated
with pytest.warns(
Warning,
match=r"^The use of --prepend-channels is deprecated\. Use --prepend-channel instead\.$",
):
assert validate_args(
[
"--output",
"conda",
"--matrix",
"cuda=11.5;arch=x86_64",
"--file-key",
"all",
"--prepend-channels",
"my_channel;my_other_channel",
]
).prepend_channels == [
"my_channel",
"my_other_channel",
]

# Invalid
with pytest.raises(
ValueError,
match=r"^The --prepend-channels \(deprecated\) and --prepend-channel arguments cannot be specified together\.$",
):
validate_args(
[
"--output",
"conda",
"--matrix",
"cuda=11.5;arch=x86_64",
"--file-key",
"all",
"--prepend-channels",
"my_channel;my_other_channel",
"--prepend-channel",
"other_channel_2",
]
)

0 comments on commit 1f20a3e

Please sign in to comment.