Skip to content

Commit f5445a4

Browse files
author
Vincent Moens
committed
[Doc] Solve ref issues in docstrings
ghstack-source-id: 09823fa Pull Request resolved: #2776
1 parent c2a149d commit f5445a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+281
-254
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ jobs:
112112
cd ./docs
113113
# timeout 7m bash -ic "MUJOCO_GL=egl sphinx-build ./source _local_build" || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi
114114
# bash -ic "PYOPENGL_PLATFORM=egl MUJOCO_GL=egl sphinx-build ./source _local_build" || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi
115-
PYOPENGL_PLATFORM=egl MUJOCO_GL=egl TORCHRL_CONSOLE_STREAM=stdout sphinx-build ./source _local_build
115+
PYOPENGL_PLATFORM=egl MUJOCO_GL=egl TORCHRL_CONSOLE_STREAM=stdout sphinx-build ./source _local_build -v
116116
cd ..
117117
118118
cp -r docs/_local_build/* "${RUNNER_ARTIFACT_DIR}"

docs/source/content_generation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ def generate_tutorial_references(tutorial_path: str, file_type: str) -> None:
8383
for f in os.listdir(tutorial_path)
8484
if f.endswith((".py", ".rst", ".png"))
8585
]
86+
# Make rb_tutorial.py the first one
87+
file_paths = [p for p in file_paths if p.endswith("rb_tutorial.py")] + [
88+
p for p in file_paths if not p.endswith("rb_tutorial.py")
89+
]
8690

8791
for file_path in file_paths:
8892
shutil.copyfile(file_path, os.path.join(target_path, Path(file_path).name))

docs/source/reference/envs.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ component (sub-environments or agents) should be reset.
212212
This allows to reset some but not all of the components.
213213

214214
The ``"_reset"`` key has two distinct functionalities:
215+
215216
1. During a call to :meth:`~.EnvBase._reset`, the ``"_reset"`` key may or may
216217
not be present in the input tensordict. TorchRL's convention is that the
217218
absence of the ``"_reset"`` key at a given ``"done"`` level indicates
@@ -899,7 +900,7 @@ to be able to create this other composition:
899900
Hash
900901
InitTracker
901902
KLRewardTransform
902-
LineariseReward
903+
LineariseRewards
903904
NoopResetEnv
904905
ObservationNorm
905906
ObservationTransform

torchrl/_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def reset(cls, setters_dict: Dict[str, implement_for] = None):
513513
"""Resets the setters in setter_dict.
514514
515515
``setter_dict`` is a copy of implementations. We just need to iterate through its
516-
values and call :meth:`~.module_set` for each.
516+
values and call :meth:`module_set` for each.
517517
518518
"""
519519
if VERBOSE:
@@ -888,7 +888,7 @@ def _standardize(
888888
exclude_dims (Tuple[int]): dimensions to exclude from the statistics, can be negative. Default: ().
889889
mean (Tensor): a mean to be used for standardization. Must be of shape broadcastable to input. Default: None.
890890
std (Tensor): a standard deviation to be used for standardization. Must be of shape broadcastable to input. Default: None.
891-
eps (float): epsilon to be used for numerical stability. Default: float32 resolution.
891+
eps (:obj:`float`): epsilon to be used for numerical stability. Default: float32 resolution.
892892
893893
"""
894894
if eps is None:

torchrl/collectors/collectors.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,12 @@ class SyncDataCollector(DataCollectorBase):
339339
instances) it will be wrapped in a `nn.Module` first.
340340
Then, the collector will try to assess if these
341341
modules require wrapping in a :class:`~tensordict.nn.TensorDictModule` or not.
342+
342343
- If the policy forward signature matches any of ``forward(self, tensordict)``,
343344
``forward(self, td)`` or ``forward(self, <anything>: TensorDictBase)`` (or
344345
any typing with a single argument typed as a subclass of ``TensorDictBase``)
345346
then the policy won't be wrapped in a :class:`~tensordict.nn.TensorDictModule`.
347+
346348
- In all other cases an attempt to wrap it will be undergone as such: ``TensorDictModule(policy, in_keys=env_obs_key, out_keys=env.action_keys)``.
347349
348350
Keyword Args:
@@ -1462,6 +1464,7 @@ class _MultiDataCollector(DataCollectorBase):
14621464
``forward(self, td)`` or ``forward(self, <anything>: TensorDictBase)`` (or
14631465
any typing with a single argument typed as a subclass of ``TensorDictBase``)
14641466
then the policy won't be wrapped in a :class:`~tensordict.nn.TensorDictModule`.
1467+
14651468
- In all other cases an attempt to wrap it will be undergone as such:
14661469
``TensorDictModule(policy, in_keys=env_obs_key, out_keys=env.action_keys)``.
14671470
@@ -1548,7 +1551,7 @@ class _MultiDataCollector(DataCollectorBase):
15481551
reset_when_done (bool, optional): if ``True`` (default), an environment
15491552
that return a ``True`` value in its ``"done"`` or ``"truncated"``
15501553
entry will be reset at the corresponding indices.
1551-
update_at_each_batch (boolm optional): if ``True``, :meth:`~.update_policy_weight_()`
1554+
update_at_each_batch (boolm optional): if ``True``, :meth:`update_policy_weight_()`
15521555
will be called before (sync) or after (async) each data collection.
15531556
Defaults to ``False``.
15541557
preemptive_threshold (:obj:`float`, optional): a value between 0.0 and 1.0 that specifies the ratio of workers
@@ -2774,10 +2777,12 @@ class aSyncDataCollector(MultiaSyncDataCollector):
27742777
instances) it will be wrapped in a `nn.Module` first.
27752778
Then, the collector will try to assess if these
27762779
modules require wrapping in a :class:`~tensordict.nn.TensorDictModule` or not.
2780+
27772781
- If the policy forward signature matches any of ``forward(self, tensordict)``,
27782782
``forward(self, td)`` or ``forward(self, <anything>: TensorDictBase)`` (or
27792783
any typing with a single argument typed as a subclass of ``TensorDictBase``)
27802784
then the policy won't be wrapped in a :class:`~tensordict.nn.TensorDictModule`.
2785+
27812786
- In all other cases an attempt to wrap it will be undergone as such: ``TensorDictModule(policy, in_keys=env_obs_key, out_keys=env.action_keys)``.
27822787
27832788
Keyword Args:
@@ -2863,7 +2868,7 @@ class aSyncDataCollector(MultiaSyncDataCollector):
28632868
reset_when_done (bool, optional): if ``True`` (default), an environment
28642869
that return a ``True`` value in its ``"done"`` or ``"truncated"``
28652870
entry will be reset at the corresponding indices.
2866-
update_at_each_batch (boolm optional): if ``True``, :meth:`~.update_policy_weight_()`
2871+
update_at_each_batch (boolm optional): if ``True``, :meth:`update_policy_weight_()`
28672872
will be called before (sync) or after (async) each data collection.
28682873
Defaults to ``False``.
28692874
preemptive_threshold (:obj:`float`, optional): a value between 0.0 and 1.0 that specifies the ratio of workers

torchrl/collectors/distributed/generic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,12 @@ class DistributedDataCollector(DataCollectorBase):
262262
instances) it will be wrapped in a `nn.Module` first.
263263
Then, the collector will try to assess if these
264264
modules require wrapping in a :class:`~tensordict.nn.TensorDictModule` or not.
265+
265266
- If the policy forward signature matches any of ``forward(self, tensordict)``,
266267
``forward(self, td)`` or ``forward(self, <anything>: TensorDictBase)`` (or
267268
any typing with a single argument typed as a subclass of ``TensorDictBase``)
268269
then the policy won't be wrapped in a :class:`~tensordict.nn.TensorDictModule`.
270+
269271
- In all other cases an attempt to wrap it will be undergone as such: ``TensorDictModule(policy, in_keys=env_obs_key, out_keys=env.action_keys)``.
270272
271273
Keyword Args:
@@ -341,7 +343,7 @@ class DistributedDataCollector(DataCollectorBase):
341343
collecting data. Must be one of ``torchrl.envs.utils.ExplorationType.DETERMINISTIC``,
342344
``torchrl.envs.utils.ExplorationType.RANDOM``, ``torchrl.envs.utils.ExplorationType.MODE``
343345
or ``torchrl.envs.utils.ExplorationType.MEAN``.
344-
collector_class (type or str, optional): a collector class for the remote node. Can be
346+
collector_class (Type or str, optional): a collector class for the remote node. Can be
345347
:class:`~torchrl.collectors.SyncDataCollector`,
346348
:class:`~torchrl.collectors.MultiSyncDataCollector`,
347349
:class:`~torchrl.collectors.MultiaSyncDataCollector`

torchrl/collectors/distributed/ray.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,12 @@ class RayCollector(DataCollectorBase):
135135
instances) it will be wrapped in a `nn.Module` first.
136136
Then, the collector will try to assess if these
137137
modules require wrapping in a :class:`~tensordict.nn.TensorDictModule` or not.
138+
138139
- If the policy forward signature matches any of ``forward(self, tensordict)``,
139140
``forward(self, td)`` or ``forward(self, <anything>: TensorDictBase)`` (or
140141
any typing with a single argument typed as a subclass of ``TensorDictBase``)
141142
then the policy won't be wrapped in a :class:`~tensordict.nn.TensorDictModule`.
143+
142144
- In all other cases an attempt to wrap it will be undergone as such: ``TensorDictModule(policy, in_keys=env_obs_key, out_keys=env.action_keys)``.
143145
144146
Keyword Args:

torchrl/collectors/distributed/rpc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,12 @@ class RPCDataCollector(DataCollectorBase):
110110
instances) it will be wrapped in a `nn.Module` first.
111111
Then, the collector will try to assess if these
112112
modules require wrapping in a :class:`~tensordict.nn.TensorDictModule` or not.
113+
113114
- If the policy forward signature matches any of ``forward(self, tensordict)``,
114115
``forward(self, td)`` or ``forward(self, <anything>: TensorDictBase)`` (or
115116
any typing with a single argument typed as a subclass of ``TensorDictBase``)
116117
then the policy won't be wrapped in a :class:`~tensordict.nn.TensorDictModule`.
118+
117119
- In all other cases an attempt to wrap it will be undergone as such: ``TensorDictModule(policy, in_keys=env_obs_key, out_keys=env.action_keys)``.
118120
119121
Keyword Args:
@@ -190,7 +192,7 @@ class RPCDataCollector(DataCollectorBase):
190192
``torchrl.envs.utils.ExplorationType.RANDOM``, ``torchrl.envs.utils.ExplorationType.MODE``
191193
or ``torchrl.envs.utils.ExplorationType.MEAN``.
192194
Defaults to ``torchrl.envs.utils.ExplorationType.RANDOM``.
193-
collector_class (type or str, optional): a collector class for the remote node. Can be
195+
collector_class (Type or str, optional): a collector class for the remote node. Can be
194196
:class:`~torchrl.collectors.SyncDataCollector`,
195197
:class:`~torchrl.collectors.MultiSyncDataCollector`,
196198
:class:`~torchrl.collectors.MultiaSyncDataCollector`

torchrl/collectors/distributed/sync.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,12 @@ class DistributedSyncDataCollector(DataCollectorBase):
143143
instances) it will be wrapped in a `nn.Module` first.
144144
Then, the collector will try to assess if these
145145
modules require wrapping in a :class:`~tensordict.nn.TensorDictModule` or not.
146+
146147
- If the policy forward signature matches any of ``forward(self, tensordict)``,
147148
``forward(self, td)`` or ``forward(self, <anything>: TensorDictBase)`` (or
148149
any typing with a single argument typed as a subclass of ``TensorDictBase``)
149150
then the policy won't be wrapped in a :class:`~tensordict.nn.TensorDictModule`.
151+
150152
- In all other cases an attempt to wrap it will be undergone as such: ``TensorDictModule(policy, in_keys=env_obs_key, out_keys=env.action_keys)``.
151153
152154
Keyword Args:
@@ -222,7 +224,7 @@ class DistributedSyncDataCollector(DataCollectorBase):
222224
collecting data. Must be one of ``torchrl.envs.utils.ExplorationType.DETERMINISTIC``,
223225
``torchrl.envs.utils.ExplorationType.RANDOM``, ``torchrl.envs.utils.ExplorationType.MODE``
224226
or ``torchrl.envs.utils.ExplorationType.MEAN``.
225-
collector_class (type or str, optional): a collector class for the remote node. Can be
227+
collector_class (Type or str, optional): a collector class for the remote node. Can be
226228
:class:`~torchrl.collectors.SyncDataCollector`,
227229
:class:`~torchrl.collectors.MultiSyncDataCollector`,
228230
:class:`~torchrl.collectors.MultiaSyncDataCollector`

torchrl/data/datasets/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def preprocess(
7272
7373
Args and Keyword Args are forwarded to :meth:`~tensordict.TensorDictBase.map`.
7474
75-
The dataset can subsequently be deleted using :meth:`~.delete`.
75+
The dataset can subsequently be deleted using :meth:`delete`.
7676
7777
Keyword Args:
7878
dest (path or equivalent): a path to the location of the new dataset.

0 commit comments

Comments
 (0)