From 4962f237c28b7814c7e703634c19f06923f65e12 Mon Sep 17 00:00:00 2001 From: vedithal-amd Date: Tue, 23 Sep 2025 17:47:31 -0400 Subject: [PATCH] Fix workload path (#1096) --- projects/rocprofiler-compute/src/argparser.py | 2 +- .../src/rocprof_compute_base.py | 50 ++++++++----------- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/projects/rocprofiler-compute/src/argparser.py b/projects/rocprofiler-compute/src/argparser.py index aeac860606..2445d716f7 100644 --- a/projects/rocprofiler-compute/src/argparser.py +++ b/projects/rocprofiler-compute/src/argparser.py @@ -185,7 +185,7 @@ Examples: metavar="", type=str, dest="subpath", - default="gpu", + default="gpu_model", required=False, help=( "\t\t\tSpecify the type of subpath to save workload: node_name, gpu_model." diff --git a/projects/rocprofiler-compute/src/rocprof_compute_base.py b/projects/rocprofiler-compute/src/rocprof_compute_base.py index d6f3182f63..9609a30c26 100644 --- a/projects/rocprofiler-compute/src/rocprof_compute_base.py +++ b/projects/rocprofiler-compute/src/rocprof_compute_base.py @@ -220,32 +220,6 @@ class RocProfCompute: if getattr(self.__args, "list_available_metrics", False): return - # Add --name to workload path if --path is not given - if self.__args.path == str(Path.cwd() / "workloads"): - if not hasattr(self.__args, "name") or not self.__args.name: - console_error("-n/--name is required") - self.__args.path = str(Path(self.__args.path) / self.__args.name) - # Add node name to workload path - if self.__args.subpath == "node_name": - self.__args.path = str(Path(self.__args.path) / socket.gethostname()) - # Or, add gpu model name to workload path - elif self.__args.subpath == "gpu_model": - if self.__mspec.gpu_model: - self.__args.path = str(Path(self.__args.path) / self.__mspec.gpu_model) - else: - self.__args.path = str(Path(self.__args.path) / self.__args.name) - console_warning( - f"No gpu model found, using default path: {self.__args.path}" - ) - - # Create workload directory if it does not exist - p = Path(self.__args.path) - if not p.exists(): - try: - p.mkdir(parents=True, exist_ok=False) - except FileExistsError: - console_error("Directory already exists.") - def handle_analyze_args(self) -> None: """Handle analyze-specific argument processing""" # Block all filters during spatial-multiplexing @@ -379,12 +353,28 @@ class RocProfCompute: # instantiate desired profiler profiler = self.create_profiler() - - # ----------------------- - # run profiling workflow - # ----------------------- profiler.sanitize() + # Add --name to workload path if --path is not given + if self.__args.path == str(Path.cwd() / "workloads"): + if not hasattr(self.__args, "name") or not self.__args.name: + console_error("-n/--name is required") + self.__args.path = str(Path(self.__args.path) / self.__args.name) + # Add node name to workload path + if self.__args.subpath == "node_name": + self.__args.path = str(Path(self.__args.path) / socket.gethostname()) + # Add gpu model name to workload path + elif self.__args.subpath == "gpu_model": + self.__args.path = str(Path(self.__args.path) / self.__mspec.gpu_model) + + # Create workload directory if it does not exist + p = Path(self.__args.path) + if not p.exists(): + try: + p.mkdir(parents=True, exist_ok=False) + except FileExistsError: + console_error("Directory already exists.") + # enable file-based logging setup_file_handler(self.__args.loglevel, self.__args.path)