chellow 1729849426.0.0__py3-none-any.whl → 1730296955.0.0__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.

Potentially problematic release.


This version of chellow might be problematic. Click here for more details.

chellow/e/computer.py CHANGED
@@ -127,12 +127,30 @@ def non_core_rate(sess, caches, contract_id_or_name, date):
127
127
 
128
128
  def hh_rate(sess, caches, contract_id_or_name, date, market_role_code=None):
129
129
  try:
130
- return caches["computer"]["rates"][market_role_code][contract_id_or_name][date]
130
+ ccache = caches["computer"]
131
+ except KeyError:
132
+ ccache = caches["computer"] = {}
133
+
134
+ try:
135
+ contract_id = ccache[market_role_code][contract_id_or_name]
131
136
  except KeyError:
132
137
  try:
133
- ccache = caches["computer"]
138
+ mr_cache = ccache[market_role_code]
134
139
  except KeyError:
135
- ccache = caches["computer"] = {}
140
+ mr_cache = ccache[market_role_code] = {}
141
+
142
+ if market_role_code is None:
143
+ contract_id = Contract.get_by_id(sess, contract_id_or_name).id
144
+ else:
145
+ contract_id = Contract.get_by_role_code_name(
146
+ sess, market_role_code, contract_id_or_name
147
+ ).id
148
+
149
+ mr_cache[contract_id_or_name] = contract_id
150
+
151
+ try:
152
+ return ccache["rates"][contract_id][date]
153
+ except KeyError:
136
154
 
137
155
  try:
138
156
  rss_cache = ccache["rates"]
@@ -140,24 +158,14 @@ def hh_rate(sess, caches, contract_id_or_name, date, market_role_code=None):
140
158
  rss_cache = ccache["rates"] = {}
141
159
 
142
160
  try:
143
- mr_cache = rss_cache[market_role_code]
144
- except KeyError:
145
- mr_cache = rss_cache[market_role_code] = {}
146
-
147
- try:
148
- cont_cache = mr_cache[contract_id_or_name]
161
+ cont_cache = rss_cache[contract_id]
149
162
  except KeyError:
150
- cont_cache = mr_cache[contract_id_or_name] = {}
163
+ cont_cache = rss_cache[contract_id] = {}
151
164
 
152
165
  try:
153
166
  return cont_cache[date]
154
167
  except KeyError:
155
- if market_role_code is None:
156
- contract = Contract.get_by_id(sess, contract_id_or_name)
157
- else:
158
- contract = Contract.get_by_role_code_name(
159
- sess, market_role_code, contract_id_or_name
160
- )
168
+ contract = Contract.get_by_id(sess, contract_id)
161
169
 
162
170
  year_after = date + YEAR
163
171
  year_before = date - YEAR
chellow/e/scenario.py CHANGED
@@ -15,13 +15,16 @@ from chellow.e.computer import (
15
15
  contract_func,
16
16
  datum_range,
17
17
  displaced_era,
18
+ hh_rate,
18
19
  )
19
20
  from chellow.models import Era, Llfc, MtcParticipant, Pc, SiteEra, Source, Supply
20
21
  from chellow.utils import (
22
+ PropDict,
21
23
  c_months_u,
22
24
  hh_format,
23
25
  hh_max,
24
26
  hh_min,
27
+ hh_range,
25
28
  parse_hh_start,
26
29
  to_ct,
27
30
  to_utc,
@@ -661,3 +664,46 @@ class ScenarioSource:
661
664
 
662
665
  hh["msp-kwh"] += delt
663
666
  hh["msp-kw"] += delt * 2
667
+
668
+
669
+ def scenario_fill_cache(report_context, sess, scenario_props):
670
+ try:
671
+ comp = report_context["computer"]
672
+ except KeyError:
673
+ comp = report_context["computer"] = {}
674
+
675
+ try:
676
+ rate_cache = comp["rates"]
677
+ except KeyError:
678
+ rate_cache = comp["rates"] = {}
679
+
680
+ for rate_script in scenario_props.get("rates", []):
681
+ contract_id = rate_script["contract_id"]
682
+ try:
683
+ cont_cache = rate_cache[contract_id]
684
+ except KeyError:
685
+ cont_cache = rate_cache[contract_id] = {}
686
+
687
+ try:
688
+ rate_script_start = rate_script["start_date"]
689
+ except KeyError:
690
+ raise BadRequest(
691
+ f"Problem in the scenario properties. Can't find the 'start_date' key "
692
+ f"of the contract {contract_id} in the 'rates' map."
693
+ )
694
+
695
+ try:
696
+ rate_script_finish = rate_script["finish_date"]
697
+ except KeyError:
698
+ raise BadRequest(
699
+ f"Problem in the scenario properties. Can't find the 'finish_date' "
700
+ f"key of the contract {contract_id} in the 'rates' map."
701
+ )
702
+
703
+ for dt in hh_range(report_context, rate_script_start, rate_script_finish):
704
+ hh_rate(sess, report_context, contract_id, dt)
705
+
706
+ for dt in hh_range(report_context, rate_script_start, rate_script_finish):
707
+ storage = cont_cache[dt]._storage.copy()
708
+ storage.update(rate_script["script"])
709
+ cont_cache[dt] = PropDict("scenario properties", storage)
chellow/e/tnuos.py CHANGED
@@ -21,6 +21,7 @@ def hh(ds):
21
21
  BAND_LOOKUP = {
22
22
  "Domestic Aggregated (Related MPAN)": "Domestic",
23
23
  "Domestic Aggregated with Residual": "Domestic",
24
+ "Domestic Aggregated or CT with Residual": "Domestic",
24
25
  "HV Generation Site Specific": "HV1",
25
26
  "HV Generation Site Specific no RP charge": "HV1",
26
27
  "HV Site Specific Band 1": "HV1",
@@ -46,11 +47,21 @@ BAND_LOOKUP = {
46
47
  "LV Sub Site Specific No Residual": "LV1",
47
48
  "Non-Domestic Aggregated (related MPAN)": "LV_NoMIC_1",
48
49
  "Non-Domestic Aggregated Band 1": "LV_NoMIC_1",
50
+ "Non-Domestic Aggregated or CT Band 1": "LV_NoMIC_1",
49
51
  "Non-Domestic Aggregated Band 2": "LV_NoMIC_2",
52
+ "Non-Domestic Aggregated or CT Band 2": "LV_NoMIC_2",
50
53
  "Non-Domestic Aggregated Band 3": "LV_NoMIC_3",
54
+ "Non-Domestic Aggregated or CT Band 3": "LV_NoMIC_3",
51
55
  "Non-Domestic Aggregated Band 4": "LV_NoMIC_4",
56
+ "Non-Domestic Aggregated or CT Band 4": "LV_NoMIC_4",
52
57
  "Non-Domestic Aggregated No Residual": "LV_NoMIC_1",
58
+ "Non-Domestic Aggregated or CT No Residual": "LV_NoMIC_1",
53
59
  "Unmetered Supplies": "Unmetered",
60
+ "Designated EHV Site Specific No Residual": "EHV1",
61
+ "Designated EHV Site Specific Band 1": "EHV1",
62
+ "Designated EHV Site Specific Band 2": "EHV2",
63
+ "Designated EHV Site Specific Band 3": "EHV3",
64
+ "Designated EHV Site Specific Band 4": "EHV4",
54
65
  "Designated EHV0": "EHV1",
55
66
  "Designated EHV1": "EHV1",
56
67
  "Designated EHV2": "EHV2",
@@ -17,7 +17,7 @@ from werkzeug.exceptions import BadRequest
17
17
 
18
18
  from chellow.dloads import open_file
19
19
  from chellow.e.computer import contract_func, forecast_date
20
- from chellow.e.scenario import make_calcs, make_site_deltas
20
+ from chellow.e.scenario import make_calcs, make_site_deltas, scenario_fill_cache
21
21
  from chellow.models import (
22
22
  Bill,
23
23
  Contract,
@@ -36,7 +36,6 @@ from chellow.models import (
36
36
  )
37
37
  from chellow.utils import (
38
38
  HH,
39
- PropDict,
40
39
  c_months_c,
41
40
  c_months_u,
42
41
  hh_format,
@@ -734,21 +733,6 @@ class Object:
734
733
  def content(scenario_props, base_name, user_id, compression, now):
735
734
  report_context = {}
736
735
 
737
- try:
738
- comp = report_context["computer"]
739
- except KeyError:
740
- comp = report_context["computer"] = {}
741
-
742
- try:
743
- rate_cache = comp["rates"]
744
- except KeyError:
745
- rate_cache = comp["rates"] = {}
746
-
747
- try:
748
- ind_cont = report_context["contract_names"]
749
- except KeyError:
750
- ind_cont = report_context["contract_names"] = {}
751
-
752
736
  sess = rf = None
753
737
  org_rows = []
754
738
  site_rows = []
@@ -826,54 +810,7 @@ def content(scenario_props, base_name, user_id, compression, now):
826
810
  fname = "_".join(base_name) + ".ods"
827
811
  rf = open_file(fname, user, mode="wb")
828
812
 
829
- for rate_script in scenario_props.get("rates", []):
830
- contract_id = rate_script["contract_id"]
831
- try:
832
- cont_cache = rate_cache[contract_id]
833
- except KeyError:
834
- cont_cache = rate_cache[contract_id] = {}
835
-
836
- try:
837
- rate_script_start = rate_script["start_date"]
838
- except KeyError:
839
- raise BadRequest(
840
- f"Problem in the scenario properties. Can't find the "
841
- f"'start_date' key of the contract {contract_id} in the "
842
- f"'rates' map."
843
- )
844
-
845
- try:
846
- rate_script_start = rate_script["start_date"]
847
- except KeyError:
848
- raise BadRequest(
849
- f"Problem in the scenario properties. Can't find the "
850
- f"'start_date' key of the contract {contract_id} in the "
851
- f"'rates' map."
852
- )
853
-
854
- props = PropDict("scenario properties", rate_script["script"])
855
- for dt in hh_range(
856
- report_context, rate_script_start, rate_script["finish_date"]
857
- ):
858
- cont_cache[dt] = props
859
-
860
- for rate_script in scenario_props.get("industry_rates", []):
861
- contract_name = rate_script["contract_name"]
862
- try:
863
- cont_cache = ind_cont[contract_name]
864
- except KeyError:
865
- cont_cache = ind_cont[contract_name] = {}
866
-
867
- rfinish = rate_script["finish_date"]
868
- if rfinish is None:
869
- raise BadRequest(
870
- f"For the industry rate {contract_name} the finish_date can't "
871
- f"be null."
872
- )
873
- for dt in hh_range(report_context, rate_script["start_date"], rfinish):
874
- cont_cache[dt] = PropDict(
875
- "scenario properties", rate_script["script"]
876
- )
813
+ scenario_fill_cache(report_context, sess, scenario_props)
877
814
 
878
815
  by_hh = scenario_props.get("by_hh", False)
879
816
  org_header_titles = [
@@ -16,7 +16,7 @@ from werkzeug.exceptions import BadRequest
16
16
 
17
17
  from chellow.dloads import open_file
18
18
  from chellow.e.computer import contract_func, forecast_date
19
- from chellow.e.scenario import make_calcs, make_site_deltas
19
+ from chellow.e.scenario import make_calcs, make_site_deltas, scenario_fill_cache
20
20
  from chellow.models import (
21
21
  Bill,
22
22
  Contract,
@@ -34,7 +34,6 @@ from chellow.models import (
34
34
  )
35
35
  from chellow.utils import (
36
36
  HH,
37
- PropDict,
38
37
  c_months_u,
39
38
  ct_datetime,
40
39
  ct_datetime_now,
@@ -716,21 +715,6 @@ def content(
716
715
  ):
717
716
  report_context = {}
718
717
 
719
- try:
720
- comp = report_context["computer"]
721
- except KeyError:
722
- comp = report_context["computer"] = {}
723
-
724
- try:
725
- rate_cache = comp["rates"]
726
- except KeyError:
727
- rate_cache = comp["rates"] = {}
728
-
729
- try:
730
- ind_cont = report_context["contract_names"]
731
- except KeyError:
732
- ind_cont = report_context["contract_names"] = {}
733
-
734
718
  rsess = rf = None
735
719
  site_rows = []
736
720
  supply_rows = []
@@ -786,55 +770,7 @@ def content(
786
770
 
787
771
  user = User.get_by_id(rsess, user_id)
788
772
  rf = open_file("_".join(base_name) + ".ods", user, mode="wb")
789
-
790
- for rate_script in scenario_props.get("rates", []):
791
- contract_id = rate_script["contract_id"]
792
- try:
793
- cont_cache = rate_cache[contract_id]
794
- except KeyError:
795
- cont_cache = rate_cache[contract_id] = {}
796
-
797
- try:
798
- rate_script_start = rate_script["start_date"]
799
- except KeyError:
800
- raise BadRequest(
801
- f"Problem in the scenario properties. Can't find the "
802
- f"'start_date' key of the contract {contract_id} in the "
803
- f"'rates' map."
804
- )
805
-
806
- try:
807
- rate_script_start = rate_script["start_date"]
808
- except KeyError:
809
- raise BadRequest(
810
- f"Problem in the scenario properties. Can't find the "
811
- f"'start_date' key of the contract {contract_id} in the "
812
- f"'rates' map."
813
- )
814
-
815
- props = PropDict("scenario properties", rate_script["script"])
816
- for dt in hh_range(
817
- report_context, rate_script_start, rate_script["finish_date"]
818
- ):
819
- cont_cache[dt] = props
820
-
821
- for rate_script in scenario_props.get("industry_rates", []):
822
- contract_name = rate_script["contract_name"]
823
- try:
824
- cont_cache = ind_cont[contract_name]
825
- except KeyError:
826
- cont_cache = ind_cont[contract_name] = {}
827
-
828
- rfinish = rate_script["finish_date"]
829
- if rfinish is None:
830
- raise BadRequest(
831
- f"For the industry rate {contract_name} the finish_date can't "
832
- f"be null."
833
- )
834
- for dt in hh_range(report_context, rate_script["start_date"], rfinish):
835
- cont_cache[dt] = PropDict(
836
- "scenario properties", rate_script["script"]
837
- )
773
+ scenario_fill_cache(report_context, rsess, scenario_props)
838
774
 
839
775
  by_hh = scenario_props.get("by_hh", False)
840
776
  is_bill_check = scenario_props.get("is_bill_check", False)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: chellow
3
- Version: 1729849426.0.0
3
+ Version: 1730296955.0.0
4
4
  Summary: Web Application for checking UK energy bills.
5
5
  Project-URL: Homepage, https://github.com/WessexWater/chellow
6
6
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
@@ -22,7 +22,7 @@ Requires-Dist: python-dateutil==2.8.2
22
22
  Requires-Dist: pytz==2022.6
23
23
  Requires-Dist: requests==2.32.2
24
24
  Requires-Dist: sqlalchemy==2.0.30
25
- Requires-Dist: waitress==2.1.2
25
+ Requires-Dist: waitress==3.0.1
26
26
  Requires-Dist: xlrd==2.0.1
27
27
  Requires-Dist: zish==0.1.11
28
28
  Description-Content-Type: text/markdown
@@ -20,7 +20,7 @@ chellow/e/bmarketidx.py,sha256=C0BaHn2RxIuWH2QzA-OmSP0fbUGvW9tqEUhLnzOEdmA,7968
20
20
  chellow/e/bsuos.py,sha256=hdP9vnOJSuZl46OAkJeUg1XJYvYIBj4J6Sqce1Hy9Vs,15542
21
21
  chellow/e/ccl.py,sha256=30dh_SvlgzsTQPPAJNZWILaMvbeDsv9-P-S1JxS5_SQ,3184
22
22
  chellow/e/cfd.py,sha256=Gm435c42LFwZx1n-1UY1Tdx6mL1is7E0vRLWQe8RPOo,14184
23
- chellow/e/computer.py,sha256=24aBfC-aYoTseRwQSNRAb1PwTKp0zL9aispceL8drcU,67469
23
+ chellow/e/computer.py,sha256=jslEeLsSHbu4l95WDIHCytL2Fced-kLtyxZtvm2WEtg,67597
24
24
  chellow/e/dno_rate_parser.py,sha256=A5TP6KjyfT5lVWh7dX4SiXRi6wnf2lGv-H_T4Sod8CI,21731
25
25
  chellow/e/duos.py,sha256=nwviRjz-qIt3GxIMHk0hItIT4dtKsxOWq9TUC1z-hO8,30864
26
26
  chellow/e/elexon.py,sha256=ALhXS9Es7PV0z9ukPbIramn3cf3iLyFi-PMWPSm5iOs,5487
@@ -38,10 +38,10 @@ chellow/e/lcc.py,sha256=OkpynN8_iAdHRlu-yyU6BhRUqYYOZsUnl0HbHULYo_4,4670
38
38
  chellow/e/mdd_importer.py,sha256=NugJr2JhuzkPTsEMl_5UdQuw5K2p8lVJ-hyz4MK6Hfg,35762
39
39
  chellow/e/rcrc.py,sha256=92CA1uIotIHd1epQ_jEPdJKzXqDFV-AoJOJeRO6MEyA,4274
40
40
  chellow/e/ro.py,sha256=dZKZv_9wXSWuwcb3jiKavoD_9ot-PZseNVeEEe0siLo,596
41
- chellow/e/scenario.py,sha256=86DQIJ6ZK2XYIisHw6DafGcfwo1iPWF1t9rByy2yxbg,23396
41
+ chellow/e/scenario.py,sha256=FLgh03r_SgXx0hMWFbAvwsz2ScDL8LUwYWSWVv2rQlg,24973
42
42
  chellow/e/system_price.py,sha256=6w5J7bzwFAZubE2zdOFRiS8IIrVP8hkoIOaG2yCt-Ic,6232
43
43
  chellow/e/tlms.py,sha256=M33D6YpMixu2KkwSCzDRM3kThLgShg8exp63Obo75l8,8905
44
- chellow/e/tnuos.py,sha256=XseYztPUsQXNKuBmystO2kzzwAG9ehCZgpGBTdgSk-A,4313
44
+ chellow/e/tnuos.py,sha256=NBmc-f3oezrl4gviAKobljHfICTpBKxxxEGBGJi_lRk,4927
45
45
  chellow/e/triad.py,sha256=lIQj7EdUrcFwEqleuHZXYU_bfzIwNOqUVVxB3NPQt4A,13710
46
46
  chellow/e/views.py,sha256=ZISAhDQZHM8j0VKdMOqfNBtwSLTE9c0OtnsGVCaT0kE,216706
47
47
  chellow/e/bill_parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -84,14 +84,14 @@ chellow/reports/report_219.py,sha256=cA0lfJKnJg41Zc4_gZB1KUXZ9JeJo0TiTlu5jm1bdDM
84
84
  chellow/reports/report_231.py,sha256=uhO1algP7sibpZVaniqGs56HOCPCQeDO-Y-UfvFQwnI,5311
85
85
  chellow/reports/report_233.py,sha256=HJRn4wH7RsYIduD2MNZYjFTbgb5LIu8_-jmUuRc0Q6Y,5016
86
86
  chellow/reports/report_241.py,sha256=AlFmSHnfG2HWv_ICmWX7fNpPwLHjq7mo1QtOTjSKO3k,5384
87
- chellow/reports/report_247.py,sha256=kIHXNyXnmL0eZe-o8YvgiF0ZnlzdXF7KDz4r0pcHszk,46965
87
+ chellow/reports/report_247.py,sha256=eQurEZB51uucdpvBRZ8riOTRs55px4hMo1r3BBeo4Uw,44550
88
88
  chellow/reports/report_29.py,sha256=KDFjgrLBv4WbG9efCdu_geMR7gT_QV9N97Wfdt7aDc4,2736
89
89
  chellow/reports/report_291.py,sha256=rqBXy6s7hMeYWw-yNX6w_L5t2yz6rNEeos_4xO7wf90,7519
90
90
  chellow/reports/report_33.py,sha256=laVz-itDbJTdvC6LxLEeuY0eKpYx43Un4adiExPTEEE,16730
91
91
  chellow/reports/report_387.py,sha256=kmBZopb0AOivcowO2nPjRj6LnV0_QjCDXLwqPL7IGVE,5672
92
92
  chellow/reports/report_41.py,sha256=QQeTshA1Og7N3wPaoZ8ynJzwsvZ1mgSFc7DDkVqIZoM,7447
93
93
  chellow/reports/report_429.py,sha256=8WlLqyfMyvIF5Kc6CE0MKwcT5xwmR_Ao99Ef72yAOVc,12668
94
- chellow/reports/report_59.py,sha256=BPeXKF3BJFDY6tsP2-SehBGKXO_t_uRX7MwVgyNbDpo,44677
94
+ chellow/reports/report_59.py,sha256=3N5I9U-nqNGKz39IdBTyDMlb_-srwpo_0kwn9viQnYs,42262
95
95
  chellow/reports/report_81.py,sha256=NkT6dZeMo7Z0AkJemD_Xv8Ut5PIZ9vn8Ia1Q_DS9v54,5611
96
96
  chellow/reports/report_87.py,sha256=j2gdBOapaVY1ZnlNlw14RPx58_k8eUkc3oRSnKuCsNA,7057
97
97
  chellow/reports/report_asset_comparison.py,sha256=UN298MHuzyUDUiiZr7F_Ua6SrdVOlFLjgKjnIbrA-14,6118
@@ -377,6 +377,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
377
377
  chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
378
378
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
379
379
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
380
- chellow-1729849426.0.0.dist-info/METADATA,sha256=l0ROSjJXuLVti1C4484g9I-i6_O6pR1RNfgQk2uICCM,12204
381
- chellow-1729849426.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
382
- chellow-1729849426.0.0.dist-info/RECORD,,
380
+ chellow-1730296955.0.0.dist-info/METADATA,sha256=EWZqlbrVtZnK0QYT9y6umoxEQNWbIAPMBYFWvnPr9WU,12204
381
+ chellow-1730296955.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
382
+ chellow-1730296955.0.0.dist-info/RECORD,,