hydamo-validation 1.3.0b3__tar.gz → 1.3.0b4__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.
Potentially problematic release.
This version of hydamo-validation might be problematic. Click here for more details.
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/PKG-INFO +1 -1
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/__init__.py +4 -2
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/logical_validation.py +6 -3
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/summaries.py +3 -3
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/validator.py +41 -24
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation.egg-info/PKG-INFO +1 -1
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/LICENSE +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/README.md +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/datamodel.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/datasets.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/functions/__init__.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/functions/general.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/functions/logic.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/functions/topologic.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/geometry.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/schemas/hydamo/HyDAMO_2.2.json +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/schemas/hydamo/HyDAMO_2.3.json +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/schemas/rules/rules_1.0.json +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/schemas/rules/rules_1.1.json +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/schemas/rules/rules_1.2.json +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/schemas/rules/rules_1.3.json +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/styles/hydroobject.qml +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/styles/hydroobject.sld +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/styles.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/syntax_validation.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/utils.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation.egg-info/SOURCES.txt +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation.egg-info/dependency_links.txt +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation.egg-info/requires.txt +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation.egg-info/top_level.txt +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation.egg-info/zip-safe +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/pyproject.toml +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/setup.cfg +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/setup.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_datasets.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_dommelerwaard.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_general_functions.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_hydamo_2_2.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_init.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_logic_functions.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_not_overlapping.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_productie.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_structures_at_interersections.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_summaries.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_topologic_functions.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_validationrules.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_wrij.py +0 -0
- {hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_wrij_profielen.py +0 -0
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
__author__ = ["Het Waterschapshuis", "D2HYDRO", "HKV", "HydroConsult"]
|
|
2
2
|
__copyright__ = "Copyright 2021, HyDAMO ValidatieTool"
|
|
3
3
|
__credits__ = ["D2HYDRO", "HKV", "HydroConsult"]
|
|
4
|
-
__version__ = "1.3.
|
|
4
|
+
__version__ = "1.3.0b4"
|
|
5
5
|
|
|
6
6
|
__license__ = "MIT"
|
|
7
7
|
__maintainer__ = "Daniel Tollenaar"
|
|
8
8
|
__email__ = "daniel@d2hydro.nl"
|
|
9
9
|
|
|
10
|
-
import fiona
|
|
10
|
+
import fiona # top-level import to avoid fiona import issue: https://github.com/conda-forge/fiona-feedstock/issues/213
|
|
11
|
+
from pathlib import Path
|
|
11
12
|
from hydamo_validation.functions import topologic as topologic_functions
|
|
12
13
|
from hydamo_validation.functions import logic as logic_functions
|
|
13
14
|
from hydamo_validation.functions import general as general_functions
|
|
@@ -19,4 +20,5 @@ __all__ = [
|
|
|
19
20
|
"logic_functions",
|
|
20
21
|
"general_functions",
|
|
21
22
|
"validator",
|
|
23
|
+
"SCHEMAS_PATH",
|
|
22
24
|
]
|
{hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/logical_validation.py
RENAMED
|
@@ -127,11 +127,14 @@ def execute(
|
|
|
127
127
|
for i in validation_rules_sets["objects"]
|
|
128
128
|
if i["object"] in datamodel.data_layers
|
|
129
129
|
)
|
|
130
|
+
logger.info(
|
|
131
|
+
rf"lagen met valide objecten én regels: {[i["object"] for i in object_rules_sets]}"
|
|
132
|
+
)
|
|
130
133
|
for object_rules in object_rules_sets:
|
|
131
134
|
col_translation: dict = {}
|
|
132
135
|
|
|
133
136
|
object_layer = object_rules["object"]
|
|
134
|
-
logger.info(f"
|
|
137
|
+
logger.info(f"{object_layer}: start")
|
|
135
138
|
object_gdf = getattr(datamodel, object_layer).copy()
|
|
136
139
|
|
|
137
140
|
# add summary columns
|
|
@@ -145,7 +148,7 @@ def execute(
|
|
|
145
148
|
general_rules_sorted = sorted(general_rules, key=lambda k: k["id"])
|
|
146
149
|
for rule in general_rules_sorted:
|
|
147
150
|
logger.info(
|
|
148
|
-
f"{object_layer}:
|
|
151
|
+
f"{object_layer}: uitvoeren general-rule met id {rule['id']}"
|
|
149
152
|
)
|
|
150
153
|
try:
|
|
151
154
|
result_variable = rule["result_variable"]
|
|
@@ -224,7 +227,7 @@ def execute(
|
|
|
224
227
|
try:
|
|
225
228
|
rule_id = rule["id"]
|
|
226
229
|
logger.info(
|
|
227
|
-
f"{object_layer}:
|
|
230
|
+
f"{object_layer}: uitvoeren validatieregel met id {rule_id} ({rule['name']})"
|
|
228
231
|
)
|
|
229
232
|
result_variable = rule["result_variable"]
|
|
230
233
|
if "exceptions" in rule.keys():
|
|
@@ -142,7 +142,7 @@ class LayersSummary:
|
|
|
142
142
|
gdf_out = gdf.copy()
|
|
143
143
|
if gdf_out.crs:
|
|
144
144
|
gdf_out.to_crs("epsg:4326", inplace=True)
|
|
145
|
-
gdf_out.to_file(file_path, driver="GeoJSON")
|
|
145
|
+
gdf_out.to_file(file_path, driver="GeoJSON", engine="pyogrio")
|
|
146
146
|
|
|
147
147
|
# drop geometry for writing to csv
|
|
148
148
|
elif output_type == "csv":
|
|
@@ -150,7 +150,7 @@ class LayersSummary:
|
|
|
150
150
|
output_type, f"{object_layer}.csv"
|
|
151
151
|
)
|
|
152
152
|
df = gdf.drop("geometry", axis=1)
|
|
153
|
-
df.to_csv(file_path)
|
|
153
|
+
df.to_csv(file_path, index=False)
|
|
154
154
|
|
|
155
155
|
# write to geopackage as is
|
|
156
156
|
elif output_type == "geopackage":
|
|
@@ -182,7 +182,7 @@ class ResultSummary:
|
|
|
182
182
|
self.error_layers = []
|
|
183
183
|
self.syntax_result = []
|
|
184
184
|
self.validation_result = []
|
|
185
|
-
self.error =
|
|
185
|
+
self.error = []
|
|
186
186
|
self.errors = None
|
|
187
187
|
self.warnings = None
|
|
188
188
|
|
|
@@ -23,7 +23,7 @@ import traceback
|
|
|
23
23
|
|
|
24
24
|
OUTPUT_TYPES = ["geopackage", "geojson", "csv"]
|
|
25
25
|
LOG_LEVELS = Literal["INFO", "DEBUG"]
|
|
26
|
-
INCLUDE_COLUMNS = ["code"]
|
|
26
|
+
INCLUDE_COLUMNS = ["nen3610id", "code"]
|
|
27
27
|
SCHEMAS_PATH = Path(__file__).parent.joinpath(r"./schemas")
|
|
28
28
|
HYDAMO_SCHEMAS_PATH = SCHEMAS_PATH.joinpath("hydamo")
|
|
29
29
|
RULES_SCHEMAS_PATH = SCHEMAS_PATH.joinpath("rules")
|
|
@@ -54,6 +54,13 @@ def _add_log_file(logger, log_file):
|
|
|
54
54
|
return logger
|
|
55
55
|
|
|
56
56
|
|
|
57
|
+
def _close_log_file(logger):
|
|
58
|
+
"""Remove log-file from existing logger"""
|
|
59
|
+
for h in logger.handlers:
|
|
60
|
+
h.close()
|
|
61
|
+
logger.removeHandler(h)
|
|
62
|
+
|
|
63
|
+
|
|
57
64
|
def _log_to_results(log_file, result_summary):
|
|
58
65
|
result_summary.log = log_file.read_text().split("\n")
|
|
59
66
|
|
|
@@ -180,28 +187,31 @@ def _validator(
|
|
|
180
187
|
log_level=log_level,
|
|
181
188
|
)
|
|
182
189
|
|
|
183
|
-
logger.info("
|
|
190
|
+
logger.info("init validatie")
|
|
184
191
|
date_check = pd.Timestamp.now().isoformat()
|
|
185
192
|
result_summary = ResultSummary(date_check=date_check)
|
|
186
193
|
layers_summary = LayersSummary(date_check=date_check)
|
|
187
194
|
# check if all files are present
|
|
188
195
|
# create a results_path
|
|
196
|
+
permission_error = False
|
|
189
197
|
if dir_path.exists():
|
|
190
198
|
results_path = dir_path.joinpath("results")
|
|
191
199
|
if results_path.exists():
|
|
192
200
|
try:
|
|
193
201
|
shutil.rmtree(results_path)
|
|
194
202
|
except PermissionError:
|
|
195
|
-
|
|
196
|
-
f"Cannot remove {results_path}. This may lead to write-issues later!"
|
|
197
|
-
)
|
|
198
|
-
pass
|
|
203
|
+
permission_error = True
|
|
199
204
|
results_path.mkdir(parents=True, exist_ok=True)
|
|
200
205
|
else:
|
|
201
206
|
raise FileNotFoundError(f"{dir_path.absolute().resolve()} does not exist")
|
|
202
207
|
|
|
203
208
|
log_file = results_path.joinpath("validator.log")
|
|
204
209
|
logger = _add_log_file(logger, log_file=log_file)
|
|
210
|
+
logger.info("start validatie")
|
|
211
|
+
if permission_error:
|
|
212
|
+
logger.warning(
|
|
213
|
+
f"Kan pad {results_path} niet verwijderen. Dit kan later tot problemen leiden!"
|
|
214
|
+
)
|
|
205
215
|
dataset_path = dir_path.joinpath("datasets")
|
|
206
216
|
validation_rules_json = dir_path.joinpath("validationrules.json")
|
|
207
217
|
missing_paths = []
|
|
@@ -209,11 +219,11 @@ def _validator(
|
|
|
209
219
|
if not path.exists():
|
|
210
220
|
missing_paths += [str(path)]
|
|
211
221
|
if missing_paths:
|
|
212
|
-
result_summary.error
|
|
222
|
+
result_summary.error += [f'missing_paths: {",".join(missing_paths)}']
|
|
213
223
|
raise FileNotFoundError(f'missing_paths: {",".join(missing_paths)}')
|
|
214
224
|
else:
|
|
215
225
|
validation_rules_sets = read_validation_rules(
|
|
216
|
-
validation_rules_json,
|
|
226
|
+
validation_rules_json, result_summary
|
|
217
227
|
)
|
|
218
228
|
|
|
219
229
|
# check if output-files are supported
|
|
@@ -224,7 +234,7 @@ def _validator(
|
|
|
224
234
|
error_message = (
|
|
225
235
|
r"unsupported output types: " f'{",".join(unsupported_output_types)}'
|
|
226
236
|
)
|
|
227
|
-
result_summary.error
|
|
237
|
+
result_summary.error += [error_message]
|
|
228
238
|
raise TypeError(error_message)
|
|
229
239
|
|
|
230
240
|
# set coverages
|
|
@@ -249,7 +259,7 @@ def _validator(
|
|
|
249
259
|
result_summary.dataset_layers = datasets.layers
|
|
250
260
|
|
|
251
261
|
## validate syntax of datasets on layers-level and append to result
|
|
252
|
-
logger.info("start syntax-
|
|
262
|
+
logger.info("start syntax-validatie van object-lagen")
|
|
253
263
|
valid_layers = datamodel_layers(datamodel.layers, datasets.layers)
|
|
254
264
|
result_summary.missing_layers = missing_layers(
|
|
255
265
|
datamodel.layers, datasets.layers
|
|
@@ -265,7 +275,7 @@ def _validator(
|
|
|
265
275
|
status_object = validation_rules_sets["status_object"]
|
|
266
276
|
|
|
267
277
|
for layer in valid_layers:
|
|
268
|
-
logger.info(f"
|
|
278
|
+
logger.info(f"{layer}: inlezen")
|
|
269
279
|
|
|
270
280
|
# read layer
|
|
271
281
|
gdf, schema = datasets.read_layer(
|
|
@@ -275,7 +285,7 @@ def _validator(
|
|
|
275
285
|
gdf.empty
|
|
276
286
|
): # pass if gdf is empty. Most likely due to mall-formed or ill-specifiec status_object
|
|
277
287
|
logger.warning(
|
|
278
|
-
f"
|
|
288
|
+
f"{layer}: geen objecten ingelezen. Zorg dat alle waarden in de kolom 'status_object' voorkomen in {status_object}"
|
|
279
289
|
)
|
|
280
290
|
continue
|
|
281
291
|
|
|
@@ -285,23 +295,28 @@ def _validator(
|
|
|
285
295
|
gdf[col] = None
|
|
286
296
|
schema["properties"][col] = "str"
|
|
287
297
|
|
|
288
|
-
logger.info(f"
|
|
298
|
+
logger.info(f"{layer}: syntax-validatie")
|
|
289
299
|
gdf, result_gdf = fields_syntax(
|
|
290
300
|
gdf,
|
|
291
|
-
schema,
|
|
292
|
-
datamodel.validation_schemas[layer],
|
|
301
|
+
schema=schema,
|
|
302
|
+
validation_schema=datamodel.validation_schemas[layer],
|
|
293
303
|
keep_columns=INCLUDE_COLUMNS,
|
|
294
304
|
)
|
|
295
305
|
|
|
296
306
|
# Add the syntax-validation result to the results_summary
|
|
297
307
|
layers_summary.set_data(result_gdf, layer, schema["geometry"])
|
|
298
308
|
# Add the corrected datasets_layer data to the datamodel.
|
|
299
|
-
|
|
309
|
+
if gdf.empty:
|
|
310
|
+
logger.warning(
|
|
311
|
+
f"{layer}: geen valide objecten na syntax-validatie. Inspecteer 'syntax_oordeel' in de resultaten; deze is false voor alle objecten. De laag zal genegeerd worden in de (topo)logische validatie."
|
|
312
|
+
)
|
|
313
|
+
else:
|
|
314
|
+
datamodel.set_data(gdf, layer, index_col=None)
|
|
300
315
|
syntax_result += [layer]
|
|
301
316
|
|
|
302
317
|
# do logical validation: append result to layers_summary
|
|
303
318
|
result_summary.status = "logical validation"
|
|
304
|
-
logger.info("start (topo)
|
|
319
|
+
logger.info("start (topo)logische validatie van object-lagen")
|
|
305
320
|
layers_summary, result_summary = logical_validation.execute(
|
|
306
321
|
datamodel,
|
|
307
322
|
validation_rules_sets,
|
|
@@ -312,7 +327,7 @@ def _validator(
|
|
|
312
327
|
)
|
|
313
328
|
|
|
314
329
|
# finish validation and export results
|
|
315
|
-
logger.info("
|
|
330
|
+
logger.info("exporteren resultaten")
|
|
316
331
|
result_summary.status = "export results"
|
|
317
332
|
result_layers = layers_summary.export(results_path, output_types)
|
|
318
333
|
result_summary.result_layers = result_layers
|
|
@@ -328,21 +343,21 @@ def _validator(
|
|
|
328
343
|
result_summary.success = True
|
|
329
344
|
result_summary.status = "finished"
|
|
330
345
|
result_summary.duration = timer.report()
|
|
331
|
-
logger.info(f"
|
|
346
|
+
logger.info(f"klaar in {result_summary.duration:.2f} seconden")
|
|
332
347
|
|
|
333
348
|
_log_to_results(log_file, result_summary)
|
|
334
349
|
result_summary.to_json(results_path)
|
|
335
350
|
|
|
351
|
+
_close_log_file(logger)
|
|
352
|
+
|
|
336
353
|
return datamodel, layers_summary, result_summary
|
|
337
354
|
|
|
338
355
|
except Exception as e:
|
|
339
|
-
|
|
340
|
-
e_str = " ".join(e_str.split())
|
|
341
|
-
stacktrace = rf"{traceback.format_exc(limit=2)}".split("\n")
|
|
356
|
+
stacktrace = rf"\n{traceback.format_exc(limit=0, chain=False)}".split("\n")
|
|
342
357
|
if result_summary.error is not None:
|
|
343
|
-
result_summary.error +=
|
|
358
|
+
result_summary.error += stacktrace
|
|
344
359
|
else:
|
|
345
|
-
result_summary.error =
|
|
360
|
+
result_summary.error = stacktrace
|
|
346
361
|
if results_path is not None:
|
|
347
362
|
result_layers = layers_summary.export(results_path, output_types)
|
|
348
363
|
_log_to_results(log_file, result_summary)
|
|
@@ -352,4 +367,6 @@ def _validator(
|
|
|
352
367
|
else:
|
|
353
368
|
result_summary.to_dict()
|
|
354
369
|
|
|
370
|
+
_close_log_file(logger)
|
|
371
|
+
|
|
355
372
|
return None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/functions/__init__.py
RENAMED
|
File without changes
|
{hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/functions/general.py
RENAMED
|
File without changes
|
{hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/functions/logic.py
RENAMED
|
File without changes
|
{hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/functions/topologic.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/styles/hydroobject.qml
RENAMED
|
File without changes
|
{hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/styles/hydroobject.sld
RENAMED
|
File without changes
|
|
File without changes
|
{hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation/syntax_validation.py
RENAMED
|
File without changes
|
|
File without changes
|
{hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation.egg-info/requires.txt
RENAMED
|
File without changes
|
{hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/hydamo_validation.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hydamo_validation-1.3.0b3 → hydamo_validation-1.3.0b4}/tests/test_structures_at_interersections.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|