Skip to content

Commit

Permalink
[FileStore] Updating Docs to Reflect FileStore changes (pytorch#49557)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#49557

Updating the PyTorch docs to reflect that FileStore now supported the
num_keys API. Also included a note to describe the behavior of the API.

Test Plan: build and rendered docs.

Reviewed By: jiayisuse

Differential Revision: D25619000

fbshipit-source-id: 6c660d7ceb32d1d61024df8394aff3fcd0b752c1
  • Loading branch information
osalpekar authored and hwangdeyu committed Dec 23, 2020
1 parent 1c90741 commit 9611cf3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions torch/csrc/distributed/c10d/init.cpp
Expand Up @@ -480,15 +480,14 @@ and :meth:`~torch.distributed.store.add` since one key is used to coordinate all
the workers using the store.
.. warning::
The ``num_keys`` API is only supported by the :class:`~torch.distributed.TCPStore` and :class:`~torch.distributed.HashStore`. Using this API
with the :class:`~torch.distributed.FileStore` will result in an exception.
When used with the :class:`~torch.distributed.TCPStore`, ``num_keys`` returns the number of keys written to the underlying file. If the store is destructed and another store is created with the same file, the original keys will be retained.
Returns:
The number of keys present in the store.
Example::
>>> import torch.distributed as dist
>>> # Using TCPStore as an example, HashStore can also be used
>>> # Using TCPStore as an example, other store types can also be used
>>> store = dist.TCPStore("127.0.0.1", 0, True, timedelta(seconds=30))
>>> store.set("first_key", "first_value")
>>> # This should return 2
Expand Down

0 comments on commit 9611cf3

Please sign in to comment.