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

v2.3.0 #72

Merged
merged 2 commits into from
Dec 1, 2024
Merged

v2.3.0 #72

merged 2 commits into from
Dec 1, 2024

Conversation

MBueschelberger
Copy link
Member

@MBueschelberger MBueschelberger commented Nov 27, 2024

With this PR, we will be able to:

  • also allow strings as value types in quantity graphs, but raise a warning if it cannot be converted into float or int
  • add alias choices for several field names
  • fix the behaviour if the retrieved value from the mapping is None or np.nan
  • also allow quantity graphs / property graph in the mappings in case of custom relations.

In the following, you will find a test sceanrion in case of an quantity graph / property graph in the custom relations mapping.

The data may look like this:

data = {
    "data": [
        {
            "name": "specimen_1",
            "youngs_modulus": 100,
            "material": "material_1",
        },
        {
            "name": "specimen_2",
            "youngs_modulus": "200-300", # note this cannot be converted into float/int
            "material": "material_2",
        },
    ]
}

The mapping looks like this

mapping = [
    {
        "iri": "https://w3id.org/steel/ProcessOntology/Specimen",
        "suffix": "name",
        "source": "data[*]",
        "suffix_from_location": True,
        "custom_relations": [
            {
                "object_location": "youngs_modulus",
                "relation": "https://w3id.org/steel/ProcessOntology/hasYoungsModulus",
                "object_type": {
                    "iri": "https://w3id.org/steel/ProcessOntology/YoungsModulus",
                    "unit": "GPa",
                },
            },
            {
                "object_location": "material",
                "relation": "https://w3id.org/steel/ProcessOntology/hasMaterial",
                "object_type": {
                    "iri": "https://w3id.org/steel/ProcessOntology/Material",
                    "value_relation": "https://w3id.org/steel/ProcessOntology/hasIdentifier",
                },
            },
            {
                "object_location": "name",
                "relation": "https://w3id.org/steel/ProcessOntology/hasIdentifier",
            },
        ],
    }
]

The expected graph will look like this:

@prefix ns1: <https://w3id.org/steel/ProcessOntology/> .
@prefix ns2: <http://qudt.org/schema/qudt/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix: ex: <https://example.org#> .

ex:specimen_1 a ns1:Specimen ;
    ns1:hasIdentifier "specimen_1"^^xsd:string ;
    ns1:hasMaterial ex:Material_specimen_1 ;
    ns1:hasYoungsModulus ex:YoungsModulus_specimen_1 .

ex:specimen_2 a ns1:Specimen ;
    ns1:hasIdentifier "specimen_2"^^xsd:string ;
    ns1:hasMaterial ex:Material_specimen_2 ;
    ns1:hasYoungsModulus ex:YoungsModulus_specimen_2 .

ex:Material_specimen_1 a ns1:Material ;
    ns1:hasIdentifier "material_1"^^xsd:string .

ex:Material_specimen_2 a ns1:Material ;
    ns1:hasIdentifier "material_2"^^xsd:string .

ex:YoungsModulus_specimen_1 a ns1:YoungsModulus ;
    ns2:hasUnit "http://qudt.org/vocab/unit/GigaPA"^^xsd:anyURI ;
    ns2:value 100 .

ex:YoungsModulus_specimen_2 a ns1:YoungsModulus ;
    ns2:hasUnit "http://qudt.org/vocab/unit/GigaPA"^^xsd:anyURI ;
    ns2:value "200-300"^^xsd:string .

Copy link
Contributor

github-actions bot commented Dec 1, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
data2rdf
   __init__.py50100% 
   config.py2611 96%
   utils.py811 88%
   warnings.py20100% 
data2rdf/models
   __init__.py30100% 
   base.py5455 91%
   graph.py11677 94%
   mapping.py4511 98%
   utils.py581414 76%
data2rdf/modes
   __init__.py40100% 
data2rdf/parsers
   __init__.py60100% 
   base.py1351111 92%
   csv.py1682020 88%
   excel.py1831717 91%
   json.py2163737 83%
   utils.py901010 89%
data2rdf/pipelines
   __init__.py20100% 
   main.py8299 89%
data2rdf/qudt
   __init__.py00100% 
   utils.py421212 71%
TOTAL124514588% 

Tests Skipped Failures Errors Time
120 0 💤 0 ❌ 0 🔥 2m 57s ⏱️

@MBueschelberger MBueschelberger changed the title let the custom relations have their own subgraph and allow string daatypes for quantity graphs v2.3.0 Dec 1, 2024
@MBueschelberger MBueschelberger merged commit 4d4079a into main Dec 1, 2024
10 checks passed
@MBueschelberger MBueschelberger deleted the dev/additional-subgraphs branch December 1, 2024 17:43
MBueschelberger added a commit that referenced this pull request Dec 1, 2024
This reverts commit 4d4079a.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants