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

Fixes vara-cs view --commit-hash option conversion #871

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion varats/varats/tools/driver_casestudy.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
TypedChoice,
EnumChoice,
create_multi_case_study_choice,
ShortCommitHashParamType,
)
from varats.utils.git_util import (
get_initial_commit,
Expand Down Expand Up @@ -555,7 +556,11 @@ def __casestudy_package(
@click.option(
"--project", required=True, help="Project to view result files for."
)
@click.option("--commit-hash", help="Commit hash to view result files for.")
@click.option(
"--commit-hash",
type=ShortCommitHashParamType(),
help="Commit hash to view result files for."
)
@click.option(
"--newest-only",
is_flag=True,
Expand Down
18 changes: 17 additions & 1 deletion varats/varats/ts_utils/click_param_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import click
from benchbuild.experiment import ExperimentRegistry
from click import ParamType

from varats.data.discover_reports import initialize_reports
from varats.experiments.discover_experiments import initialize_experiments
Expand All @@ -17,6 +18,7 @@
)
from varats.ts_utils.cli_util import CLIOptionTy, convert_value, make_cli_option
from varats.utils.exceptions import ConfigurationLookupError
from varats.utils.git_util import ShortCommitHash

if tp.TYPE_CHECKING:
# pylint: disable=unused-import
Expand Down Expand Up @@ -184,8 +186,22 @@ def create_multi_experiment_type_choice(
return TypedMultiChoice(value_dict)


class ShortCommitHashParamType(ParamType):
"""Click parameter type for commit hashes."""
name = "ShortCommitHash"

def convert(
self, value: tp.Union[str, ShortCommitHash],
param: tp.Optional[click.Parameter], ctx: tp.Optional[click.Context]
) -> ShortCommitHash:
if isinstance(value, ShortCommitHash):
return value

return ShortCommitHash(value)


# ------------------------------------------------------------------------------
# Predefined CLI Options
# Predefined plot/table CLI Options
# ------------------------------------------------------------------------------

REQUIRE_CASE_STUDY: CLIOptionTy = convert_value(
Expand Down
Loading