-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodel.py
More file actions
46 lines (38 loc) · 1.06 KB
/
model.py
File metadata and controls
46 lines (38 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Live coded tutorial / example from Charlie, how we could use Pydantic to model for schemas
from pydantic import BaseModel, Field
from curies import NamedReference
from curies.vocabulary import charlie
charlie = NamedReference(
prefix="orcid",
identifier="0000-0000-0000-000X",
name="Charlie Hoyt"
)
class LearningMaterial(BaseModel):
title: str
authors: list[Reference]
class LearningPathModule(BaseModel):
name: str
description: str | None
materials: list[LearningMaterial]
class LearningPath(BaseModel):
name: str
description: str | None = Field(
None,
description="This is where you describe the learning path"
)
course_code: str | None = None
modules: list[LearningPathModule]
example = LearningPath(
name="Introduction to Sequencing",
modules=[
LearningPathModule(
name="Getting Started",
materials=[
LearningMaterial(
name="Install Python",
authors=[charlie],
)
]
)
]
)