ssb-dash-framework 0.2.2__tar.gz → 0.3.0a0__tar.gz

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.
Files changed (61) hide show
  1. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/PKG-INFO +2 -2
  2. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/pyproject.toml +2 -2
  3. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/__init__.py +18 -0
  4. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/assets/dashAgGridFunctions.js +2 -2
  5. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/assets/stylesheet.css +1 -1
  6. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/control/control_framework_base.py +43 -90
  7. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/__init__.py +6 -0
  8. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/agg_dist_plotter.py +157 -184
  9. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/altinn_control_view.py +126 -186
  10. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/altinn_editor/altinn_editor_comment.py +13 -27
  11. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/altinn_editor/altinn_editor_contact.py +26 -46
  12. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/altinn_editor/altinn_editor_control.py +31 -68
  13. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/altinn_editor/altinn_editor_history.py +45 -45
  14. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/altinn_editor/altinn_editor_main_view.py +6 -30
  15. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/altinn_editor/altinn_editor_primary_table.py +163 -177
  16. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/altinn_editor/altinn_editor_submitted_forms.py +88 -129
  17. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/altinn_editor/altinn_editor_supporting_table.py +11 -17
  18. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/altinn_editor/altinn_editor_unit_details.py +15 -35
  19. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/freesearch.py +12 -15
  20. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/macro_module.py +10 -5
  21. ssb_dash_framework-0.3.0a0/src/ssb_dash_framework/modules/macro_module_consolidated.py +1252 -0
  22. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/utils/__init__.py +12 -0
  23. ssb_dash_framework-0.3.0a0/src/ssb_dash_framework/utils/config_tools/__init__.py +17 -0
  24. ssb_dash_framework-0.3.0a0/src/ssb_dash_framework/utils/config_tools/connection.py +220 -0
  25. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/LICENSE +0 -0
  26. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/README.md +0 -0
  27. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/__main__.py +0 -0
  28. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/control/__init__.py +0 -0
  29. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/aarsregnskap.py +0 -0
  30. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/altinn_data_capture.py +0 -0
  31. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/altinn_editor/__init__.py +0 -0
  32. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/altinn_editor/altinn_editor_utility.py +0 -0
  33. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/bedriftstabell.py +0 -0
  34. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/bofregistry.py +0 -0
  35. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/building_blocks/__init__.py +0 -0
  36. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/building_blocks/canvas.py +0 -0
  37. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/building_blocks/figuredisplay.py +0 -0
  38. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/building_blocks/map_display.py +0 -0
  39. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/building_blocks/multimodule.py +0 -0
  40. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/building_blocks/tables.py +0 -0
  41. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/hb_method.py +0 -0
  42. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/nspek.py +0 -0
  43. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/parquet_editor.py +0 -0
  44. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/pi_memorizer.py +0 -0
  45. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/skjemapdfviewer.py +0 -0
  46. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/modules/visualizationbuilder.py +0 -0
  47. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/py.typed +0 -0
  48. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/setup/__init__.py +0 -0
  49. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/setup/app_setup.py +0 -0
  50. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/setup/main_layout.py +0 -0
  51. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/setup/variableselector.py +0 -0
  52. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/utils/alert_handler.py +0 -0
  53. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/utils/app_logger.py +0 -0
  54. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/utils/core_query_functions.py +0 -0
  55. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/utils/datahelper.py +0 -0
  56. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/utils/debugger_modal.py +0 -0
  57. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/utils/eimerdb_helpers.py +0 -0
  58. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/utils/functions.py +0 -0
  59. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/utils/implementations.py +0 -0
  60. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/utils/module_validation.py +0 -0
  61. {ssb_dash_framework-0.2.2 → ssb_dash_framework-0.3.0a0}/src/ssb_dash_framework/utils/r_helpers.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ssb-dash-framework
3
- Version: 0.2.2
3
+ Version: 0.3.0a0
4
4
  Summary: SSB Dash Framework
5
5
  License-Expression: GPL-3.0
6
6
  License-File: LICENSE
@@ -27,7 +27,7 @@ Requires-Dist: ipykernel (>=6.29.5,<7.0.0)
27
27
  Requires-Dist: mpmath (>=1.3.0)
28
28
  Requires-Dist: orjson (>=3.10.16,<4.0.0)
29
29
  Requires-Dist: pandas (>=2.3.1,<3.0.0)
30
- Requires-Dist: psycopg2-binary (>=2.9.10,<3.0.0)
30
+ Requires-Dist: psycopg[pool] (>=3.3.3,<4.0.0)
31
31
  Requires-Dist: rpy2 (>=3.6.4,<4.0.0)
32
32
  Requires-Dist: rwrapr (>=0.9.1,<0.10.0)
33
33
  Requires-Dist: sqlalchemy (>=2.0.43,<3.0.0)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ssb-dash-framework"
3
- version = "0.2.2"
3
+ version = "0.3.0a0"
4
4
  description = "SSB Dash Framework"
5
5
  authors = [{ name = "Magnus Theodor Engh", email = "dor@ssb.no" }]
6
6
  license = "GPL-3.0"
@@ -14,7 +14,6 @@ dependencies = [
14
14
  "mpmath>=1.3.0", # Pimemorizer uses this
15
15
  "orjson (>=3.10.16,<4.0.0)",
16
16
  "ipykernel (>=6.29.5,<7.0.0)",
17
- "psycopg2-binary (>=2.9.10,<3.0.0)",
18
17
  "geopandas (>=1.1.1,<2.0.0)",
19
18
  "ssb-eimerdb (>=0.2.6,<0.3.0)",
20
19
  "sqlalchemy (>=2.0.43,<3.0.0)",
@@ -27,6 +26,7 @@ dependencies = [
27
26
  "dash-bootstrap-templates (>=2.1.0,<3.0.0)",
28
27
  "duckdb (==1.3.2)",
29
28
  "ssb-poc-statlog-model (>=1.0.0,<2.0.0)",
29
+ "psycopg[pool] (>=3.3.3,<4.0.0)",
30
30
  ]
31
31
 
32
32
  [project.urls]
@@ -39,6 +39,9 @@ from .modules import FreeSearchWindow
39
39
  from .modules import HBMethod
40
40
  from .modules import HBMethodWindow
41
41
  from .modules import MacroModule
42
+ from .modules import MacroModuleConsolidated
43
+ from .modules import MacroModuleConsolidatedTab
44
+ from .modules import MacroModuleConsolidatedWindow
42
45
  from .modules import MacroModuleTab
43
46
  from .modules import MacroModuleWindow
44
47
  from .modules import MapDisplay
@@ -73,6 +76,8 @@ from .utils import DebugInspector
73
76
  from .utils import DemoDataCreator
74
77
  from .utils import TabImplementation
75
78
  from .utils import WindowImplementation
79
+ from .utils import _get_connection_callable
80
+ from .utils import _get_connection_object
76
81
  from .utils import _get_kostra_r
77
82
  from .utils import active_no_duplicates_refnr_list
78
83
  from .utils import conn_is_ibis
@@ -80,9 +85,13 @@ from .utils import create_alert
80
85
  from .utils import create_database
81
86
  from .utils import create_database_engine
82
87
  from .utils import enable_app_logging
88
+ from .utils import get_connection
83
89
  from .utils import hb_method
84
90
  from .utils import ibis_filter_with_dict
85
91
  from .utils import module_validator
92
+ from .utils import set_connection
93
+ from .utils import set_eimerdb_connection
94
+ from .utils import set_postgres_connection
86
95
  from .utils import sidebar_button
87
96
 
88
97
  # from .utils import th_error
@@ -130,6 +139,9 @@ __all__ = [
130
139
  "HBMethod",
131
140
  "HBMethodWindow",
132
141
  "MacroModule",
142
+ "MacroModuleConsolidated",
143
+ "MacroModuleConsolidatedTab",
144
+ "MacroModuleConsolidatedWindow",
133
145
  "MacroModuleTab",
134
146
  "MacroModuleWindow",
135
147
  "MapDisplay",
@@ -157,6 +169,8 @@ __all__ = [
157
169
  "VisualizationBuilder",
158
170
  "VisualizationBuilderWindow",
159
171
  "WindowImplementation",
172
+ "_get_connection_callable",
173
+ "_get_connection_object",
160
174
  "active_no_duplicates_refnr_list",
161
175
  "app_setup",
162
176
  "apply_edits",
@@ -166,12 +180,16 @@ __all__ = [
166
180
  "create_database_engine",
167
181
  "enable_app_logging",
168
182
  "export_from_parqueteditor",
183
+ "get_connection",
169
184
  "get_export_log_path",
170
185
  "get_log_path",
171
186
  "ibis_filter_with_dict",
172
187
  "main_layout",
173
188
  "module_validator",
174
189
  "register_control",
190
+ "set_connection",
191
+ "set_eimerdb_connection",
192
+ "set_postgres_connection",
175
193
  "set_variables",
176
194
  "sidebar_button",
177
195
  # "hb_method",
@@ -4,7 +4,7 @@ window.dashAgGridFunctions = window.dashAgGridFunctions || {};
4
4
  window.dashAgGridFunctions.MacroModule = {
5
5
 
6
6
  // === Function formatHeatmapValue (Format values based on row type) ===
7
- formatHeatmapValue(params, isPercentage) {
7
+ formatHeatmapValue(params, tallvisning) {
8
8
  const value = params.value;
9
9
 
10
10
  if (value === null || value === undefined) {
@@ -20,7 +20,7 @@ window.dashAgGridFunctions.MacroModule = {
20
20
  }
21
21
 
22
22
  // Regular cells - format as percentage or number
23
- if (isPercentage) {
23
+ if (tallvisning === 1) {
24
24
  return value.toLocaleString('nb-NO', {
25
25
  style: 'percent',
26
26
  minimumFractionDigits: 1,
@@ -239,7 +239,7 @@ Altinn Editor Support Tables
239
239
  }
240
240
 
241
241
  .hjelpetabeller-modal .modal-content {
242
- height: 70vh !important;
242
+ height: 80vh !important;
243
243
  overflow: hidden;
244
244
  }
245
245
 
@@ -4,12 +4,13 @@ from collections.abc import Callable
4
4
  from typing import Any
5
5
  from typing import ClassVar
6
6
 
7
- import ibis
8
7
  import pandas as pd
9
8
  from eimerdb import EimerDBInstance
10
9
  from ibis import _
10
+ from psycopg_pool import ConnectionPool
11
11
 
12
- from ..utils.core_query_functions import conn_is_ibis
12
+ from ..utils.config_tools.connection import _get_connection_object
13
+ from ..utils.config_tools.connection import get_connection
13
14
  from ..utils.core_query_functions import ibis_filter_with_dict
14
15
 
15
16
  logger = logging.getLogger(__name__)
@@ -120,9 +121,8 @@ class ControlFrameworkBase: # TODO: Add some common control methods here for ea
120
121
  self,
121
122
  time_units,
122
123
  applies_to_subset,
123
- conn,
124
124
  ) -> None:
125
- super().__init__(time_units, applies_to_subset, conn)
125
+ super().__init__(time_units, applies_to_subset)
126
126
  """
127
127
 
128
128
  _required_kontroller_columns: ClassVar[list[str]] = [
@@ -142,21 +142,18 @@ class ControlFrameworkBase: # TODO: Add some common control methods here for ea
142
142
  self,
143
143
  time_units: list[str],
144
144
  applies_to_subset: dict[str, Any],
145
- conn: object,
146
145
  ) -> None:
147
146
  """Initialize the control framework.
148
147
 
149
148
  Args:
150
149
  time_units: Time units that exists in the dataset.
151
150
  applies_to_subset: Subset to execute controls on.
152
- conn: Database connection object.
153
151
  """
154
152
  self.time_units = time_units
155
153
  self.applies_to_subset = applies_to_subset
156
154
  for key, value in self.applies_to_subset.items():
157
155
  if not isinstance(value, list):
158
156
  self.applies_to_subset[key] = [value]
159
- self.conn = conn
160
157
 
161
158
  self._required_kontroller_columns = [
162
159
  *self.time_units,
@@ -223,14 +220,14 @@ class ControlFrameworkBase: # TODO: Add some common control methods here for ea
223
220
  logger.debug("No new control to register, ending here.")
224
221
  return None
225
222
  logger.debug(f"Rows to register:\n{rows_to_register}")
226
- if isinstance(self.conn, EimerDBInstance):
227
- self.conn.insert("kontroller", rows_to_register)
228
- elif conn_is_ibis(self.conn):
229
- conn = self.conn
230
- conn.insert("kontroller", rows_to_register)
223
+ connection_object = _get_connection_object()
224
+ if isinstance(connection_object, EimerDBInstance):
225
+ connection_object.insert("kontroller", rows_to_register)
226
+ elif isinstance(connection_object, ConnectionPool):
227
+ connection_object.insert("kontroller", rows_to_register)
231
228
  else:
232
229
  raise NotImplementedError(
233
- f"Connection type '{type(self.conn)}' is currently not implemented."
230
+ f"Connection type '{type(connection_object)}' is currently not implemented."
234
231
  )
235
232
  logger.info(f"Done inserting {control}")
236
233
 
@@ -245,33 +242,13 @@ class ControlFrameworkBase: # TODO: Add some common control methods here for ea
245
242
  def get_current_kontroller(self) -> pd.DataFrame | None:
246
243
  """Gets the current contents of the 'kontroller' table."""
247
244
  logger.info("Getting current contents of table 'kontroller'")
248
- if isinstance(self.conn, EimerDBInstance):
249
- conn = ibis.polars.connect()
250
- try:
251
- kontroller = self.conn.query(
252
- "SELECT * FROM kontroller"
253
- ) # maybe add something like this?partition_select=self.applies_to_subset
254
- conn.create_table("kontroller", kontroller)
255
- except (
256
- ValueError
257
- ) as e: # TODO permanently fix this. Error caused by running .query on eimerdb table with no contents.
258
- if str(e) == "max() arg is an empty sequence":
259
- logger.warning(
260
- "Did not find any contents in 'kontroller', starting from scratch."
261
- )
262
- return None
263
- elif conn_is_ibis(self.conn):
264
- conn = self.conn
265
- else:
266
- raise NotImplementedError(
267
- f"Connection type '{type(self.conn)}' is currently not implemented."
268
- )
269
- kontroller = conn.table("kontroller")
270
- kontroller = kontroller.filter(
271
- ibis_filter_with_dict(self.applies_to_subset)
272
- ).to_pandas()
273
- logger.debug(f"Kontroller data to return:\n{kontroller}")
274
- return kontroller
245
+ with get_connection(necessary_tables=["kontroller"]) as conn:
246
+ kontroller = conn.table("kontroller")
247
+ kontroller = kontroller.filter(
248
+ ibis_filter_with_dict(self.applies_to_subset)
249
+ ).to_pandas()
250
+ logger.debug(f"Kontroller data to return:\n{kontroller}")
251
+ return kontroller
275
252
 
276
253
  def execute_controls(self) -> None:
277
254
  """Executes all control methods found in the class."""
@@ -391,47 +368,20 @@ class ControlFrameworkBase: # TODO: Add some common control methods here for ea
391
368
 
392
369
  Returns:
393
370
  pd.DataFrame containing the current kontrollutslag table for all controls or just the specified one or None if table empty.
394
-
395
- Raises:
396
- NotImplementedError: If connection is not EimerDBInstance or Ibis connection.
397
- ValueError: If the query fails for reasons other than an empty 'kontrollutslag' table.
398
371
  """
399
372
  logger.info("Getting current kontrollutslag.")
400
- if isinstance(self.conn, EimerDBInstance):
401
- conn = ibis.polars.connect()
402
- try:
403
- kontrollutslag = self.conn.query(
404
- "SELECT * FROM kontrollutslag"
405
- ) # maybe add something like this?partition_select=self.applies_to_subset
406
- conn.create_table("kontrollutslag", kontrollutslag)
407
- except (
408
- ValueError
409
- ) as e: # TODO permanently fix this. Error caused by running .query on eimerdb table with no contents.
410
- if str(e) == "max() arg is an empty sequence":
411
- logger.warning(
412
- "Did not find any contents in 'kontrollutslag', starting from scratch."
413
- )
414
- return None
415
- else:
416
- raise e
417
-
418
- elif conn_is_ibis(self.conn):
419
- conn = self.conn
420
- else:
421
- raise NotImplementedError(
422
- f"Connection type '{type(self.conn)}' is currently not implemented."
373
+ with get_connection(necessary_tables=["kontrollutslag"]) as conn:
374
+ kontrollutslag = conn.table("kontrollutslag")
375
+ kontrollutslag = kontrollutslag.filter(
376
+ ibis_filter_with_dict(self.applies_to_subset)
423
377
  )
424
- kontrollutslag = conn.table("kontrollutslag")
425
- kontrollutslag = kontrollutslag.filter(
426
- ibis_filter_with_dict(self.applies_to_subset)
427
- )
428
- if specific_control:
429
- kontrollutslag = kontrollutslag.filter(_.kontrollid == specific_control)
430
- kontrollutslag = kontrollutslag.to_pandas()
431
- logger.debug(
432
- f"Existing kontrollutslag\nAmount:{kontrollutslag['utslag'].value_counts()}\nData:\n{kontrollutslag}"
433
- )
434
- return kontrollutslag
378
+ if specific_control:
379
+ kontrollutslag = kontrollutslag.filter(_.kontrollid == specific_control)
380
+ kontrollutslag = kontrollutslag.to_pandas()
381
+ logger.debug(
382
+ f"Existing kontrollutslag\nAmount:{kontrollutslag['utslag'].value_counts()}\nData:\n{kontrollutslag}"
383
+ )
384
+ return kontrollutslag
435
385
 
436
386
  def insert_new_records(self, control_results: pd.DataFrame) -> None:
437
387
  """Inserts new records that are not found in the current contents of the 'kontrollutslag' table."""
@@ -471,14 +421,14 @@ class ControlFrameworkBase: # TODO: Add some common control methods here for ea
471
421
  return None
472
422
  # Now to insert new rows into the table.
473
423
  logger.debug(f"Inserting {control_results.shape[0]} new rows.")
474
- if isinstance(self.conn, EimerDBInstance):
475
- self.conn.insert("kontrollutslag", control_results)
476
- elif conn_is_ibis(self.conn):
477
- conn = self.conn
478
- conn.insert("kontrollutslag", control_results)
424
+ connection_object = _get_connection_object()
425
+ if isinstance(connection_object, EimerDBInstance):
426
+ connection_object.insert("kontrollutslag", control_results)
427
+ elif isinstance(connection_object, ConnectionPool):
428
+ connection_object.insert("kontrollutslag", control_results)
479
429
  else:
480
430
  raise NotImplementedError(
481
- f"Connection type '{type(self.conn)}' is currently not implemented."
431
+ f"Connection type '{type(connection_object)}' is currently not implemented."
482
432
  )
483
433
  logger.debug("Finished inserting new rows.")
484
434
 
@@ -546,15 +496,18 @@ class ControlFrameworkBase: # TODO: Add some common control methods here for ea
546
496
  logger.info(f"Updating {changed.shape[0]} rows.")
547
497
  logger.debug(f"Rows to update:\n{changed}")
548
498
  update_query = self.generate_update_query(changed)
549
- if isinstance(self.conn, EimerDBInstance):
550
- self.conn.query(update_query)
551
- elif conn_is_ibis(self.conn):
552
- conn = self.conn
553
- conn.raw_sql(update_query) # type: ignore[attr-defined]
499
+
500
+ connection_object = _get_connection_object()
501
+ if isinstance(connection_object, EimerDBInstance):
502
+ connection_object.query(update_query)
503
+ elif isinstance(connection_object, ConnectionPool):
504
+ with get_connection() as conn:
505
+ conn.raw_sql(update_query)
554
506
  else:
555
507
  raise NotImplementedError(
556
- f"Connection type '{type(self.conn)}' is currently not implemented."
508
+ f"Connection type '{type(connection_object)}' is currently not implemented."
557
509
  )
510
+
558
511
  logger.debug("Finished updating kontrollutslag.")
559
512
 
560
513
  def generate_update_query(self, df_updates: pd.DataFrame) -> str:
@@ -45,6 +45,9 @@ from .hb_method import HBMethodWindow
45
45
  from .macro_module import MacroModule
46
46
  from .macro_module import MacroModuleTab
47
47
  from .macro_module import MacroModuleWindow
48
+ from .macro_module_consolidated import MacroModuleConsolidated
49
+ from .macro_module_consolidated import MacroModuleConsolidatedTab
50
+ from .macro_module_consolidated import MacroModuleConsolidatedWindow
48
51
  from .nspek import Naeringsspesifikasjon
49
52
  from .nspek import NaeringsspesifikasjonTab
50
53
  from .nspek import NaeringsspesifikasjonWindow
@@ -101,6 +104,9 @@ __all__ = [
101
104
  "MacroModule",
102
105
  "MacroModuleTab",
103
106
  "MacroModuleWindow",
107
+ "MacroModuleConsolidated",
108
+ "MacroModuleConsolidatedTab",
109
+ "MacroModuleConsolidatedWindow",
104
110
  "MapDisplay",
105
111
  "MapDisplayTab",
106
112
  "MapDisplayWindow",