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

TVB-2689: add summary_info to DataType indexes #139

Merged
merged 7 commits into from
May 8, 2020
17 changes: 17 additions & 0 deletions framework_tvb/tvb/core/entities/model/model_datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,23 @@ class DataType(HasTraitsIndex):
fk_from_operation = Column(Integer, ForeignKey('OPERATIONS.id', ondelete="CASCADE"))
parent_operation = relationship(Operation, backref=backref("DATA_TYPES", order_by=id, cascade="all,delete"))

def summary_info(self):
# type: () -> typing.Dict[str, str]

cls = type(self)
ret = {'Type': cls.__name__}
popaula937 marked this conversation as resolved.
Show resolved Hide resolved
if self.title:
ret['title'] = str(self.title)
popaula937 marked this conversation as resolved.
Show resolved Hide resolved

for attribute in cls.__dict__:
try:
attr_field = getattr(self, attribute)
if attr_field is not None:
popaula937 marked this conversation as resolved.
Show resolved Hide resolved
popaula937 marked this conversation as resolved.
Show resolved Hide resolved
ret[attribute] = attr_field
except Exception:
""
popaula937 marked this conversation as resolved.
Show resolved Hide resolved
return ret

def __init__(self, gid=None, **kwargs):

# if gid is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,4 @@ def fill_from_datatype(self, datatype_result, parent_burst):

### Populate Scientific attributes
if hasattr(datatype_result, 'summary_info') and datatype_result.summary_info is not None:
self.add_scientific_fields(datatype_result.summary_info)
self.add_scientific_fields(datatype_result.summary_info())
popaula937 marked this conversation as resolved.
Show resolved Hide resolved