Closed cl3m3nt closed 1 week ago
Thanks for reporting this. Can you run the command curl http://169.254.169.254/computeMetadata/v1/instance/?recursive=true&alt=json
because I expect that there is a missing field "zone" in "metadata". It is not related to the update of GCP location data in CodeCarbon. GCP may have modify the output of their API we use to know if we are on GCP and where.
Hi Benoit,
thanks for your reply. After I ran the command from GCP colab entreprise notebook I got the following:
Missing required header: Metadata-Flavor
I appreciate your feedback.
Sorry, from https://stackoverflow.com/questions/62026424/is-it-possible-to-obtain-instance-metadata-for-gcp-on-google-collaboratory it seems to be
curl -v -w "\n" -H "Metadata-Flavor: Google" http://169.254.169.254/computeMetadata/v1/instance/?recursive=true&alt=json
Hi,
here is the output:
GET /computeMetadata/v1/instance/machine-type HTTP/1.1 Host: 169.254.169.254 User-Agent: curl/7.81.0 Accept: / Metadata-Flavor: Google
Sorry, it's curl -v -w "\n" -H "Metadata-Flavor: Google" http://169.254.169.254/computeMetadata/v1/instance/?recursive=true&alt=json
I tested it and I get this from Cloud Shell (I delete un-relevant lines)
{
"cpuPlatform": "Intel Broadwell",
"machineType": "projects/8xxxxx2/machineTypes/e2-standard-4",
"zone": "projects/8xxxx2/zones/europe-west1-b"
}
Hi again,
tx for your reply. Not sure your test makes sense as it's comparing output from one environment being colab enteprise, the other being cloud shell. I appreciate your feedback.
Testing it from gcp colab enteprise notebook:
GET /computeMetadata/v1/instance/?recursive=true HTTP/1.1 Host: 169.254.169.254 User-Agent: curl/7.81.0 Accept: / Metadata-Flavor: Google
Testing from gcp cloud shell, got info like (deleted others lines):
"cpuPlatform": "Intel Broadwell", "description": "", "disks": [ { "deviceName": "boot", "index": 0, "interface": "SCSI", "mode": "READ_WRITE", "type": "PERSISTENT-BALANCED" }, { "deviceName": "home", "index": 1, "interface": "SCSI", "mode": "READ_WRITE", "type": "PERSISTENT" }
So it seems that on Colab Entreprise you get an answer from the GCP API but it's an empty JSON {}
We have to update our GCP detection to handle this case. Thanks for reporting the details.
Hi,
tx for your feedback. Our team is looking forward to getting the fix. Kind regards
Hello, I've opened a PR for that : https://github.com/mlco2/codecarbon/pull/580
Description
Tried to launch codecarbon EmissionTracker on GCP Colab Enterprise. It works correctly on Colab Web with same codecarbon version 2.4.2. It failed on different GCP region trials always with same error message below. As you recently updated GCP location metatadata this might be related. I appreciate your help.
What I Did
@eherra