[MyPy][BugFix] Check profiler is assigned before calling start() on it (#35505)

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Martin Hickey
2026-03-02 13:23:42 +00:00
committed by GitHub
co-authored by Harry Mellor
parent de7dd634b9
commit 87c98b0236
+8 -7
View File
@@ -788,13 +788,14 @@ class Worker(WorkerBase):
self.profiler = CudaProfilerWrapper(self.profiler_config) self.profiler = CudaProfilerWrapper(self.profiler_config)
logger.debug("Starting CUDA profiler") logger.debug("Starting CUDA profiler")
else: else:
logger.warning("Unrecognized profiler: %s", profiler_type) # Config validation should prevent this code being reached
return raise ValueError(
self.profiler.start() f"Invalid profiler value of {self.profiler_config.profiler}"
else: )
# Profiler already initialized. Restart profiling but keep
# the original trace name from the first initialization. # If profiler already initialized, restart profiling but keep
self.profiler.start() # the original trace name from the first initialization.
self.profiler.start()
else: else:
if self.profiler is None: if self.profiler is None:
logger.warning("Profiler was not started, nothing to stop.") logger.warning("Profiler was not started, nothing to stop.")