metadata4Ing

metadata4Ing#

Metadata4Ing is an ontology developed within the NFDI Consortium NFDI4Ing “with the aim of providing a thorough framework for the semantic description of research data, with a particular focus on engineering sciences and neighbouring disciplines.”

The h5RDMtoolbox allows translating JSON-LD data into the HDF5 structure and wise versa (see here). This way, engineering process metadata can be added easily to the HDF5 file.

Consider the following example file taken from the m4i ontology “first steps guide”, which describes an experimental investigation. You can find the full content of the JSON-LD file here, the following shows an excerpt:

import h5rdmtoolbox as h5tbx
_ = h5tbx.set_config(auto_create_h5tbx_version=False)
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 import h5rdmtoolbox as h5tbx
      2 _ = h5tbx.set_config(auto_create_h5tbx_version=False)

File ~/checkouts/readthedocs.org/user_builds/h5rdmtoolbox/checkouts/v1.7.0/h5rdmtoolbox/__init__.py:129
    125     with File(src) as h5:
    126         return h5.dumps()
--> 129 from h5rdmtoolbox.wrapper.ld.hdf.file import get_ld as hdf_get_ld
    130 from h5rdmtoolbox.wrapper.ld.user.file import get_ld as user_get_ld
    133 def get_ld(
    134         hdf_filename: Union[str, pathlib.Path],
    135         structural: bool = True,
    136         semantic: bool = True,
    137         blank_node_iri_base: Optional[str] = None,
    138         **kwargs) -> rdflib.Graph:

File ~/checkouts/readthedocs.org/user_builds/h5rdmtoolbox/checkouts/v1.7.0/h5rdmtoolbox/wrapper/ld/__init__.py:1
----> 1 import ssnolib.ssno.standard_name
      2 from ontolutils.namespacelib import M4I
      3 from ontolutils.namespacelib import SCHEMA

ModuleNotFoundError: No module named 'ssnolib'

With a single call (h5tbx.jsonld.to_hdf) it is possible to read in the JSON-LD data and parse it into the HDF5 structure:

with h5tbx.File() as h5:
    h5.create_group('metadata')
    h5tbx.jsonld.to_hdf(h5.metadata, source='min_m4i_ex.jsonld')
    # h5.dump(collapsed=False)
print(h5tbx.serialize(h5.hdf_filename, format="ttl", structural=False))
print(
    h5tbx.serialize(
        h5.hdf_filename,
        format="ttl",
        structural=False,
        indent=2,
        context={"@import": "https://w3id.org/nfdi4ing/metadata4ing/m4i_context.jsonld"})
)