|
1 | 1 | import asyncio
|
| 2 | +import html |
2 | 3 | import inspect
|
3 | 4 | import itertools
|
4 | 5 | import json
|
@@ -732,13 +733,22 @@ def clean(self):
|
732 | 733 | return ws
|
733 | 734 |
|
734 | 735 | def __repr__(self):
|
735 |
| - return "<Worker %r, name: %s, memory: %d, processing: %d>" % ( |
| 736 | + return "<WorkerState %r, name: %s, memory: %d, processing: %d>" % ( |
736 | 737 | self._address,
|
737 | 738 | self._name,
|
738 | 739 | len(self._has_what),
|
739 | 740 | len(self._processing),
|
740 | 741 | )
|
741 | 742 |
|
| 743 | + def _repr_html_(self): |
| 744 | + text = ( |
| 745 | + f"<b>WorkerState: </b> {html.escape(self._address)} " |
| 746 | + f'<font style="color: var(--jp-ui-font-color2, gray)">name: </font>{self.name} ' |
| 747 | + f'<font style="color: var(--jp-ui-font-color2, gray)">memory: </font>{len(self._has_what)} ' |
| 748 | + f'<font style="color: var(--jp-ui-font-color2, gray)">processing: </font>{len(self._processing)}' |
| 749 | + ) |
| 750 | + return text |
| 751 | + |
742 | 752 | @ccall
|
743 | 753 | @exceptval(check=False)
|
744 | 754 | def identity(self) -> dict:
|
@@ -1549,7 +1559,19 @@ def set_nbytes(self, nbytes: Py_ssize_t):
|
1549 | 1559 | self._nbytes = nbytes
|
1550 | 1560 |
|
1551 | 1561 | def __repr__(self):
|
1552 |
| - return "<Task %r %s>" % (self._key, self._state) |
| 1562 | + return "<TaskState %r %s>" % (self._key, self._state) |
| 1563 | + |
| 1564 | + def _repr_html_(self): |
| 1565 | + color = ( |
| 1566 | + "var(--jp-error-color0, red)" |
| 1567 | + if self._state == "erred" |
| 1568 | + else "var(--jp-ui-font-color0, black)" |
| 1569 | + ) |
| 1570 | + text = f'<b>TaskState: </b> <font style="color: {color}">{self._state} </font>' |
| 1571 | + if self._state == "memory": |
| 1572 | + text += f'<font style="color: var(--jp-ui-font-color2, gray)">nbytes: </font>{format_bytes(self._nbytes)} ' |
| 1573 | + text += f'<font style="color: var(--jp-ui-font-color2, gray)">key: </font>{html.escape(self._key)}' |
| 1574 | + return text |
1553 | 1575 |
|
1554 | 1576 | @ccall
|
1555 | 1577 | def validate(self):
|
@@ -3579,11 +3601,22 @@ def __init__(
|
3579 | 3601 |
|
3580 | 3602 | def __repr__(self):
|
3581 | 3603 | parent: SchedulerState = cast(SchedulerState, self)
|
3582 |
| - return '<Scheduler: "%s" processes: %d cores: %d>' % ( |
| 3604 | + return '<Scheduler: "%s" workers: %d cores: %d, tasks: %d>' % ( |
3583 | 3605 | self.address,
|
3584 | 3606 | len(parent._workers),
|
3585 | 3607 | parent._total_nthreads,
|
| 3608 | + len(parent._tasks), |
| 3609 | + ) |
| 3610 | + |
| 3611 | + def _repr_html_(self): |
| 3612 | + parent: SchedulerState = cast(SchedulerState, self) |
| 3613 | + text = ( |
| 3614 | + f"<b>Scheduler: </b>{html.escape(self.address)} " |
| 3615 | + f'<font color="gray">workers: </font>{len(parent._workers)} ' |
| 3616 | + f'<font color="gray">cores: </font>{parent._total_nthreads} ' |
| 3617 | + f'<font color="gray">tasks: </font>{len(parent._tasks)}' |
3586 | 3618 | )
|
| 3619 | + return text |
3587 | 3620 |
|
3588 | 3621 | def identity(self, comm=None):
|
3589 | 3622 | """ Basic information about ourselves and our cluster """
|
|
0 commit comments