MCPcopy
hub / github.com/Textualize/rich / add_task

Method add_task

rich/progress.py:1600–1641  ·  view source on GitHub ↗

Add a new 'task' to the Progress display. Args: description (str): A description of the task. start (bool, optional): Start the task immediately (to calculate elapsed time). If set to False, you will need to call `start` manually. Defaults to True.

(
        self,
        description: str,
        start: bool = True,
        total: Optional[float] = 100.0,
        completed: int = 0,
        visible: bool = True,
        **fields: Any,
    )

Source from the content-addressed store, hash-verified

1598 return self.get_renderable()
1599
1600 def add_task(
1601 self,
1602 description: str,
1603 start: bool = True,
1604 total: Optional[float] = 100.0,
1605 completed: int = 0,
1606 visible: bool = True,
1607 **fields: Any,
1608 ) -> TaskID:
1609 """Add a new 'task' to the Progress display.
1610
1611 Args:
1612 description (str): A description of the task.
1613 start (bool, optional): Start the task immediately (to calculate elapsed time). If set to False,
1614 you will need to call `start` manually. Defaults to True.
1615 total (float, optional): Number of total steps in the progress if known.
1616 Set to None to render a pulsing animation. Defaults to 100.
1617 completed (int, optional): Number of steps completed so far. Defaults to 0.
1618 visible (bool, optional): Enable display of the task. Defaults to True.
1619 **fields (str): Additional data fields required for rendering.
1620
1621 Returns:
1622 TaskID: An ID you can use when calling `update`.
1623 """
1624 with self._lock:
1625 task = Task(
1626 self._task_index,
1627 description,
1628 total,
1629 completed,
1630 visible=visible,
1631 fields=fields,
1632 _get_time=self.get_time,
1633 _lock=self._lock,
1634 )
1635 self._tasks[self._task_index] = task
1636 if start:
1637 self.start_task(self._task_index)
1638 new_task_index = self._task_index
1639 self._task_index = TaskID(int(self._task_index) + 1)
1640 self.refresh()
1641 return new_task_index
1642
1643 def remove_task(self, task_id: TaskID) -> None:
1644 """Delete a task if it exists.

Callers 15

make_progressFunction · 0.95
test_expand_barFunction · 0.95
test_columnsFunction · 0.95
test_track_threadFunction · 0.95
test_resetFunction · 0.95
trackMethod · 0.95
wrap_fileMethod · 0.95
openMethod · 0.95
run_stepsFunction · 0.80

Calls 3

start_taskMethod · 0.95
refreshMethod · 0.95
TaskClass · 0.85

Tested by 8

make_progressFunction · 0.76
test_expand_barFunction · 0.76
test_columnsFunction · 0.76
test_track_threadFunction · 0.76
test_resetFunction · 0.76