Skip to content

Commit a8a6a5b

Browse files
committed
Rename loops/base.py to loops/loop.py (Lightning-AI#13043)
1 parent 5a5b616 commit a8a6a5b

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

docs/source/extensions/loops.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ The core research logic is simply shifted to the :class:`~pytorch_lightning.core
8181
loss.backward()
8282
optimizer.step()
8383
84-
Under the hood, the above loop is implemented using the :class:`~pytorch_lightning.loops.base.Loop` API like so:
84+
Under the hood, the above loop is implemented using the :class:`~pytorch_lightning.loops.loop.Loop` API like so:
8585

8686
.. code-block:: python
8787
@@ -183,7 +183,7 @@ Now your code is FULLY flexible and you can still leverage ALL the best parts of
183183
Creating a New Loop From Scratch
184184
--------------------------------
185185

186-
You can also go wild and implement a full loop from scratch by sub-classing the :class:`~pytorch_lightning.loops.base.Loop` base class.
186+
You can also go wild and implement a full loop from scratch by sub-classing the :class:`~pytorch_lightning.loops.loop.Loop` base class.
187187
You will need to override a minimum of two things:
188188

189189
.. code-block:: python
@@ -222,7 +222,7 @@ Loop API
222222
--------
223223
Here is the full API of methods available in the Loop base class.
224224

225-
The :class:`~pytorch_lightning.loops.base.Loop` class is the base of all loops in the same way as the :class:`~pytorch_lightning.core.module.LightningModule` is the base of all models.
225+
The :class:`~pytorch_lightning.loops.loop.Loop` class is the base of all loops in the same way as the :class:`~pytorch_lightning.core.module.LightningModule` is the base of all models.
226226
It defines a public interface that each loop implementation must follow, the key ones are:
227227

228228
Properties
@@ -231,13 +231,13 @@ Properties
231231
done
232232
~~~~
233233

234-
.. autoattribute:: pytorch_lightning.loops.base.Loop.done
234+
.. autoattribute:: pytorch_lightning.loops.loop.Loop.done
235235
:noindex:
236236

237237
skip (optional)
238238
~~~~~~~~~~~~~~~
239239

240-
.. autoattribute:: pytorch_lightning.loops.base.Loop.skip
240+
.. autoattribute:: pytorch_lightning.loops.loop.Loop.skip
241241
:noindex:
242242

243243
Methods
@@ -246,19 +246,19 @@ Methods
246246
reset (optional)
247247
~~~~~~~~~~~~~~~~
248248

249-
.. automethod:: pytorch_lightning.loops.base.Loop.reset
249+
.. automethod:: pytorch_lightning.loops.loop.Loop.reset
250250
:noindex:
251251

252252
advance
253253
~~~~~~~
254254

255-
.. automethod:: pytorch_lightning.loops.base.Loop.advance
255+
.. automethod:: pytorch_lightning.loops.loop.Loop.advance
256256
:noindex:
257257

258258
run (optional)
259259
~~~~~~~~~~~~~~
260260

261-
.. automethod:: pytorch_lightning.loops.base.Loop.run
261+
.. automethod:: pytorch_lightning.loops.loop.Loop.run
262262
:noindex:
263263

264264

@@ -267,7 +267,7 @@ run (optional)
267267
Subloops
268268
--------
269269

270-
When you want to customize nested loops within loops, use the :meth:`~pytorch_lightning.loops.base.Loop.replace` method:
270+
When you want to customize nested loops within loops, use the :meth:`~pytorch_lightning.loops.loop.Loop.replace` method:
271271

272272
.. code-block:: python
273273
@@ -276,7 +276,7 @@ When you want to customize nested loops within loops, use the :meth:`~pytorch_li
276276
# Trainer runs the fit loop with your new epoch loop!
277277
trainer.fit(model)
278278
279-
Alternatively, for more fine-grained control, use the :meth:`~pytorch_lightning.loops.base.Loop.connect` method:
279+
Alternatively, for more fine-grained control, use the :meth:`~pytorch_lightning.loops.loop.Loop.connect` method:
280280

281281
.. code-block:: python
282282
@@ -326,7 +326,7 @@ Here is what the structure would look like in plain Python:
326326
...
327327
328328
329-
Each of these :code:`for`-loops represents a class implementing the :class:`~pytorch_lightning.loops.base.Loop` interface.
329+
Each of these :code:`for`-loops represents a class implementing the :class:`~pytorch_lightning.loops.loop.Loop` interface.
330330

331331

332332
.. list-table:: Trainer entry points and associated loops

docs/source/extensions/loops_advanced.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ A powerful property of the class-based loop interface is that it can own an inte
1818
Loop instances can save their state to the checkpoint through corresponding hooks and if implemented accordingly, resume the state of execution at the appropriate place.
1919
This design is particularly interesting for fault-tolerant training which is an experimental feature released in Lightning v1.5.
2020

21-
The two hooks :meth:`~pytorch_lightning.loops.base.Loop.on_save_checkpoint` and :meth:`~pytorch_lightning.loops.base.Loop.on_load_checkpoint` function very similarly to how LightningModules and Callbacks save and load state.
21+
The two hooks :meth:`~pytorch_lightning.loops.loop.Loop.on_save_checkpoint` and :meth:`~pytorch_lightning.loops.loop.Loop.on_load_checkpoint` function very similarly to how LightningModules and Callbacks save and load state.
2222

2323
.. code-block:: python
2424
@@ -30,9 +30,9 @@ The two hooks :meth:`~pytorch_lightning.loops.base.Loop.on_save_checkpoint` and
3030
def on_load_checkpoint(self, state_dict):
3131
self.iteration = state_dict["iteration"]
3232
33-
When the Trainer is restarting from a checkpoint (e.g., through :code:`trainer.fit(ckpt_path=...)`), the loop exposes a boolean attribute :attr:`~pytorch_lightning.loops.base.Loop.restarting`.
33+
When the Trainer is restarting from a checkpoint (e.g., through :code:`trainer.fit(ckpt_path=...)`), the loop exposes a boolean attribute :attr:`~pytorch_lightning.loops.loop.Loop.restarting`.
3434
Based around the value of this variable, the user can write the loop in such a way that it can restart from an arbitrary point given the state loaded from the checkpoint.
35-
For example, the implementation of the :meth:`~pytorch_lightning.loops.base.Loop.reset` method could look like this given our previous example:
35+
For example, the implementation of the :meth:`~pytorch_lightning.loops.loop.Loop.reset` method could look like this given our previous example:
3636

3737
.. code-block:: python
3838

pl_examples/loop_examples/kfold.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
from pl_examples.basic_examples.mnist_examples.image_classifier_4_lightning_module import ImageClassifier
3232
from pytorch_lightning import LightningDataModule, seed_everything, Trainer
3333
from pytorch_lightning.core.module import LightningModule
34-
from pytorch_lightning.loops.base import Loop
3534
from pytorch_lightning.loops.fit_loop import FitLoop
35+
from pytorch_lightning.loops.loop import Loop
3636
from pytorch_lightning.trainer.states import TrainerFn
3737

3838
#############################################################################################

pytorch_lightning/loops/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from pytorch_lightning.loops.base import Loop # noqa: F401
1615
from pytorch_lightning.loops.batch import ManualOptimization # noqa: F401
1716
from pytorch_lightning.loops.batch import TrainingBatchLoop # noqa: F401
1817
from pytorch_lightning.loops.dataloader import DataLoaderLoop, EvaluationLoop, PredictionLoop # noqa: F401
1918
from pytorch_lightning.loops.epoch import EvaluationEpochLoop, PredictionEpochLoop, TrainingEpochLoop # noqa: F401
2019
from pytorch_lightning.loops.fit_loop import FitLoop # noqa: F401
20+
from pytorch_lightning.loops.loop import Loop # noqa: F401
2121
from pytorch_lightning.loops.optimization.optimizer_loop import OptimizerLoop # noqa: F401

pytorch_lightning/loops/batch/training_batch_loop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from torch import Tensor
1717

18-
from pytorch_lightning.loops.base import Loop
18+
from pytorch_lightning.loops.loop import Loop
1919
from pytorch_lightning.loops.optimization.manual_loop import _OUTPUTS_TYPE as _MANUAL_LOOP_OUTPUTS_TYPE
2020
from pytorch_lightning.loops.optimization.manual_loop import ManualOptimization
2121
from pytorch_lightning.loops.optimization.optimizer_loop import _OUTPUTS_TYPE as _OPTIMIZER_LOOP_OUTPUTS_TYPE

pytorch_lightning/loops/dataloader/dataloader_loop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from torch.utils.data import DataLoader
1919

20-
from pytorch_lightning.loops.base import Loop
20+
from pytorch_lightning.loops.loop import Loop
2121
from pytorch_lightning.trainer.progress import DataLoaderProgress
2222

2323

pytorch_lightning/loops/epoch/evaluation_epoch_loop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from deprecate import void
2020
from torch.utils.data import DataLoader
2121

22-
from pytorch_lightning.loops.base import Loop
22+
from pytorch_lightning.loops.loop import Loop
2323
from pytorch_lightning.trainer.progress import BatchProgress
2424
from pytorch_lightning.trainer.states import TrainerFn
2525
from pytorch_lightning.trainer.supporters import CombinedLoader

pytorch_lightning/loops/epoch/prediction_epoch_loop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import torch
55
from deprecate import void
66

7-
from pytorch_lightning.loops.base import Loop
7+
from pytorch_lightning.loops.loop import Loop
88
from pytorch_lightning.overrides.distributed import IndexBatchSamplerWrapper
99
from pytorch_lightning.trainer.progress import Progress
1010
from pytorch_lightning.utilities.apply_func import move_data_to_device
File renamed without changes.

0 commit comments

Comments
 (0)