-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a802ead
commit 70f555b
Showing
2 changed files
with
23 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |