Index
frequenz.client.common.grid ¤
Grid definitions for the energy market.
Classes¤
frequenz.client.common.grid.BaseDeliveryArea
dataclass
¤
A base class for all delivery areas.
This is the common supertype of both well-formed
DeliveryArea instances and
InvalidDeliveryArea instances that carry
malformed wire data. It cannot be instantiated directly; use one of
its concrete subclasses instead.
Source code in src/frequenz/client/common/grid/_delivery_area.py
Attributes¤
code
instance-attribute
¤
code: str | None
The code representing the unique identifier for the delivery area.
Using None is deprecated
This field is required for a well-formed DeliveryArea, so we are
making this more explicit by deprecating the use of None here. In the
future, | None will be removed so passing None will fail type
checking.
code_type
instance-attribute
¤
code_type: EnergyMarketCodeType | int
Type of code used for identifying the delivery area itself.
This code could be extended in the future, in case an unknown code type is encountered, a plain integer value is used to represent it.
Tip
This is the lower-level accessor; when working with a valid
DeliveryArea, prefer
get_code_type to obtain a known
member or a clear error.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
__post_init__ ¤
Warn if this instance carries invalid data.
Source code in src/frequenz/client/common/grid/_delivery_area.py
frequenz.client.common.grid.DeliveryArea
dataclass
¤
Bases: BaseDeliveryArea
A geographical or administrative region where electricity deliveries occur.
DeliveryArea represents the geographical or administrative region, usually defined and maintained by a Transmission System Operator (TSO), where electricity deliveries for a contract occur.
The concept is important to energy trading as it delineates the agreed-upon delivery location. Delivery areas can have different codes based on the jurisdiction in which they operate.
Construction of invalid instances is deprecated
A well-formed DeliveryArea carries a non-empty code and a
specified code_type. Constructing one with data that
violates this invariant is deprecated, and will raise a
ValueError in a future release.
You can temporarily use the _raise_on_invalid keyword argument to get
the upcoming behavior now (raising instead of deprecation warning).
Use InvalidDeliveryArea if you need to
represent a malformed message.
Jurisdictional Differences
This is typically represented by specific codes according to local jurisdiction.
In Europe, this is represented by an EIC (Energy Identification Code). List of EICs.
Source code in src/frequenz/client/common/grid/_delivery_area.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
Attributes¤
code
instance-attribute
¤
code: str | None
The code representing the unique identifier for the delivery area.
Using None is deprecated
This field is required for a well-formed DeliveryArea, so we are
making this more explicit by deprecating the use of None here. In the
future, | None will be removed so passing None will fail type
checking.
code_type
instance-attribute
¤
code_type: EnergyMarketCodeType | int
Type of code used for identifying the delivery area itself.
This code could be extended in the future, in case an unknown code type is encountered, a plain integer value is used to represent it.
Tip
This is the lower-level accessor; when working with a valid
DeliveryArea, prefer
get_code_type to obtain a known
member or a clear error.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
__post_init__ ¤
__post_init__(_raise_on_invalid: bool) -> None
Warn if this instance carries invalid data.
Source code in src/frequenz/client/common/grid/_delivery_area.py
__str__ ¤
__str__() -> str
Return a human-readable string representation of this instance.
Source code in src/frequenz/client/common/grid/_delivery_area.py
get_code_type ¤
get_code_type() -> EnergyMarketCodeType
Return the code type as a known enum member.
This is the higher-level accessor for the code_type attribute: it
resolves the value to a known EnergyMarketCodeType member or raises a
clear, catchable error.
| RETURNS | DESCRIPTION |
|---|---|
EnergyMarketCodeType
|
The code type, when it is a known |
| RAISES | DESCRIPTION |
|---|---|
UnspecifiedEnumValueError
|
If the code type is unspecified. |
UnrecognizedEnumValueError
|
If the code type is a value not
recognized by this version of the client. The raw value is
available on the exception's |
Source code in src/frequenz/client/common/grid/_delivery_area.py
frequenz.client.common.grid.EnergyMarketCodeType ¤
Bases: Enum
The identification code types used in the energy market.
CodeType specifies the type of identification code used for uniquely identifying various entities such as delivery areas, market participants, and grid components within the energy market.
This enumeration aims to offer compatibility across different jurisdictional standards.
Understanding Code Types
Different regions or countries may have their own standards for uniquely identifying various entities within the energy market. For example, in Europe, the Energy Identification Code (EIC) is commonly used for this purpose.
Extensibility
New code types can be added to this enum to accommodate additional regional standards, enhancing the API's adaptability.
Validation Required
The chosen code type should correspond correctly with the code field in
the relevant message objects, such as DeliveryArea or Counterparty.
Failure to match the code type with the correct code could lead to
processing errors.
Source code in src/frequenz/client/common/grid/_delivery_area.py
Attributes¤
EUROPE_EIC
class-attribute
instance-attribute
¤
European Energy Identification Code Standard.
UNSPECIFIED
class-attribute
instance-attribute
¤
UNSPECIFIED = deprecated_member(
0,
"EnergyMarketCodeType.UNSPECIFIED is deprecated; use the `int` value `0` instead if you really need to check for this low-level value.",
)
Unspecified type. This value is a placeholder and should not be used.
US_NERC
class-attribute
instance-attribute
¤
North American Electric Reliability Corporation identifiers.
frequenz.client.common.grid.InvalidDeliveryArea
dataclass
¤
Bases: BaseDeliveryArea
A delivery area with malformed data received from the wire.
Represents delivery area data that fails the invariants required for a
well-formed DeliveryArea. Callers can inspect the raw
fields to recover partial information.
This class does not enforce any invariants on construction.
Source code in src/frequenz/client/common/grid/_delivery_area.py
Attributes¤
code
instance-attribute
¤
code: str | None
The code representing the unique identifier for the delivery area.
Using None is deprecated
This field is required for a well-formed DeliveryArea, so we are
making this more explicit by deprecating the use of None here. In the
future, | None will be removed so passing None will fail type
checking.
code_type
instance-attribute
¤
code_type: EnergyMarketCodeType | int
Type of code used for identifying the delivery area itself.
This code could be extended in the future, in case an unknown code type is encountered, a plain integer value is used to represent it.
Tip
This is the lower-level accessor; when working with a valid
DeliveryArea, prefer
get_code_type to obtain a known
member or a clear error.
Methods:¤
__new__ ¤
Prevent instantiation of this class.
__post_init__ ¤
Warn if this instance carries invalid data.
Source code in src/frequenz/client/common/grid/_delivery_area.py
__str__ ¤
__str__() -> str
Return a human-readable string representation of this instance.
Source code in src/frequenz/client/common/grid/_delivery_area.py
frequenz.client.common.grid.InvalidDeliveryAreaError ¤
Bases: InvalidAttributeError
Raised when a semantic accessor sees an invalid delivery area.
The offending InvalidDeliveryArea instance
is available as the delivery_area attribute so callers can inspect
the raw wire data.
This is also a ValueError for convenience.
Source code in src/frequenz/client/common/grid/_delivery_area.py
Attributes¤
attr_name
instance-attribute
¤
attr_name: str = attr_name
The name of the attribute that had an invalid value.
delivery_area
instance-attribute
¤
delivery_area: InvalidDeliveryArea = delivery_area
The invalid delivery area instance that caused this error.
instance
instance-attribute
¤
instance: object = instance
The object instance that had an invalid value.
Methods:¤
__init__ ¤
__init__(
instance: object,
attr_name: str,
delivery_area: InvalidDeliveryArea,
message: str | None = None,
) -> None
Initialize this error.
| PARAMETER | DESCRIPTION |
|---|---|
instance
|
The instance that was being accessed when this error was raised.
TYPE:
|
attr_name
|
The name of the attribute that was being accessed when this error was raised.
TYPE:
|
delivery_area
|
The invalid delivery area instance.
TYPE:
|
message
|
A custom error message. If
TYPE:
|