From 225c76b2880fc936f984f049ac780a33b5a6fdd5 Mon Sep 17 00:00:00 2001 From: Carlos Mocholi Date: Sat, 6 Mar 2021 14:06:17 +0100 Subject: [PATCH 1/5] Use f-"""-string --- pytorch_lightning/trainer/trainer.py | 41 +++++++++++++++------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index cc1964f07039b..6bf00b2b5e31b 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -449,25 +449,28 @@ def fit( # ---------------------------- # INSPECT THE CORE LOOPS # ---------------------------- - # Lightning internal flow looks like this. - # - # trainer.fit(...) or trainer.test(...) or trainer.predict(...) || - # | || - # create accelerator || - # | || - # trainer.dispatch || LIGHTNING - # | || - # start_training or start_evaluating or start_predicting call || FLOW - # from `accelerator` || - # | || DIRECTION - # run_train or run_evaluate or run_predict call || - # from `trainer` || - # | || - # results \/ - # This is used to guide readers to the core loops: train, test, predict. - # `run_predict` is the simplest to understand, use `Go to Definition` to read it :) - # Search for `start_training` or `start_evaluating` or `start_predicting` in - # `pytorch_lightning/plugins/training_type` folder to find accelerator dispatch functions. + f""" + Lightning internal flow looks like this. || + {self.fit} or {self.test} or {self.predict} || + | || + create accelerator || + | || + {self.dispatch} || + | || LIGHTNING + {self.accelerator.start_training} or || FLOW + {self.accelerator.start_evaluating} or || DIRECTION + {self.accelerator.start_predicting} || + | || + {self.run_train} or || + {self.run_evaluation} or || + {self.run_predict} || + | || + results \/ + This is used to guide readers to the core loops: train, test, predict. + {self.run_predict} is the simplest to understand, use `Go to Definition` to read it :) + Search for `start_training` or `start_evaluating` or `start_predicting` in + `pytorch_lightning/plugins/training_type_plugin` to find accelerator dispatch functions. + """ # ---------------------------- # TRAIN From bfb6366e79f770d793cd469fc3b7789c667ed8ac Mon Sep 17 00:00:00 2001 From: Carlos Mocholi Date: Sat, 6 Mar 2021 14:22:50 +0100 Subject: [PATCH 2/5] Add r --- pytorch_lightning/trainer/trainer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index 6bf00b2b5e31b..ab6a4a922d5b4 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -449,7 +449,7 @@ def fit( # ---------------------------- # INSPECT THE CORE LOOPS # ---------------------------- - f""" + rf""" Lightning internal flow looks like this. || {self.fit} or {self.test} or {self.predict} || | || From 05aa312a0b4eed6ea7bd1dfc5fd9d7287e3cc4a2 Mon Sep 17 00:00:00 2001 From: Carlos Mocholi Date: Sat, 6 Mar 2021 14:25:39 +0100 Subject: [PATCH 3/5] Use Trainer. --- pytorch_lightning/trainer/trainer.py | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index ab6a4a922d5b4..8521bc3a77859 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -450,22 +450,22 @@ def fit( # INSPECT THE CORE LOOPS # ---------------------------- rf""" - Lightning internal flow looks like this. || - {self.fit} or {self.test} or {self.predict} || - | || - create accelerator || - | || - {self.dispatch} || - | || LIGHTNING - {self.accelerator.start_training} or || FLOW - {self.accelerator.start_evaluating} or || DIRECTION - {self.accelerator.start_predicting} || - | || - {self.run_train} or || - {self.run_evaluation} or || - {self.run_predict} || - | || - results \/ + Lightning internal flow looks like this: + {Trainer.fit} or {Trainer.test} or {Trainer.predict} || + | || + create accelerator || + | || + {self.dispatch} || + | || LIGHTNING + {self.accelerator.start_training} or || FLOW + {self.accelerator.start_evaluating} or || DIRECTION + {self.accelerator.start_predicting} || + | || + {self.run_train} or || + {self.run_evaluation} or || + {self.run_predict} || + | || + results \/ This is used to guide readers to the core loops: train, test, predict. {self.run_predict} is the simplest to understand, use `Go to Definition` to read it :) Search for `start_training` or `start_evaluating` or `start_predicting` in From 9bd303b6df96a6c7fdfe0b99b88c94b1af319ddc Mon Sep 17 00:00:00 2001 From: Carlos Mocholi Date: Sat, 6 Mar 2021 14:29:56 +0100 Subject: [PATCH 4/5] r -> noqa: W605 --- pytorch_lightning/trainer/trainer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index 8521bc3a77859..612762c0a49e9 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -449,7 +449,7 @@ def fit( # ---------------------------- # INSPECT THE CORE LOOPS # ---------------------------- - rf""" + f""" Lightning internal flow looks like this: {Trainer.fit} or {Trainer.test} or {Trainer.predict} || | || @@ -470,7 +470,7 @@ def fit( {self.run_predict} is the simplest to understand, use `Go to Definition` to read it :) Search for `start_training` or `start_evaluating` or `start_predicting` in `pytorch_lightning/plugins/training_type_plugin` to find accelerator dispatch functions. - """ + """ # noqa: W605 # ---------------------------- # TRAIN From 4e815ce08693e58fba47ab121e866ea18575969c Mon Sep 17 00:00:00 2001 From: Carlos Mocholi Date: Sat, 6 Mar 2021 14:32:18 +0100 Subject: [PATCH 5/5] Move y label --- pytorch_lightning/trainer/trainer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index 612762c0a49e9..07e422d777ab2 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -457,10 +457,10 @@ def fit( | || {self.dispatch} || | || LIGHTNING - {self.accelerator.start_training} or || FLOW - {self.accelerator.start_evaluating} or || DIRECTION + {self.accelerator.start_training} or || + {self.accelerator.start_evaluating} or || FLOW {self.accelerator.start_predicting} || - | || + | || DIRECTION {self.run_train} or || {self.run_evaluation} or || {self.run_predict} ||