import platform
from pathlib import Path
from typing import List
from deprecated import deprecated
from pydantic_settings import BaseSettings, SettingsConfigDict
[docs]
class MatrixLabels(BaseSettings):
[docs]
lci_node_types: List[str] = [
"process",
"product",
"processwithreferenceproduct",
"multifunctional",
]
[docs]
other_node_types: List[str] = []
[docs]
process_node_types: List[str] = ["process", "processwithreferenceproduct"]
[docs]
product_node_types: List[str] = ["product"]
[docs]
process_node_default: str = "process"
[docs]
multifunctional_node_default: str = "multifunctional"
[docs]
chimaera_node_default: str = "processwithreferenceproduct"
[docs]
product_node_default: str = "product"
[docs]
biosphere_node_default: str = "emission"
[docs]
biosphere_edge_types: List[str] = ["biosphere"]
[docs]
technosphere_negative_edge_types: List[str] = [
"technosphere",
"generic consumption",
]
[docs]
technosphere_positive_edge_types: List[str] = [
"production",
"generic production",
"substitution",
]
# You should normally use `technosphere_positive_edge_types`, as it includes substitution
[docs]
substitution_edge_types: List[str] = ["substitution"]
[docs]
other_edge_types: List[str] = []
[docs]
production_edge_default: str = "production"
[docs]
consumption_edge_default: str = "technosphere"
[docs]
biosphere_edge_default: str = "biosphere"
[docs]
substitution_edge_default: str = "substitution"
@property
[docs]
def implicit_production_allowed_node_types(self):
return [self.chimaera_node_default]
@property
[docs]
def lci_edge_types(self) -> List[str]:
return sorted(
set(
self.biosphere_edge_types
+ self.technosphere_negative_edge_types
+ self.technosphere_positive_edge_types
+ self.substitution_edge_types
)
)
@property
[docs]
def edge_types(self) -> List[str]:
return sorted(set(self.lci_edge_types + self.other_edge_types))
@property
[docs]
def node_types(self) -> List[str]:
return sorted(set(self.lci_node_types + self.other_node_types))
[docs]
model_config = SettingsConfigDict(
env_file="brightway-matrix-configuration.env",
env_prefix="dont_pick_up_random_env_vars_a1b2c3d4e5",
)
[docs]
def reload(self, fp: Path) -> None:
"""Load new `.env` file and overwrite settings"""
self.model_config.update(env_file=fp)
[docs]
class TypoSettings(BaseSettings):
[docs]
node_types: List[str] = [
"economic",
"emission",
"inventory indicator",
"multifunctional",
"natural resource",
"process",
"processwithreferenceproduct",
"product",
]
[docs]
edge_types: List[str] = [
"biosphere",
"generic consumption",
"generic production",
"production",
"substitution",
"technosphere",
]
[docs]
node_keys: List[str] = [
"CAS number",
"activity",
"activity type",
"authors",
"categories",
"classifications",
"code",
"comment",
"created",
"database",
"exchanges",
"filename",
"flow",
"id",
"location",
"modified",
"name",
"parameters",
"production amount",
"reference product",
"synonyms",
"tags",
"type",
"unit",
]
[docs]
edge_keys: List[str] = [
"shape",
"temporal_distribution",
"activity",
"amount",
"classifications",
"code",
"comment",
"flow",
"input",
"loc",
"maximum",
"minimum",
"name",
"output",
"pedigree",
"production volume",
"properties",
"scale without pedigree",
"scale",
"type",
"uncertainty type",
"uncertainty_type",
"unit",
]
[docs]
model_config = SettingsConfigDict(
env_file="brightway-typo-configuration.env",
env_prefix="dont_pick_up_random_env_vars_a1b2c3d4e5",
)
[docs]
class Config(BaseSettings):
[docs]
sqlite3_databases: list = []
[docs]
_windows: bool = platform.system() == "Windows"
[docs]
model_config = SettingsConfigDict(
env_file="brightway-configuration.env",
extra="allow",
env_prefix="dont_pick_up_random_env_vars_a1b2c3d4e5",
)
@property
[docs]
def biosphere(self):
"""Get name for ``biosphere`` database from user preferences.
Default name is ``biosphere3``; change this by changing ``config.p["biosphere_database"]``.
"""
return self.p.get("biosphere_database", "biosphere3")
@property
[docs]
def global_location(self):
"""Get name for global location from user preferences.
Default name is ``GLO``; change this by changing ``config.p["global_location"]``.
"""
return self.p.get("global_location", "GLO")
[docs]
labels = MatrixLabels()
[docs]
typo_settings = TypoSettings()