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

Enh/schema validation attribute values #830

Merged
merged 13 commits into from
Dec 7, 2022

Conversation

MBueschelberger
Copy link
Member

@MBueschelberger MBueschelberger commented Nov 15, 2022

closes #828

New functionalities for checking the value and length (if it is string) or range (it is a float/int/bool) of a CUDS-attribute.

Please see the updated unittests as reference for this example:

city.Citizen:
    city.name:
        STRING:
            length: 1+
            cardinality: 1
    city.age:
        INT:
            range: 0+
            cardinality: 1

In the case of a string for an attribute, we can state what should be the length of a city.name. For all other types, we can specify the numerical range.

Here is an example of how to restrict a cuds with respect to a certain value, which is very useful for unittesting:

city.Citizen:
    city.name:
        STRING:
            value: peter
            cardinality: 1
    city.age:
        INT:
            value: 18
            cardinality: 1

Furthermore, the schema validation received an extra keyword-argument called strict_check which - as the name already says - triggers a strict check of the cuds during the validation. This basically means that the test fails when any extra cuds apart the ones listed in the schema-file are encountered while querying the root object.

Please note: This implementation is closely imitating what is supposed to be covered by any standardized markup-language such as SHACL. But due to lack of time in the use case, we could not really focus on integrating these languages into simphony-osp, because the effort for translating the schema file into the required shapes was too high.

@MBueschelberger
Copy link
Member Author

@kysrpex , there seems to be some problem with the sqlite-wrapper in the pipeline. I am not sure if this is related to the native sqlite3-package from python3.

@kysrpex kysrpex added 🌱 new feature Solving the issue involves the incorporation of a new feature. data model 📜 ontology labels Dec 6, 2022
@kysrpex kysrpex linked an issue Dec 6, 2022 that may be closed by this pull request
Copy link
Contributor

@kysrpex kysrpex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MBueschelberger,

I requested two very minor changes that you can automatically apply just clicking a button on GitHub, if you do it then the PR is good to go.

I am not very happy with the code (and foresee bugs) but this is strongly related to the fact that I am not happy with the original code either. I know that you are just plugging your feature into it and it seems reasonable to me, and the changes do not make things worse. Let's say that I would not be ready to document and promote the whole schema validation feature in its current state (neither was I ready before), but I think this PR is a net positive anyway.

osp/core/utils/schema_validation.py Outdated Show resolved Hide resolved
osp/core/utils/schema_validation.py Outdated Show resolved Hide resolved
MBueschelberger and others added 2 commits December 7, 2022 12:01
Co-authored-by: José Manuel Domínguez <43052541+kysrpex@users.noreply.github.com>
Co-authored-by: José Manuel Domínguez <43052541+kysrpex@users.noreply.github.com>
@MBueschelberger
Copy link
Member Author

MBueschelberger commented Dec 7, 2022

Why does the pipeline fail again after you merged dev into this branch at commit d3bc34e2b9ae9d5b88c7fa092ba2071f288fc45d? The pipeline for commit 1a42f0f6731014c43b8ebc2b4e81963f19a8cfe2 was successful but not for the following 15a168c3afcde72fd2094e89ce67afc234155aad? This is confusing

@kysrpex
Copy link
Contributor

kysrpex commented Dec 7, 2022

Why does the pipeline fail again after you merged dev into this branch at commit d3bc34e2b9ae9d5b88c7fa092ba2071f288fc45d? The pipeline for commit 1a42f0f6731014c43b8ebc2b4e81963f19a8cfe2 was successful but not for the following 15a168c3afcde72fd2094e89ce67afc234155aad? This is confusing

Good question honestly, I will try to find out.

@kysrpex kysrpex merged commit 3441c73 into dev Dec 7, 2022
@kysrpex kysrpex deleted the enh/schema-validation-attribute-values branch December 7, 2022 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data model 📜 ontology 🌱 new feature Solving the issue involves the incorporation of a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enh: add checking of attribute-values (=values of data properties)
2 participants