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

15 define and store a generic example with nested structure #17

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

cmclscourtney
Copy link
Collaborator

@francescalb @jesper-friis @sygout

Adding example generic cuds object with a nested structure. I would love to get your insight into how this could be improved but could be good to have this to aim towards in testing the conversion.

@cmclscourtney cmclscourtney added the enhancement New feature or request label Aug 23, 2023
@cmclscourtney cmclscourtney self-assigned this Aug 23, 2023
@cmclscourtney cmclscourtney linked an issue Aug 23, 2023 that may be closed by this pull request
@jesper-friis
Copy link

jesper-friis commented Sep 10, 2023

@francescalb @jesper-friis @sygout

Adding example generic cuds object with a nested structure. I would love to get your insight into how this could be improved but could be good to have this to aim towards in testing the conversion.

@cmclscourtney, @francescalb, @sygout
I took the liberty to push to your branch. I hope it is ok with you. I added:

  • docs/figs/dlite_cuds.svg; A figure with a possible suggestion for a design of this package.
  • Some straight forward datamodels in the example/ directory for the TypeOne, TypeTwo and TypeThree classes (as json). These data models represents the data properties, but not inheritance.
  • example/instances.json: a serialisation of a collection representing the data in example_ABox.ttl. The function of the object properties is not clear to me, but for now I added them to the collection.
  • example/mkcoll.py: small script for generating the collection.

My suggestion would be that this library provides three functions:

def from_cuds_metadata(ts: Triplestore, iri: str, uri: str, conf: Mapping = None) -> dlite.Metadata:
    """Creates a DLite data model from CUDS stored in triplestore. 

    By default are all data property restrictions directly translated into DLite properties of corresponding type and object properties translated into reference properties.

    Arguments:
        ts: Reference to triplestore.
        iri: IRI of CUDS class to represent as a DLite data model.
        uri: URI of the new DLite metadata.
        conf: A mapping for customisation of the created data model.

    Returns:
        New DLite Metadata.
"""

def from_cuds(ts: Triplestore, iri: str, metaid: str, coll: dlite.Collection = None, label: str = None) -> dlite.Instance:
    """Creates a DLite instance from CUDS individuals stored in triplestore. 

    Arguments:
        ts: Reference to triplestore.
        iri: IRI of CUDS individual to represent as a DLite data model.
        metaid: URI or UUID or DLite data model to instantiate.
        coll: If provided, the new instance together with some relations will be added to this collection.
        label: Label assigned to the new instance in the collection.

    Returns:
        Reference to new instance.
    """

def to_cuds(ts: Triplestore, inst: dlite.Instance, coll: dlite.Collection = None, conf: Mapping = None) -> None:
    """Store CUDS individuals representing a DLite instance to a triplestore. 

    Arguments:
        ts: Reference to triplestore.
        inst: IRI of CUDS individual to represent as a DLite data model.
        coll: Collection to fetch additional relations from needed to create the CUDS.
        conf: Optional additional instructions for creating the CUDS.  (Needed??)
    """

The interesting question is in the details in how to do the conversion.

@cmclscourtney, does the CUDS ontology and A-box example you added to the examples/ folder contain all the complexity you need?
Is it generally true that the object properties are not included in the class restrictions, but only used in the A-box?

@francescalb francescalb marked this pull request as ready for review October 16, 2023 11:34
@francescalb
Copy link
Collaborator

Sorry! I made this ready-for -review by mistake. And I do not see where to revert that :(

@francescalb francescalb marked this pull request as draft October 16, 2023 11:35
@cmclscourtney
Copy link
Collaborator Author

cmclscourtney commented Nov 13, 2023

@jesper-friis,
Regarding the infrastructural diagram I don't know I fully understand it but generally like the idea of those methods.

I'm not sure I fully understand your question either but I think the answer is yes. You can see the MoDS ontolgy here. I did intend for that example to be sufficiently general. I believe the structure you are referring to with the restictions on the properties is inherent to SimPhoNy.

@francescalb
Copy link
Collaborator

@cmclscourtney , With the updated implementation we can now convert between the files you have provided. Please let us know if this is sufficient for your needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define and store a generic example with nested structure
3 participants