Skip to content

Commit

Permalink
feat: add reserved codes in ADEME database
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienbanse committed Aug 27, 2024
1 parent 6ff67b8 commit b09553b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions ecologits/electricity_mix_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dataclasses import dataclass
from typing import Optional

reserved_codes = ["WOR", "EEE", "SCG"]

@dataclass
class ElectricityMix:
Expand Down
4 changes: 2 additions & 2 deletions ecologits/tracers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pycountry import countries

from ecologits.electricity_mix_repository import electricity_mixes
from ecologits.electricity_mix_repository import electricity_mixes, reserved_codes
from ecologits.impacts.llm import compute_llm_impacts
from ecologits.impacts.modeling import Impacts, Range
from ecologits.model_repository import models
Expand Down Expand Up @@ -32,7 +32,7 @@ def llm_impacts(
Returns:
The impacts of an LLM generation request.
"""
if countries.get(alpha_3=electricity_mix_zone) is None:
if countries.get(alpha_3=electricity_mix_zone) is None and electricity_mix_zone not in reserved_codes:
# TODO: Replace with proper logging
print(f"`{electricity_mix_zone}` is currently not a valid ISO 3166-1 alpha-3 code")
return None
Expand Down

0 comments on commit b09553b

Please sign in to comment.