Skip to content

Commit

Permalink
Merge pull request #5430 from eukaryo/v4pr-deprecated-study-vs-studyname
Browse files Browse the repository at this point in the history
Drop `--study` in `cli.py`
  • Loading branch information
not522 committed May 7, 2024
2 parents f290095 + 2a74606 commit bca90dd
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions optuna/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,9 @@ class _StudySetUserAttribute(_BaseCommand):
"""Set a user attribute to a study."""

def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument(
"--study", default=None, help="This argument is deprecated. Use --study-name instead."
)
parser.add_argument(
"--study-name",
default=None,
required=True,
help="The name of the study to set the user attribute to.",
)
parser.add_argument("--key", "-k", required=True, help="Key of the user attribute.")
Expand All @@ -376,19 +373,7 @@ def add_arguments(self, parser: ArgumentParser) -> None:
def take_action(self, parsed_args: Namespace) -> int:
storage = _get_storage(parsed_args.storage, parsed_args.storage_class)

if parsed_args.study and parsed_args.study_name:
raise ValueError(
"Both `--study-name` and the deprecated `--study` was specified. "
"Please remove the `--study` flag."
)
elif parsed_args.study:
message = "The use of `--study` is deprecated. Please use `--study-name` instead."
warnings.warn(message, FutureWarning)
study = optuna.load_study(storage=storage, study_name=parsed_args.study)
elif parsed_args.study_name:
study = optuna.load_study(storage=storage, study_name=parsed_args.study_name)
else:
raise ValueError("Missing study name. Please use `--study-name`.")
study = optuna.load_study(storage=storage, study_name=parsed_args.study_name)

study.set_user_attr(parsed_args.key, parsed_args.value)

Expand Down

0 comments on commit bca90dd

Please sign in to comment.