Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

get_cloud_geo_region() returns NaN instead of the city for GCP regions with no state

オープン 初心者向け
#1,456 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
86/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
pandas, python
領域
backend, databases

調査の方向性

codecarbon/core/emissions.py の get_cloud_geo_region() から始め、data/cloud/impact.csv から読み込まれる state の値がどのように処理されるかを調べてください。GCP リージョン asia-east1 で再現し、その後、state のないリージョンのテストを追加してください。都市が返され、そのリージョンが排出量の出力で NaN を生成しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Problem

Emissions.get_cloud_geo_region() (codecarbon/core/emissions.py) falls back to city only when state is None:

state = selected["state"].item()
if state is not None:
    return state

impact.csv is read with pandas, so an empty state cell is NaN, not None. The check passes and NaN is returned. 30 of the 40 GCP regions in data/cloud/impact.csv have no state (e.g. asia-east1, africa-south1), so the city is never used.

Reproduction

from codecarbon import OfflineEmissionsTracker

tracker = OfflineEmissionsTracker(cloud_provider="gcp", cloud_region="asia-east1")
tracker.start()
data = tracker._prepare_emissions_data()
tracker.stop()
print(repr(data.region))  # nan, expected 'Changhua County'

Impact

  • region is empty in emissions.csv
  • HTTPOutput fails: requests raises InvalidJSONError: Out of range float values are not JSON compliant: nan
  • LoggerOutput logs invalid JSON ("region": NaN)

Proposed fix

Check for a real string instead of None, e.g. if isinstance(state, str):, and add a test with a region that has no state. Happy to open a PR.


Proposed fix

Check for a real string instead of None, e.g. if isinstance(state, str):, and add a test with a region that has no state. Happy to open a PR.


主要言語
Python
スター
1.9k
フォーク
341
平均マージ
3日 51分
マージ済み PR(30日)
16

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

mlco2/codecarbon のほかの issue

mlco2/codecarbon の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。