asitop icon indicating copy to clipboard operation
asitop copied to clipboard

KeyError: 'combined_power' on MacOS 12.4/12.6.3 on M1 Max

Open emidln-imc opened this issue 2 years ago • 4 comments

Hardware Overview

  Model Name:	MacBook Pro
  Model Identifier:	MacBookPro18,2
  Chip:	Apple M1 Max
  Total Number of Cores:	10 (8 performance and 2 efficiency)
  Memory:	64 GB
  System Firmware Version:	7459.121.3
  OS Loader Version:	7459.121.3

Exception

$ sudo asitop 

ASITOP - Performance monitoring CLI tool for Apple Silicon
You can update ASITOP by running `pip install asitop --upgrade`
Get help at `https://github.com/tlkh/asitop`
P.S. You are recommended to run ASITOP with `sudo asitop`


[1/3] Loading ASITOP



[2/3] Starting powermetrics process


[3/3] Waiting for first reading...

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/asitop/utils.py", line 18, in parse_powermetrics
    cpu_metrics_dict = parse_cpu_metrics(powermetrics_parse)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/asitop/parsers.py", line 133, in parse_cpu_metrics
    cpu_metric_dict["package_W"] = cpu_metrics["combined_power"]/1000
                                   ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'combined_power'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/bin/asitop", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/asitop/asitop.py", line 159, in main
    ready = get_reading()
            ^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/asitop/asitop.py", line 156, in get_reading
    ready = parse_powermetrics(timecode=timecode)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/asitop/utils.py", line 29, in parse_powermetrics
    cpu_metrics_dict = parse_cpu_metrics(powermetrics_parse)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/asitop/parsers.py", line 133, in parse_cpu_metrics
    cpu_metric_dict["package_W"] = cpu_metrics["combined_power"]/1000
                                   ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'combined_power'

Python version (built by brew install [email protected])

python3.11 --version
Python 3.11.1

asitop version 0.0.23

pip3.11 freeze  | grep asitop
asitop==0.0.23

emidln-imc avatar Feb 01 '23 03:02 emidln-imc

I updated to the latest MacOs 12.x patch release I have access to, 12.6.3, and I still see the same issue.

emidln-imc avatar Feb 01 '23 14:02 emidln-imc

(For someone googled this issue) If you're in a hurry as an end-user you can install 0.0.21 that does not have this code:

pip install asitop==0.0.21

zenyr avatar Feb 02 '23 07:02 zenyr

I also meet this problem on 12.6.3, is there anyone fix it?

mikez226 avatar Feb 16 '23 06:02 mikez226

The key was recently changed to combined_power for compatibility with Ventura, but this broke compatibility with Monterey, where the key was originally package_energy...

There is a PR for fixing this at #52, hopefully it gets merged soon?

dehydratedpotato avatar Feb 16 '23 15:02 dehydratedpotato