Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add relationship between DFolder and DObject #110

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lnschema_core/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ class DFolder(SQLModel, table=True): # type: ignore

id: str = Field(default_factory=idg.dfolder, primary_key=True)
name: str = Field(index=True)
dobjects: List["DObject"] = Relationship( # type: ignore # noqa
back_populates="dfolders",
sa_relationship_kwargs=dict(secondary=DFolderDObject.__table__),
)
"""Collection of :class:`~lnschema_core.DObject`."""
created_by: str = CreatedBy
"""Auto-populated link to :class:`~lnschema_core.User`."""
created_at: datetime = CreatedAt
Expand Down Expand Up @@ -174,6 +179,11 @@ class DObject(SQLModel, table=True): # type: ignore
sa_relationship_kwargs=dict(secondary=DObjectFeatures.__table__),
)
"""Link to feature sets."""
dfolders: List[DFolder] = Relationship(
back_populates="dobjects",
sa_relationship_kwargs=dict(secondary=DFolderDObject.__table__),
)
"""Collection of :class:`~lnschema_core.DFolder` that contain this dobject."""
targets: List["lnschema_core._core.Run"] = Relationship( # type: ignore # noqa
back_populates="inputs",
sa_relationship_kwargs=dict(secondary=RunIn.__table__),
Expand Down