Skip to content

Commit

Permalink
Merge pull request #43 from teksi/2024-08-09-debug-precommits
Browse files Browse the repository at this point in the history
2024-08-09-debug-precommits
  • Loading branch information
sjib authored Aug 10, 2024
2 parents 6a13601 + bbbeaf1 commit c79deb9
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 85 deletions.
42 changes: 20 additions & 22 deletions datamodel/app/create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pirogue import SingleInheritance

# from view.vw_tdh_reach import vw_tdh_reach
# from view.vw_tdh_wastewater_structure import vw_tdh_wastewater_structure
# from view.vw_tdh_xxx_structure import vw_tdh_xxx_structure


def run_sql_file(file_path: str, pg_service: str, variables: dict = None):
Expand All @@ -36,8 +36,8 @@ def create_app(
srid: int = 2056,
pg_service: str = "pg_tdh",
drop_schema: Optional[bool] = False,
# tdh_reach_extra: Optional[Path] = None,
# tdh_wastewater_structure_extra: Optional[Path] = None,
# tdh_xxx_extra: Optional[Path] = None,
# if several tdh_xx_extra add a line for each view
):
"""
Creates the schema tdh_app for TEKSI Distance Heating
Expand All @@ -46,8 +46,7 @@ def create_app(
:param pg_service: the PostgreSQL service, if not given it will be determined from environment variable in Pirogue
"""

# :param tdh_reach_extra: YAML file path of the definition of additional columns for vw_tdh_reach view
# :param tdh_wastewater_structure_extra: YAML file path of the definition of additional columns for vw_tdh_wastewater_structure_extra view
# :param tdh_xxx_extra: YAML file path of the definition of additional columns for vw_tdh_xxx view

Path(__file__).parent.resolve()
variables = {
Expand All @@ -59,24 +58,21 @@ def create_app(

run_sql("CREATE SCHEMA tdh_app;", pg_service)

# to do add symbology_function for TEKSI Distance heating
# to do add symbology_function and geometry_funcions for TEKSI Distance heating

# run_sql_file("symbology_functions.sql", pg_service)
# run_sql_file("reach_direction_change.sql", pg_service, variables)
# run_sql_file("14_geometry_functions.sql", pg_service, variables)

# open YAML files
# if tdh_reach_extra:
# tdh_reach_extra = safe_load(open(tdh_reach_extra))
# if tdh_wastewater_structure_extra:
# tdh_wastewater_structure_extra = safe_load(open(tdh_wastewater_structure_extra))
# if tdh_xx_extra:
# tdh_xx_extra = safe_load(open(tdh_xx_extra))

run_sql_file("view/vw_dictionary_value_list.sql", pg_service, variables)

defaults = {"view_schema": "tdh_app", "pg_service": pg_service}

SingleInheritances = {
# pipe_point (Leitungspunkt)
# subclasse of pipe_point (Leitungspunkt)
"pipe_point_normal": "pipe_point",
"pipe_point_feed": "pipe_point",
}
Expand All @@ -91,6 +87,8 @@ def create_app(
**defaults,
).create()

# MultipleInheritance configuration - add a block for each MultipleInheritance

# MultipleInheritance(
# safe_load(open(cwd / "view/vw_maintenance_event.yaml")),
# create_joins=True,
Expand All @@ -105,13 +103,11 @@ def create_app(
# pg_service=pg_service,
# ).create()

# vw_tdh_wastewater_structure(
# srid, pg_service=pg_service, extra_definition=tdh_wastewater_structure_extra
# vw_tdh_xxx(
# srid, pg_service=pg_service, extra_definition=tdh_xxx_extra
# )

# vw_tdh_reach(
# pg_service=pg_service, extra_definition=tdh_reach_extra
# )
# additional views to be created with simple sql

# run_sql_file("view/vw_file.sql", pg_service, variables)

Expand All @@ -128,12 +124,14 @@ def create_app(
# run_sql_file("view/network/vw_network_segment.sql", pg_service, variables)

# Recreate extension views
# to do add extensions if necessar
# to do add extensions if necessary
# run_sql_file("swmm_views/02_vw_swmm_junctions.sql", pg_service, variables)

# SimpleJoins configuration - add a block for each SimpleJoins

# SimpleJoins(safe_load(open(cwd / "view/export/vw_export_reach.yaml")), pg_service).create()
# SimpleJoins(
# safe_load(open(cwd / "view/export/vw_export_wastewater_structure.yaml")),
# safe_load(open(cwd / "view/export/vw_export_xxx_structure.yaml")),
# pg_service,
# ).create()

Expand All @@ -149,8 +147,8 @@ def create_app(
"-s", "--srid", help="SRID EPSG code, defaults to 2056", type=int, default=2056
)
# parser.add_argument(
# "--tdh_wastewater_structure_extra",
# help="YAML definition file path for additions to vw_tdh_wastewater_structure view",
# "--tdh_xxx_structure_extra",
# help="YAML definition file path for additions to vw_tdh_xxx_structure view",
# )
# parser.add_argument(
# "--tdh_reach_extra",
Expand All @@ -170,5 +168,5 @@ def create_app(
args.pg_service,
drop_schema=args.drop_schema,
# tdh_reach_extra=args.tdh_reach_extra,
# tdh_wastewater_structure_extra=args.tdh_wastewater_structure_extra,
# tdh_xxx_structure_extra=args.tdh_xxx_structure_extra,
)
Loading

0 comments on commit c79deb9

Please sign in to comment.