Skip to content

Commit

Permalink
Fix issue with empty CLI stats headers
Browse files Browse the repository at this point in the history
The --stats-headers option was set to empty string by default,
which created an empty stats header record due to missing
if statement.
  • Loading branch information
JiriPavela committed Oct 6, 2024
1 parent adc5387 commit 3ef69ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion perun/cli_groups/import_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"--stats-headers",
"-t",
nargs=1,
default="",
default=None,
metavar="[STAT_HEADER+]",
help="Describes the stats headers associated with imported profiles specified directly in CLI. "
"A stats header has the form of 'NAME[|COMPARISON_TYPE[|UNIT[|AGGREGATE_BY[|DESCRIPTION]]]]'.",
Expand Down
17 changes: 10 additions & 7 deletions perun/profile/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class _PerfProfileSpec:
@vcs_kit.lookup_minor_version
def import_perf_from_record(
import_entries: list[str],
stats_headers: str,
stats_headers: str | None,
minor_version: str,
with_sudo: bool = False,
**kwargs: Any,
Expand Down Expand Up @@ -86,7 +86,7 @@ def import_perf_from_record(
@vcs_kit.lookup_minor_version
def import_perf_from_script(
import_entries: list[str],
stats_headers: str,
stats_headers: str | None,
minor_version: str,
**kwargs: Any,
) -> None:
Expand Down Expand Up @@ -117,7 +117,7 @@ def import_perf_from_script(
@vcs_kit.lookup_minor_version
def import_perf_from_stack(
import_entries: list[str],
stats_headers: str,
stats_headers: str | None,
minor_version: str,
**kwargs: Any,
) -> None:
Expand Down Expand Up @@ -466,7 +466,7 @@ def _parse_metadata_json(metadata_path: Path) -> list[profile.ProfileMetadata]:


def _parse_perf_import_entries(
import_entries: list[str], cli_stats_headers: str
import_entries: list[str], cli_stats_headers: str | None
) -> tuple[list[_PerfProfileSpec], list[profile.ProfileStat]]:
"""Parses perf import entries and stats.
Expand Down Expand Up @@ -494,9 +494,12 @@ def _parse_perf_import_entries(
:return: parsed profiles and stats.
"""
stats = [
profile.ProfileStat.from_string(*stat.split("|")) for stat in cli_stats_headers.split(",")
]
stats = []
if cli_stats_headers is not None:
stats = [
profile.ProfileStat.from_string(*stat.split("|"))
for stat in cli_stats_headers.split(",")
]
cli_stats_len = len(stats)

import_dir = Path(config.lookup_key_recursively("import.dir", os.getcwd()))
Expand Down

0 comments on commit 3ef69ce

Please sign in to comment.