Skip to content

Commit

Permalink
fix: adds uploader to dataset/asset
Browse files Browse the repository at this point in the history
A contributor added with the role of "Uploader" is also added to the
dataset and asset as the "uploader".
  • Loading branch information
tcp committed Sep 21, 2023
1 parent bdec003 commit abc1f90
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/syft/src/syft/service/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"<p><strong>Uploaded by: </strong>{self.uploader.name}</p>"
)
uploaded_by_line = f"<p><strong>Uploaded by: </strong>{self.uploader.name} ({self.uploader.email})</p>" 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
Expand Down Expand Up @@ -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."
)
Expand Down Expand Up @@ -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 = (
"<p class='paragraph-sm'><strong>"
+ f"<span class='pr-8'>Uploaded by:</span></strong>{self.uploader.name}</p>"
)
+ f"<span class='pr-8'>Uploaded by:</span></strong>{self.uploader.name} ({self.uploader.email})</p>"
) if self.uploader else ""

return f"""
<style>
{fonts_css}
Expand Down Expand Up @@ -620,6 +618,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}' Dataset."
)
Expand Down

0 comments on commit abc1f90

Please sign in to comment.