From 2b7006d69681c6a9310a10697e2fa72e51913de3 Mon Sep 17 00:00:00 2001 From: Roi Agai Date: Mon, 14 Oct 2024 12:26:58 +0300 Subject: [PATCH] action='extend' --- gprofiler/gprofiler_types.py | 4 ++-- gprofiler/profilers/python.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gprofiler/gprofiler_types.py b/gprofiler/gprofiler_types.py index 22719699d..410074cb0 100644 --- a/gprofiler/gprofiler_types.py +++ b/gprofiler/gprofiler_types.py @@ -89,12 +89,12 @@ def nonnegative_integer(value_str: str) -> int: def integers_list(value_str: str) -> List[int]: try: - pids = [int(pid) for pid in value_str.split(",")] + values = [int(value) for value in value_str.split(",")] except ValueError: raise configargparse.ArgumentTypeError( "Integer list should be a single integer, or comma separated list of integers f.e. 13,452,2388" ) - return pids + return values def integer_range(min_range: int, max_range: int) -> Callable[[str], int]: diff --git a/gprofiler/profilers/python.py b/gprofiler/profilers/python.py index dd0a0de31..b4ff54e8e 100644 --- a/gprofiler/profilers/python.py +++ b/gprofiler/profilers/python.py @@ -21,6 +21,7 @@ from subprocess import CompletedProcess from typing import Any, Dict, List, Match, Optional, cast +from gprofiler_types import integers_list from granulate_utils.linux.elf import get_elf_id from granulate_utils.linux.ns import get_process_nspid, run_in_ns from granulate_utils.linux.process import ( @@ -345,8 +346,9 @@ def _should_skip_process(self, process: Process) -> bool: ProfilerArgument( name="--python-pyspy-processes", dest="python_pyspy_processes", - nargs="+", - type=int, + action="extend", + default=[], + type=integers_list, help="List of processes (by PID) to profile with py-spy." " This option forces gProfiler to profile given processes with py-spy, even if" " they are not recognized by gProfiler as Python processes."