From 4af628faf0118478be184882d25572aa83266443 Mon Sep 17 00:00:00 2001 From: Thiago Costa Porto Date: Thu, 21 Sep 2023 17:35:29 +0100 Subject: [PATCH 1/3] fix: adds uploader to dataset/asset A contributor added with the role of "Uploader" is also added to the dataset and asset as the "uploader". --- .../syft/src/syft/service/dataset/dataset.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/syft/src/syft/service/dataset/dataset.py b/packages/syft/src/syft/service/dataset/dataset.py index e9da25cbb45..84856a9ce16 100644 --- a/packages/syft/src/syft/service/dataset/dataset.py +++ b/packages/syft/src/syft/service/dataset/dataset.py @@ -21,6 +21,7 @@ from result import Err from result import Ok from result import Result +from syft.service.user.roles import Roles # relative from ...serde.serializable import serializable @@ -154,11 +155,7 @@ def _repr_html_(self) -> Any: # relative from ...service.action.action_object import ActionObject - uploaded_by_line = "n/a" - if len(self.contributors) > 0: - uploaded_by_line = ( - f"

Uploaded by: {self.uploader.name}

" - ) + uploaded_by_line = f"

Uploaded by: {self.uploader.name} ({self.uploader.email})

" if self.uploader else "" if isinstance(self.data, ActionObject): data_table_line = itables.to_html_datatable( df=self.data.syft_action_data, css=itables_css @@ -336,6 +333,8 @@ def add_contributor( name=name, role=_role_str, email=email, phone=phone, note=note ) self.contributors.append(contributor) + if _role_str == Roles.UPLOADER.value: + self.uploader = contributor return SyftSuccess( message=f"Contributor '{name}' added to '{self.name}' Asset." ) @@ -451,12 +450,11 @@ def _coll_repr_(self) -> Dict[str, Any]: } def _repr_html_(self) -> Any: - uploaded_by_line = "n/a" - if len(self.contributors) > 0: - uploaded_by_line = ( + uploaded_by_line = ( "

" - + f"Uploaded by:{self.uploader.name}

" - ) + + f"Uploaded by:{self.uploader.name} ({self.uploader.email})

" + ) if self.uploader else "" + return f"""