diff --git a/projects/rocprofiler-compute/src/utils/specs.py b/projects/rocprofiler-compute/src/utils/specs.py index 5f0eaad193..197b0ceb17 100644 --- a/projects/rocprofiler-compute/src/utils/specs.py +++ b/projects/rocprofiler-compute/src/utils/specs.py @@ -69,6 +69,14 @@ def detect_arch(_rocminfo): else: return (gpu_arch, idx1) +# Custom decorator to mimic the behavior of kw_only found in Python 3.10 +def kw_only(cls): + def __init__(self, *args, **kwargs): + for name, value in kwargs.items(): + setattr(self, name, value) + cls.__init__ = __init__ + return cls + def generate_machine_specs(args, sysinfo: dict = None): if not sysinfo is None: @@ -172,7 +180,8 @@ def generate_machine_specs(args, sysinfo: dict = None): return specs -@dataclass(kw_only=True) +@kw_only +@dataclass class MachineSpecs: ########################################## ## A. Workload / Spec info