Skip to content

Multi-value filter #19

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

Merged
merged 8 commits into from
Mar 3, 2023
Merged
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
31 changes: 19 additions & 12 deletions src/parse_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import List, Optional

from src.metrics import Metrics
from src.utils import parse_config_args
from src.utils import parse_config_args, parse_config_arg


def get_arg_parser() -> ArgumentParser:
Expand All @@ -25,9 +25,9 @@ def get_arg_parser() -> ArgumentParser:

DEFAULT_COLUMNS = (
"Setting",
Metrics.BATCH_SIZE,
Metrics.INPUT_LENGTH,
Metrics.TOKENS_SAMPLE,
Metrics.BATCH_SIZE,
Metrics.THROUGHPUT_E2E,
Metrics.LATENCY_E2E,
)
Expand All @@ -54,19 +54,19 @@ def read_data(input_file: Path):
return data


def parse_key(key: Optional[str]) -> Optional[str]:
if key is None:
return key
return getattr(Metrics, key.upper(), key)


def make_table(data, cols):
from markdownTable import markdownTable

data = [Metrics.format_metrics({col: x[col] for col in cols}) for x in data]
return markdownTable(data).getMarkdown()


def parse_key(key: Optional[str]) -> Optional[str]:
if key is None:
return key
return getattr(Metrics, key.upper(), key)


def make_compare_table(data, cols, compare_value, compare_col):
from markdownTable import markdownTable

Expand Down Expand Up @@ -104,13 +104,20 @@ def make_compare_table(data, cols, compare_value, compare_col):
def filter_data(data, filters):
if filters is None:
return data
filters = parse_config_args(filters)
filters = {parse_key(key): value for key, value in filters.items()}

parsed_filters = {}
for filter in filters:
key, value = parse_config_arg(filter)
key = parse_key(key)
if key not in parsed_filters:
parsed_filters[key] = []
parsed_filters[key].append(value)

filtered_data = []
for x in data:
filter = True
for key, value in filters.items():
filter = filter and x[key] == value
for key, value in parsed_filters.items():
filter = filter and x[key] in value
if filter:
filtered_data.append(x)
return filtered_data
Expand Down