Skip to content

Commit

Permalink
Updated readme and main script
Browse files Browse the repository at this point in the history
  • Loading branch information
jesper-friis committed Aug 14, 2023
1 parent a802ead commit 70f555b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
11 changes: 9 additions & 2 deletions examples/datamodel_as_rdf/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Datamodels as RDF
=================
This example will show how DLite and Pydantic data models can be serialised to RDF.
This example will show how DLite and Pydantic data models can be
serialised to RDF.

The example requires that you have Pydantic v1.x installed.
Two examples are included:
- **pydantic_nested**: Shows serialisation of nested pydantic models into RDF.
Works for both Pydantic v1 and v2.
- **dataresource**: Shows serialisation of a Pydantic model of a OTEAPI
dataresource to RDF. This example has two versions, one for Pydantic v1
([dataresource.py](dataresource.py)) and one for Pydantic v2
([dataresource_pydantic2.py](dataresource_pydantic2.py)).
16 changes: 14 additions & 2 deletions examples/datamodel_as_rdf/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
"""Main script running all tests in this repo."""
import pydantic_nested
import dataresource
import pydantic


pydantic_major = int(pydantic.__version__.split(".")[0])

# Run examples
import pydantic_nested # works for both Pydantic v1 and v2

if pydantic_major == 1:
# Only Pydantic v1
import dataresource
elif pydantic_major == 2:
# Only Pydantic v2
import dataresource_pydantic2

0 comments on commit 70f555b

Please sign in to comment.