-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
3 changed files
with
24 additions
and
14 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 |
---|---|---|
|
@@ -22,17 +22,17 @@ | |
{ | ||
"relation_type": "IS_PART_OF", | ||
"related_identifier": "https://example.org/collection", | ||
"datetime_log": "2024-02-19T00:00:00Z" | ||
"datetime_log": "2024-02-19T00:00:00+00:00" | ||
}, | ||
{ | ||
"relation_type": "IS_REFERENCED_BY", | ||
"related_identifier": "https://example.org/referenced", | ||
"datetime_log": "2024-02-19T00:00:00Z" | ||
"datetime_log": "2024-02-19T00:00:00+00:00" | ||
} | ||
], | ||
"change_log": [ | ||
{ | ||
"datetime_log": "2024-02-19T00:00:00Z", | ||
"datetime_log": "2024-02-19T00:00:00+00:00", | ||
"has_agent": { | ||
"name": "Data Fuzzi", | ||
"email": "[email protected]", | ||
|
@@ -44,7 +44,7 @@ | |
"description": "Registration completed." | ||
}, | ||
{ | ||
"datetime_log": "2024-05-15T15:51:15Z", | ||
"datetime_log": "2024-05-15T15:51:15+00:00", | ||
"has_agent": { | ||
"name": "Data Fuzzi", | ||
"email": "[email protected]", | ||
|
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,8 +1,13 @@ | ||
import sys | ||
from datetime import datetime | ||
from linkml_runtime.dumpers import json_dumper | ||
from pid4cat_model.datamodel import pid4cat_model as p4c | ||
|
||
# Demonstrate the use of Python DataClass-based model | ||
|
||
if sys.version_info < (3, 11): | ||
raise RuntimeError("Python 3.11 or higher is required due to the use of datetime.fromisoformat") | ||
|
||
p1_Agent = p4c.Agent( | ||
name="Data Fuzzi", | ||
email="[email protected]", | ||
|
@@ -15,12 +20,12 @@ | |
p4c.PID4CatRelation( | ||
relation_type=p4c.RelationType.IS_PART_OF, | ||
related_identifier="https://example.org/collection", | ||
datetime_log="2024-02-19T00:00:00Z", | ||
datetime_log=datetime.fromisoformat("2024-02-19T00:00:00Z"), | ||
), | ||
p4c.PID4CatRelation( | ||
relation_type=p4c.RelationType.IS_REFERENCED_BY, | ||
related_identifier="https://example.org/referenced", | ||
datetime_log="2024-02-19T00:00:00Z", | ||
datetime_log=datetime.fromisoformat("2024-02-19T00:00:00Z"), | ||
), | ||
] | ||
|
||
|
@@ -43,13 +48,13 @@ | |
|
||
p1_log = [ | ||
p4c.LogRecord( | ||
datetime_log="2024-02-19T00:00:00Z", | ||
datetime_log=datetime.fromisoformat("2024-02-19T00:00:00Z"), | ||
has_agent=p1_Agent, | ||
changed_field=p4c.ChangeLogField.STATUS, | ||
description="Registration completed.", | ||
), | ||
p4c.LogRecord( | ||
datetime_log="2024-05-15T15:51:15Z", | ||
datetime_log=datetime.fromisoformat("2024-05-15T15:51:15Z"), | ||
has_agent=p1_Agent, | ||
changed_field=p4c.ChangeLogField.RESOURCE_INFO, | ||
description="as requested in issue #234", | ||
|
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,9 +1,14 @@ | ||
import sys | ||
from datetime import datetime | ||
from pathlib import Path | ||
from linkml_runtime.dumpers import json_dumper, yaml_dumper | ||
from pid4cat_model.datamodel import pid4cat_model_pydantic as p4c | ||
|
||
# Demonstrate the use of Pydantic models | ||
|
||
if sys.version_info < (3, 11): | ||
raise RuntimeError("Python 3.11 or higher is required due to the use of datetime.fromisoformat") | ||
|
||
p1_Agent = p4c.Agent( | ||
name="Data Fuzzi", | ||
email="[email protected]", | ||
|
@@ -16,12 +21,12 @@ | |
p4c.PID4CatRelation( | ||
relation_type=p4c.RelationType.IS_PART_OF, | ||
related_identifier="https://example.org/collection", | ||
datetime_log="2024-02-19T00:00:00Z", | ||
datetime_log=datetime.fromisoformat("2024-02-19T00:00:00Z"), | ||
), | ||
p4c.PID4CatRelation( | ||
relation_type=p4c.RelationType.IS_REFERENCED_BY, | ||
related_identifier="https://example.org/referenced", | ||
datetime_log="2024-02-19T00:00:00Z", | ||
datetime_log=datetime.fromisoformat("2024-02-19T00:00:00Z"), | ||
), | ||
] | ||
|
||
|
@@ -44,13 +49,13 @@ | |
|
||
p1_log = [ | ||
p4c.LogRecord( | ||
datetime_log="2024-02-19T00:00:00Z", | ||
datetime_log=datetime.fromisoformat("2024-02-19T00:00:00Z"), | ||
has_agent=p1_Agent, | ||
changed_field=p4c.ChangeLogField.STATUS, | ||
description="Registration completed.", | ||
), | ||
p4c.LogRecord( | ||
datetime_log="2024-05-15T15:51:15Z", | ||
datetime_log=datetime.fromisoformat("2024-05-15T15:51:15Z"), | ||
has_agent=p1_Agent, | ||
changed_field=p4c.ChangeLogField.RESOURCE_INFO, | ||
description="as requested in issue #234", | ||
|
@@ -73,12 +78,12 @@ | |
|
||
print(p1) | ||
|
||
print(yaml_dumper.dumps(c)) | ||
|
||
print(json_dumper.dumps(p1)) | ||
|
||
# write json to file | ||
script_folder = Path(__file__).parent | ||
|
||
with open(script_folder / "example_p1.json", "w", encoding="utf-8") as f: | ||
f.write(json_dumper.dumps(p1)) | ||
|
||
print(yaml_dumper.dumps(c)) |