Skip to content

Commit

Permalink
Merge pull request #260 from JiriPavela/fix-empty-cli-stats
Browse files Browse the repository at this point in the history
Fix empty cli stats record
  • Loading branch information
JiriPavela authored Oct 6, 2024
2 parents 3a24630 + c029796 commit 2ec3930
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 2ec3930

Please sign in to comment.