Skip to content

Commit

Permalink
Fixed documentation for ResourceMetricCollector.clear() method
Browse files Browse the repository at this point in the history
  • Loading branch information
MyGodItsFull0fStars committed Jul 22, 2024
1 parent 51f08cd commit 83a2d0b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions nvitop/api/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class ResourceMetricCollector: # pylint: disable=too-many-instance-attributes
collector.activate(tag='<tag>') # alias: start
collector.deactivate() # alias: stop
collector.reset(tag='<tag>')
collector.clear(tag='<tag>')
collector.collect()
with collector(tag='<tag>'):
Expand Down Expand Up @@ -539,14 +539,14 @@ def context(self, tag: str) -> Generator[ResourceMetricCollector, None, None]:
__call__ = context # alias for `with collector(tag='<tag>')`

def clear(self, tag: str | None = None) -> None:
"""Reset the metric collection with the given tag.
"""Clear the metric collection with the given tag.
If the tag is not specified, reset the current active collection. For nested collections,
the sub-collections will be reset as well.
If the tag is not specified, clear the current active collection. For nested collections,
the sub-collections will be cleared as well.
Args:
tag (Optional[str]):
The tag to reset. If :data:`None`, the current active collection will be reset.
The tag to clear. If :data:`None`, the current active collection will be reset.
Examples:
>>> collector = ResourceMetricCollector()
Expand All @@ -558,12 +558,12 @@ def clear(self, tag: str | None = None) -> None:
... time.sleep(5.0)
... collector.collect() # metrics within the cumulative 10.0s interval
...
... collector.reset() # reset the active collection
... collector.clear() # clear the active collection
... time.sleep(5.0)
... collector.collect() # metrics within the 5.0s interval
...
... with collector(tag='batch'): # key prefix -> 'train/batch'
... collector.reset(tag='train') # reset both 'train' and 'train/batch'
... collector.clear(tag='train') # clear both 'train' and 'train/batch'
"""
with self._lock:
if self._metric_buffer is None:
Expand Down

0 comments on commit 83a2d0b

Please sign in to comment.