Skip to content

Commit

Permalink
Merge pull request #21 from SimeonEhrig/bashiValidateRemoveMissingPar…
Browse files Browse the repository at this point in the history
…ameter

bashi-validate: remove required parameter
  • Loading branch information
SimeonEhrig authored Mar 18, 2024
2 parents 1d5c80b + 79dc7c3 commit 4d25474
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 53 deletions.
13 changes: 2 additions & 11 deletions bashi/filter_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,9 @@
which rule.
"""

from typing import Optional, IO, List
from typing import Optional, IO
from typeguard import typechecked
from bashi.types import Parameter, ParameterValueTuple


def get_required_parameters() -> List[Parameter]:
"""Return list of parameters which will be checked in the filter.
Returns:
List[Parameter]: list of checked parameters
"""
return []
from bashi.types import ParameterValueTuple


@typechecked
Expand Down
13 changes: 2 additions & 11 deletions bashi/filter_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,18 @@
which rule.
"""

from typing import Optional, IO, List
from typing import Optional, IO
import packaging.version as pkv
from typeguard import typechecked
from bashi.globals import * # pylint: disable=wildcard-import,unused-wildcard-import
from bashi.types import Parameter, ParameterValueTuple
from bashi.types import ParameterValueTuple
from bashi.versions import NVCC_GCC_MAX_VERSION, NVCC_CLANG_MAX_VERSION
from bashi.utils import reason

# uncomment me for debugging
# from bashi.utils import print_row_nice


def get_required_parameters() -> List[Parameter]:
"""Return list of parameters which will be checked in the filter.
Returns:
List[Parameter]: list of checked parameters
"""
return [HOST_COMPILER, DEVICE_COMPILER]


@typechecked
def compiler_filter_typechecked(
row: ParameterValueTuple,
Expand Down
13 changes: 2 additions & 11 deletions bashi/filter_software_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,9 @@
which rule.
"""

from typing import Optional, IO, List
from typing import Optional, IO
from typeguard import typechecked
from bashi.types import Parameter, ParameterValueTuple


def get_required_parameters() -> List[Parameter]:
"""Return list of parameters which will be checked in the filter.
Returns:
List[Parameter]: list of checked parameters
"""
return []
from bashi.types import ParameterValueTuple


@typechecked
Expand Down
20 changes: 0 additions & 20 deletions bashi/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ def get_args() -> Namespace:
def check_single_filter(
filter_func: Callable[[ParameterValueTuple, Optional[IO[str]]], bool],
row: ParameterValueTuple,
required_parameter: List[str],
) -> bool:
"""Check if row passes a filter function.
Expand All @@ -194,8 +193,6 @@ def check_single_filter(
Returns:
bool: True if the row passes the filter.
"""
missing_parameters = ""

# get name of the filter for command line output.
filter_name: str = filter_func.__name__

Expand All @@ -204,20 +201,6 @@ def check_single_filter(
if filter_name.endswith("_typechecked"):
filter_name = filter_name[: -len("_typechecked")]

# check if all required parameter are available
for req_name in required_parameter:
if req_name not in row:
missing_parameters += " " + req_name

if missing_parameters:
print(
cs(
f"skipped {filter_name}(), missing parameters ->" + missing_parameters,
"Yellow",
)
)
return False

msg = io.StringIO()

if filter_func(row, msg):
Expand Down Expand Up @@ -245,21 +228,18 @@ def check_filter_chain(row: ParameterValueTuple) -> bool:
check_single_filter(
bashi.filter_compiler.compiler_filter,
row,
bashi.filter_compiler.get_required_parameters(),
)
)
all_true += int(
check_single_filter(
bashi.filter_backend.backend_filter_typechecked,
row,
bashi.filter_backend.get_required_parameters(),
)
)
all_true += int(
check_single_filter(
bashi.filter_software_dependency.software_dependency_filter_typechecked,
row,
bashi.filter_software_dependency.get_required_parameters(),
)
)

Expand Down

0 comments on commit 4d25474

Please sign in to comment.