-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #3130.
- Loading branch information
Showing
15 changed files
with
283 additions
and
80 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
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
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
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
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
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
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
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
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
23 changes: 21 additions & 2 deletions
23
components/shared_code/src/shared_data_model/meta/subject.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,11 +1,30 @@ | ||
"""Data model subject.""" | ||
|
||
from pydantic import Field | ||
from __future__ import annotations | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
from .base import DescribedModel | ||
|
||
|
||
class Subject(DescribedModel): | ||
class SubjectContainer(BaseModel): | ||
"""Base model for subject containers.""" | ||
|
||
subjects: dict[str, Subject] = Field(default_factory=dict) | ||
|
||
@property | ||
def all_subjects(self) -> dict[str, Subject]: | ||
"""Return all subjects, recursively.""" | ||
all_subjects = {**self.subjects} | ||
for subject in self.subjects.values(): | ||
all_subjects.update(**subject.all_subjects) | ||
return all_subjects | ||
|
||
|
||
class Subject(SubjectContainer, DescribedModel): | ||
"""Base model for subjects.""" | ||
|
||
metrics: list[str] = Field(..., min_length=1) | ||
|
||
|
||
SubjectContainer.model_rebuild() |
Oops, something went wrong.