Skip to content

Commit

Permalink
🎨 Auto fetch related names for Featureset (#188)
Browse files Browse the repository at this point in the history
🎨 Auto fetch related names
  • Loading branch information
sunnyosun authored Jun 8, 2023
1 parent c57a4ca commit accfebb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lnschema_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,12 @@ def from_iterable(
return features

def __init__(self, *args, **kwargs): # type: ignore
related_names = [i.related_name for i in self.__class__._meta.related_objects]

relationships: Dict = {}
if "genes" in kwargs:
relationships["genes"] = kwargs.pop("genes")
if "proteins" in kwargs:
relationships["proteins"] = kwargs.pop("proteins")
if "cell_markers" in kwargs:
relationships["cell_markers"] = kwargs.pop("cell_markers")
for related_name in related_names:
if related_name in kwargs:
relationships[related_name] = kwargs.pop(related_name)
self._relationships = relationships

super().__init__(*args, **kwargs)
Expand Down

0 comments on commit accfebb

Please sign in to comment.