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

Fix data set validation when a logger is supplied #188

Merged
merged 1 commit into from
Jan 15, 2025
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

The `pycldf` package adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased

- Fixed issue where validator reports invalid data sets as valid if a logger is supplied

## [1.40.3] - 2025-01-03

Expand Down
11 changes: 7 additions & 4 deletions src/pycldf/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,8 +1002,8 @@ def validate(
try:
table = self[dtable_uri]
except KeyError:
log_or_raise('{0} requires {1}'.format(self.module, dtable_uri), log=log)
success = False
log_or_raise('{0} requires {1}'.format(self.module, dtable_uri), log=log)
table = None

if table:
Expand All @@ -1016,8 +1016,8 @@ def validate(
if c.propertyUrl}
table_uri = table.common_props['dc:conformsTo']
for col in required_default_cols - set(cols.keys()):
log_or_raise('{0} requires column {1}'.format(table_uri, col), log=log)
success = False
log_or_raise('{0} requires column {1}'.format(table_uri, col), log=log)
for uri, col in cols.items():
default = default_cols.get(uri)
if default:
Expand All @@ -1026,6 +1026,7 @@ def validate(
cardinality = terms.by_uri[uri].cardinality
if (cardinality == 'multivalued' and not col.separator) or \
(cardinality == 'singlevalued' and col.separator):
success = False
log_or_raise('{} {} must be {}'.format(
table_uri, uri, cardinality), log=log)

Expand Down Expand Up @@ -1060,6 +1061,7 @@ def validate(
validators_, propertyUrls, colnames = [], set(), set()
for col in table.tableSchema.columns:
if col.header in colnames: # pragma: no cover
success = False
log_or_raise(
'Duplicate column name in table schema: {} {}'.format(
table.url, col.header),
Expand All @@ -1070,6 +1072,7 @@ def validate(
try:
terms.is_cldf_uri(col_uri)
if col_uri in propertyUrls: # pragma: no cover
success = False
log_or_raise(
'Duplicate CLDF property in table schema: {} {}'.format(
table.url, col_uri),
Expand All @@ -1094,15 +1097,15 @@ def validate(
try:
validate(self, table, col, row)
except ValueError as e:
success = False
log_or_raise(
'{0}:{1}:{2} {3}'.format(fname.name, lineno, col.name, e),
log=log)
success = False
if not table.check_primary_key(log=log):
success = False
else:
log_or_raise('{0} does not exist'.format(fname), log=log)
success = False
log_or_raise('{0} does not exist'.format(fname), log=log)

if not self.tablegroup.check_referential_integrity(log=log):
success = False
Expand Down
Loading