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 HTML Repr for ProcessInterface Class and all its subclasses #5181

Merged
merged 22 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
46 changes: 46 additions & 0 deletions distributed/deploy/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,52 @@ async def finished(self):
def __repr__(self):
return f"<{type(self).__name__}: status={self.status}>"

def _repr_html_(self):
freyam marked this conversation as resolved.
Show resolved Hide resolved
if self.status == Status.created:
status = "Created"
bg_color = "#caf0f8"
border_color = "#48cae4"
elif self.status == Status.running:
status = "Running"
bg_color = "#c7f9cc"
border_color = "#78c6a3"
elif self.status == Status.closed:
status = "Closed"
bg_color = "#ffbfad"
border_color = "#ff6132"

html = f"""
<div>
<div
style="
width: 24px;
height: 24px;
background-color: {bg_color};
border: 3px solid {border_color};
border-radius: 5px;
position: absolute;"
></div>
<div style="margin-left: 48px">
<h3 style="margin-bottom: 0px">{self.__class__.__name__}</h3>
<p style="color: #9d9d9d; margin-bottom: 0px">Status: {status}</p>
</div>
<p>
<table style="width: 100%">
<tr>
<th style="text-align: left; width: 150px">Address</th>
<td style="text-align: left">{self.address}</td>
</tr>
<tr>
<th style="text-align: left; width: 150px">External Address</th>
<td style="text-align: left">{self.external_address}</td>
</tr>
</table> </p>
</div>
</div>
"""

return html

async def __aenter__(self):
await self
return self
Expand Down
15 changes: 15 additions & 0 deletions distributed/deploy/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ async def close(self):
def __repr__(self):
return f"<SSH {type(self).__name__}: status={self.status}>"

def _repr_html_(self):
return super()._repr_html_()
jacobtomlinson marked this conversation as resolved.
Show resolved Hide resolved


class Worker(Process):
"""A Remote Dask Worker controled by SSH
Expand Down Expand Up @@ -139,6 +142,12 @@ async def start(self):
logger.debug("%s", line)
await super().start()

def __repr__(self):
return f"<SSH {type(self).__name__}: status={self.status}>"

jacobtomlinson marked this conversation as resolved.
Show resolved Hide resolved
def _repr_html_(self):
return super()._repr_html_()


class Scheduler(Process):
"""A Remote Dask Scheduler controlled by SSH
Expand Down Expand Up @@ -215,6 +224,12 @@ async def start(self):
logger.debug("%s", line)
await super().start()

def __repr__(self):
return f"<SSH {type(self).__name__}: status={self.status}>"

freyam marked this conversation as resolved.
Show resolved Hide resolved
def _repr_html_(self):
return super()._repr_html_()
jacobtomlinson marked this conversation as resolved.
Show resolved Hide resolved


old_cluster_kwargs = {
"scheduler_addr",
Expand Down