mlco2 / codecarbon

Track emissions from Compute and recommend ways to reduce their impact on the environment.
https://mlco2.github.io/codecarbon
MIT License
1.18k stars 178 forks source link

Create VSCode CodeCarbon extension #436

Closed inimaz closed 5 months ago

inimaz commented 1 year ago

Description

It would be great to have an extension in the VSCode IDE to start/stop measuring with a button/command.

There is a tutorial on how to implement this--> https://code.visualstudio.com/api/advanced-topics/python-extension-template

inimaz commented 1 year ago

I am giving it a try here -->https://github.com/inimaz/vscode-extension-codecarbon. I will post here as soon as I have something working.

inimaz commented 1 year ago

Evolution for now. Maybe a VSCode extension is too much overkill? For now what I managed to do is a task in vscode that starts codecarbon when you open vscode.

How to

Create a file in your .vscode/tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "codecarbon",
      "type": "shell",
      "isBackground": true,
      "command": "${PATH_TO_YOUR_PYTHON_BIN}/codecarbon monitor --no-api",
      "presentation": {
        "close": false,
        "panel": "dedicated",
        "showReuseMessage": true
      },
      "runOptions": {
        "runOn": "folderOpen"
      }
    }
  ]
}

this will add an entry with your emissions to your emissions.csv file every time you stop the terminal or close vscode.

inimaz commented 5 months ago

First version early release is public and available to be installed ==> https://marketplace.visualstudio.com/items?itemName=CodeCarbon.codecarbon

SaboniAmine commented 5 months ago

Should we close this then @inimaz ?