python-midas 1.0.0__py3-none-any.whl → 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
midas/entities/models.py CHANGED
@@ -38,13 +38,10 @@ def _parse_decimal(n: int | float | None) -> Decimal | None:
38
38
  return Decimal(str(n))
39
39
 
40
40
 
41
- def _parse_day_type(s: str | None) -> DayType | None:
42
- if not s:
43
- return None
44
- try:
45
- return DayType(s)
46
- except ValueError:
47
- return None
41
+ def _parse_day_type(v: object) -> DayType | None:
42
+ # v2.0 MOER/ALRT send an integer code (1=Mon..8=Holiday); v1.0/electricity
43
+ # send a weekday string. DayType.from_wire accepts both.
44
+ return DayType.from_wire(v)
48
45
 
49
46
 
50
47
  def _parse_unit(s: str | None) -> Unit | str | None:
@@ -114,6 +111,8 @@ class RateInfo(MIDASBase):
114
111
  id: str | None = None
115
112
  system_time: PendulumDateTime = None
116
113
  name: str | None = None
114
+ signal_type: SignalType | None = None
115
+ description: str | None = None
117
116
  type: RateType | str | None = None
118
117
  sector: str | None = None
119
118
  end_use: str | None = None
@@ -137,6 +136,10 @@ class RateInfo(MIDASBase):
137
136
  id=raw.get("RateID"),
138
137
  system_time=parse_instant(raw.get("SystemTime_UTC")),
139
138
  name=raw.get("RateName"),
139
+ # v2.0 rate-values responses carry the per-RIN SignalType label and
140
+ # Description at the top level (as in the RIN list).
141
+ signal_type=_parse_signal_type(raw.get("SignalType")),
142
+ description=raw.get("Description"),
140
143
  type=_parse_rate_type(raw.get("RateType")),
141
144
  sector=raw.get("Sector"),
142
145
  end_use=raw.get("EndUse"),
midas/enums.py CHANGED
@@ -71,3 +71,41 @@ class DayType(str, Enum):
71
71
  SATURDAY = "Saturday"
72
72
  SUNDAY = "Sunday"
73
73
  HOLIDAY = "Holiday"
74
+
75
+ @classmethod
76
+ def from_wire(cls, v: object) -> "DayType | None":
77
+ """Coerce a wire day-type value to a DayType, or None if unmappable.
78
+
79
+ v2.0 SGIP GHG (MOER) and Flex Alert (ALRT) responses encode the day
80
+ type as an INTEGER upload code (1=Monday ... 7=Sunday, 8=Holiday); v1.0
81
+ and electricity rates use the weekday string ("Monday"). Both forms are
82
+ accepted (a digit string such as "1" is treated as the integer code).
83
+ """
84
+ if isinstance(v, bool) or v is None:
85
+ return None
86
+ if isinstance(v, int):
87
+ return _DAY_TYPE_BY_CODE.get(v)
88
+ if isinstance(v, str):
89
+ s = v.strip()
90
+ if not s:
91
+ return None
92
+ if s.isdigit():
93
+ return _DAY_TYPE_BY_CODE.get(int(s))
94
+ try:
95
+ return cls(s)
96
+ except ValueError:
97
+ return None
98
+ return None
99
+
100
+
101
+ #: v2.0 integer day-type upload codes (1=Monday ... 7=Sunday, 8=Holiday).
102
+ _DAY_TYPE_BY_CODE: dict[int, DayType] = {
103
+ 1: DayType.MONDAY,
104
+ 2: DayType.TUESDAY,
105
+ 3: DayType.WEDNESDAY,
106
+ 4: DayType.THURSDAY,
107
+ 5: DayType.FRIDAY,
108
+ 6: DayType.SATURDAY,
109
+ 7: DayType.SUNDAY,
110
+ 8: DayType.HOLIDAY,
111
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-midas
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: Python client library for the California Energy Commission MIDAS API
5
5
  Project-URL: Homepage, https://grid-coordination.energy
6
6
  Project-URL: Repository, https://github.com/grid-coordination/python-midas
@@ -23,6 +23,7 @@ Requires-Dist: httpx>=0.27
23
23
  Requires-Dist: pendulum>=3.0
24
24
  Requires-Dist: pydantic>=2.5
25
25
  Provides-Extra: dev
26
+ Requires-Dist: jsonschema>=4.18; extra == 'dev'
26
27
  Requires-Dist: pytest-httpx>=0.30; extra == 'dev'
27
28
  Requires-Dist: pytest>=8.0; extra == 'dev'
28
29
  Requires-Dist: ruff>=0.3; extra == 'dev'
@@ -1,12 +1,12 @@
1
1
  midas/__init__.py,sha256=aKqmLyoRRu0pZZn4kA6RbqxB3EhXezSLuT9CS_m27Z0,1493
2
2
  midas/auth.py,sha256=iAZmp3-pGzcvmVKgzP9jnyWeviX8ufwyAvMsetnG8dM,3301
3
3
  midas/client.py,sha256=KfsY9-jm5MyCSNdrhonFZX93POcLkJZ1ExO0I6Eik7o,6718
4
- midas/enums.py,sha256=4iamwyP426SBamteYhwSOqOALp2ulxlCNghr1SIwZJ0,2253
4
+ midas/enums.py,sha256=2UgzcJUTGHL6dy5lys_0kngm0xcQljJo5nrKVTQwCDY,3501
5
5
  midas/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  midas/time.py,sha256=rUIMN_ARZJ7bzKie6OMnngdxKXpIncab9aaE2rHFBNM,3810
7
7
  midas/entities/__init__.py,sha256=dD0Y3AjK9qI3BkO-v1fFcL_K5_yVAEzuKvP2pVntRGE,1404
8
- midas/entities/models.py,sha256=cGVbdAfPF7UqFa19ZmWkByLG7-_Xs6swxzX04jUYFYo,8200
9
- python_midas-1.0.0.dist-info/METADATA,sha256=dqWTHrqcA3VH4-7Yt3ZdqfRy0uYXgvaPhfZD3e-ctlc,19841
10
- python_midas-1.0.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
11
- python_midas-1.0.0.dist-info/licenses/LICENSE,sha256=SNfEtQtKuaLySMOhEdErGT_hoKN-6L0BJlPJpUXZoDI,1089
12
- python_midas-1.0.0.dist-info/RECORD,,
8
+ midas/entities/models.py,sha256=3iLS9Aj7vj-6ef6rV1-K27e-Etx8sknrDZFYSSgEwBE,8593
9
+ python_midas-1.0.1.dist-info/METADATA,sha256=5-Sz4Xp1sSddzxrc29LoAkrCxSzxjICuKfrxfGeRv9Q,19889
10
+ python_midas-1.0.1.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
11
+ python_midas-1.0.1.dist-info/licenses/LICENSE,sha256=SNfEtQtKuaLySMOhEdErGT_hoKN-6L0BJlPJpUXZoDI,1089
12
+ python_midas-1.0.1.dist-info/RECORD,,