Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to match some name changes in threedi-schema #433

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog of threedi-modelchecker
2.16.1 (unreleased)
-------------------

- Nothing changed yet.
- Adapt to match some name changes in threedi-schema


2.16.0 (2025-01-16)
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ dependencies = [
"GeoAlchemy2>=0.9,!=0.11.*",
"SQLAlchemy>=1.4",
"pyproj",
"threedi-schema==0.230.*"
"threedi-schema @ https://github.com/nens/threedi-schema/archive/margriet_119_orm_class_names.zip"
# "threedi-schema==0.230.*"
]

[project.optional-dependencies]
Expand Down
10 changes: 5 additions & 5 deletions threedi_modelchecker/checks/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ def description(self) -> str:
return f"{self.column_name} does not start or end at its connection node (tolerance = {self.max_distance} m)"


class ControlMeasureMapLinestringMapLocationCheck(LinestringLocationCheck):
class MeasureMapLinestringMapLocationCheck(LinestringLocationCheck):
def __init__(self, control_table, filters, *args, **kwargs):
super().__init__(
ref_column_start=models.ControlMeasureMap.measure_location_id,
ref_column_end=models.ControlMeasureMap.control_id,
ref_table_start=models.ControlMeasureLocation,
ref_column_start=models.MeasureMap.measure_location_id,
ref_column_end=models.MeasureMap.control_id,
ref_table_start=models.MeasureLocation,
ref_table_end=control_table,
column=models.ControlMeasureMap.geom,
column=models.MeasureMap.geom,
filters=filters,
*args,
**kwargs,
Expand Down
33 changes: 16 additions & 17 deletions threedi_modelchecker/checks/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,15 +963,15 @@ def get_invalid(self, session: Session) -> List[NamedTuple]:
return invalids


class ControlTableActionTableCheckDefault(TableStrCheck):
class TableControlActionTableCheckDefault(TableStrCheck):
def __init__(self, level=CheckLevel.ERROR, error_code=0):
# check for action_table for action_type != set_discharge_coefficients
# expected format: multiple rows, separated by \n of "val,val"
super().__init__(
column=models.ControlTable.action_table,
column=models.TableControl.action_table,
pattern=r"^(-?\d+(\.\d+)?,-?\d+(\.\d+)?\n?)+$",
filters=models.ControlTable.action_type
!= constants.ControlTableActionTypes.set_discharge_coefficients,
filters=models.TableControl.action_type
!= constants.TableControlActionTypes.set_discharge_coefficients,
level=level,
error_code=error_code,
)
Expand All @@ -983,15 +983,15 @@ def description(self) -> str:
)


class ControlTableActionTableCheckDischargeCoefficients(TableStrCheck):
class TableControlActionTableCheckDischargeCoefficients(TableStrCheck):
def __init__(self, level=CheckLevel.ERROR, error_code=0):
# check for action_table for action_type = set_discharge_coefficients
# expected format: multiple rows, separated by \n of "val,val val"
super().__init__(
column=models.ControlTable.action_table,
column=models.TableControl.action_table,
pattern=r"^(-?\d+(\.\d+)?,-?\d+(\.\d+)? -?\d+(\.\d+)?\n?)+$",
filters=models.ControlTable.action_type
== constants.ControlTableActionTypes.set_discharge_coefficients,
filters=models.TableControl.action_type
== constants.TableControlActionTypes.set_discharge_coefficients,
level=level,
error_code=error_code,
)
Expand All @@ -1006,8 +1006,8 @@ def description(self) -> str:
class ControlHasSingleMeasureVariable(BaseCheck):
def __init__(self, control_model, level=CheckLevel.ERROR, error_code=0):
control_type_map = {
models.ControlTable: "table",
models.ControlMemory: "memory",
models.TableControl: "table",
models.MemoryControl: "memory",
}
self.control_type_name = control_type_map[control_model]
super().__init__(
Expand All @@ -1020,17 +1020,16 @@ def get_invalid(self, session: Session) -> List[NamedTuple]:
invalid = []
for record in self.to_check(session):
res = (
session.query(models.ControlMeasureMap)
session.query(models.MeasureMap)
.filter(
models.ControlMeasureMap.control_type == self.control_type_name,
models.ControlMeasureMap.control_id == record.id,
models.MeasureMap.control_type == self.control_type_name,
models.MeasureMap.control_id == record.id,
)
.join(
models.ControlMeasureLocation,
models.ControlMeasureMap.measure_location_id
== models.ControlMeasureLocation.id,
models.MeasureLocation,
models.MeasureMap.measure_location_id == models.MeasureLocation.id,
)
.with_entities(models.ControlMeasureLocation.measure_variable)
.with_entities(models.MeasureLocation.measure_variable)
).all()
if len(res) == 0:
continue
Expand Down
Loading
Loading