From 1f20a3eb86b3e6c3ea84c2a7c51927d9f8fd47ce Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 3 Jul 2024 09:10:40 -0500 Subject: [PATCH] feat(cli): remove --file_key and --prepend-channels arguments (#100) --- src/rapids_dependency_file_generator/_cli.py | 30 ------- tests/test_cli.py | 86 -------------------- 2 files changed, 116 deletions(-) diff --git a/src/rapids_dependency_file_generator/_cli.py b/src/rapids_dependency_file_generator/_cli.py index c8babaae..a79c99a2 100644 --- a/src/rapids_dependency_file_generator/_cli.py +++ b/src/rapids_dependency_file_generator/_cli.py @@ -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 @@ -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.", @@ -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): @@ -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}") diff --git a/tests/test_cli.py b/tests/test_cli.py index 923a7ff7..f41091de 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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", - ] - )