diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a70120ed72..7e3d63abce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace @@ -49,33 +49,33 @@ repos: - id: detect-private-key - repo: https://github.com/asottile/pyupgrade - rev: v2.34.0 + rev: v3.3.1 hooks: - id: pyupgrade args: [--py37-plus] name: Upgrade code - - repo: https://github.com/myint/docformatter + - repo: https://github.com/PyCQA/docformatter rev: v1.4 hooks: - id: docformatter args: [--in-place, --wrap-summaries=115, --wrap-descriptions=120] - repo: https://github.com/asottile/yesqa - rev: v1.3.0 + rev: v1.4.0 hooks: - id: yesqa name: Unused noqa - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.11.4 hooks: - id: isort name: Format imports exclude: docs/source-app - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 22.12.0 hooks: - id: black name: Format code @@ -90,7 +90,7 @@ repos: exclude: docs/source-app - repo: https://github.com/executablebooks/mdformat - rev: 0.7.14 + rev: 0.7.16 hooks: - id: mdformat additional_dependencies: diff --git a/docs/source-app/code_samples/quickstart/hello_world/app.py b/docs/source-app/code_samples/quickstart/hello_world/app.py index 07a764cb98..94ac255461 100644 --- a/docs/source-app/code_samples/quickstart/hello_world/app.py +++ b/docs/source-app/code_samples/quickstart/hello_world/app.py @@ -3,7 +3,6 @@ import lightning as L # Step 1: Subclass LightningFlow component to define the app flow. class HelloWorld(L.LightningFlow): - # Step 2: Add the app logic to the LightningFlow run method to # ``print("Hello World!")`. # The LightningApp executes the run method of the main LightningFlow diff --git a/docs/source-app/code_samples/quickstart/hello_world/app_ui.py b/docs/source-app/code_samples/quickstart/hello_world/app_ui.py index 8ed669d81f..67fa6aab3f 100644 --- a/docs/source-app/code_samples/quickstart/hello_world/app_ui.py +++ b/docs/source-app/code_samples/quickstart/hello_world/app_ui.py @@ -32,7 +32,6 @@ def render_fn(state: AppState): # Step 4: Implement a Static Web Frontend. This could be react, vue, etc. class UIStatic(L.LightningFlow): - # Step 5: def configure_layout(self): return StaticWebFrontend(os.path.join(os.path.dirname(__file__), "ui")) diff --git a/docs/source-app/examples/dag/dag_from_scratch.rst b/docs/source-app/examples/dag/dag_from_scratch.rst index 4af39f1af7..ccf5f98df5 100644 --- a/docs/source-app/examples/dag/dag_from_scratch.rst +++ b/docs/source-app/examples/dag/dag_from_scratch.rst @@ -36,12 +36,12 @@ First, let's define the component we need: * A collection of model work to train all models in parallel. .. literalinclude:: ../../../examples/app_dag/app.py - :lines: 55-79 + :lines: 53-75 And its run method executes the steps described above. .. literalinclude:: ../../../examples/app_dag/app.py - :lines: 80-103 + :lines: 77-100 ---- @@ -50,4 +50,4 @@ Step 2: Define the scheduling ***************************** .. literalinclude:: ../../../examples/app_dag/app.py - :lines: 106-135 + :lines: 103-132 diff --git a/docs/source-app/examples/file_server/app.py b/docs/source-app/examples/file_server/app.py index cfc72a70b3..46a74efa41 100644 --- a/docs/source-app/examples/file_server/app.py +++ b/docs/source-app/examples/file_server/app.py @@ -90,7 +90,7 @@ class FileServer(L.LightningWork): "size": full_size, "drive_path": uploaded_file, } - with open(self.get_filepath(meta_file), "wt") as f: + with open(self.get_filepath(meta_file), "w") as f: json.dump(meta, f) # 5: Put the file to the drive. @@ -163,7 +163,6 @@ from lightning import LightningWork class TestFileServer(LightningWork): - def __init__(self, drive: Drive): super().__init__(cache_calls=True) self.drive = drive @@ -188,7 +187,6 @@ from lightning import LightningApp, LightningFlow class Flow(LightningFlow): - def __init__(self): super().__init__() # 1: Create a drive to share data between works diff --git a/docs/source-app/examples/github_repo_runner/app.py b/docs/source-app/examples/github_repo_runner/app.py index 70e20ac380..486055f7a8 100644 --- a/docs/source-app/examples/github_repo_runner/app.py +++ b/docs/source-app/examples/github_repo_runner/app.py @@ -73,7 +73,6 @@ class GithubRepoRunner(TracerPythonScript): class PyTorchLightningGithubRepoRunner(GithubRepoRunner): - def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.best_model_path = None diff --git a/docs/source-app/examples/model_server_app/model_server.py b/docs/source-app/examples/model_server_app/model_server.py index bdfbff3cf2..8562c63d8c 100644 --- a/docs/source-app/examples/model_server_app/model_server.py +++ b/docs/source-app/examples/model_server_app/model_server.py @@ -8,7 +8,6 @@ from lightning.app.storage import Path class MLServer(LightningWork): - """This components uses SeldonIO MLServer library. The model endpoint: /v2/models/{MODEL_NAME}/versions/{VERSION}/infer. diff --git a/docs/source-app/examples/model_server_app/train.py b/docs/source-app/examples/model_server_app/train.py index f3342b9f24..698e0d889c 100644 --- a/docs/source-app/examples/model_server_app/train.py +++ b/docs/source-app/examples/model_server_app/train.py @@ -7,7 +7,6 @@ from lightning.app.storage import Path class TrainModel(LightningWork): - """This component trains a Sklearn SVC model on digits dataset.""" def __init__(self): diff --git a/docs/source-app/workflows/add_web_ui/dash/intermediate_plot.py b/docs/source-app/workflows/add_web_ui/dash/intermediate_plot.py index 177a84219a..4d8733b561 100644 --- a/docs/source-app/workflows/add_web_ui/dash/intermediate_plot.py +++ b/docs/source-app/workflows/add_web_ui/dash/intermediate_plot.py @@ -15,7 +15,6 @@ class LitDash(L.LightningWork): self.selected_year = None def run(self): - df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv") self.df = Payload(df) diff --git a/docs/source-app/workflows/build_command_line_interface/app.py b/docs/source-app/workflows/build_command_line_interface/app.py index f6a398096b..e5abeee07e 100644 --- a/docs/source-app/workflows/build_command_line_interface/app.py +++ b/docs/source-app/workflows/build_command_line_interface/app.py @@ -6,7 +6,6 @@ from lightning.app.structures import Dict class Flow(L.LightningFlow): - def __init__(self): super().__init__() self.notebooks = Dict() diff --git a/docs/source-app/workflows/build_command_line_interface/commands/notebook/run.py b/docs/source-app/workflows/build_command_line_interface/commands/notebook/run.py index a44e6bfa4f..e0a6463c2d 100644 --- a/docs/source-app/workflows/build_command_line_interface/commands/notebook/run.py +++ b/docs/source-app/workflows/build_command_line_interface/commands/notebook/run.py @@ -12,7 +12,6 @@ class RunNotebookConfig(BaseModel): class RunNotebook(ClientCommand): - description = "Run a Notebook." def run(self): diff --git a/docs/source-app/workflows/build_command_line_interface/post_example.py b/docs/source-app/workflows/build_command_line_interface/post_example.py index c7f87f1cff..4597b3d990 100644 --- a/docs/source-app/workflows/build_command_line_interface/post_example.py +++ b/docs/source-app/workflows/build_command_line_interface/post_example.py @@ -3,7 +3,6 @@ from lightning.app.api import Post class Flow(L.LightningFlow): - # 1. Define the state def __init__(self): super().__init__() diff --git a/docs/source-app/workflows/build_rest_api/post_example.py b/docs/source-app/workflows/build_rest_api/post_example.py index 4a306f176e..0ba24058a8 100644 --- a/docs/source-app/workflows/build_rest_api/post_example.py +++ b/docs/source-app/workflows/build_rest_api/post_example.py @@ -3,7 +3,6 @@ from lightning.app.api import Post class Flow(L.LightningFlow): - # 1. Define the state def __init__(self): super().__init__() diff --git a/docs/source-app/workflows/build_rest_api/post_example_pydantic.py b/docs/source-app/workflows/build_rest_api/post_example_pydantic.py index e3c16ca35d..f32dc3f308 100644 --- a/docs/source-app/workflows/build_rest_api/post_example_pydantic.py +++ b/docs/source-app/workflows/build_rest_api/post_example_pydantic.py @@ -5,7 +5,6 @@ from lightning.app.api import Post class Flow(L.LightningFlow): - # 1. Define the state def __init__(self): super().__init__() diff --git a/examples/app_commands_and_api/command.py b/examples/app_commands_and_api/command.py index 94f54d7e91..96d3f677c2 100644 --- a/examples/app_commands_and_api/command.py +++ b/examples/app_commands_and_api/command.py @@ -10,7 +10,6 @@ class CustomConfig(BaseModel): class CustomCommand(ClientCommand): - description = "A command with a client." def run(self): diff --git a/examples/app_components/python/component_tracer.py b/examples/app_components/python/component_tracer.py index 11354490e5..8eeeaa88fd 100644 --- a/examples/app_components/python/component_tracer.py +++ b/examples/app_components/python/component_tracer.py @@ -5,7 +5,6 @@ from pytorch_lightning import Trainer class PLTracerPythonScript(TracerPythonScript): - """This component can be used for ANY PyTorch Lightning script to track its progress and extract its best model path.""" diff --git a/examples/app_components/serve/gradio/app.py b/examples/app_components/serve/gradio/app.py index b0ac325f4d..b0f81bf26c 100644 --- a/examples/app_components/serve/gradio/app.py +++ b/examples/app_components/serve/gradio/app.py @@ -12,7 +12,6 @@ from lightning.app.components import ServeGradio # Credit to @akhaliq for his inspiring work. # Find his original code there: https://huggingface.co/spaces/akhaliq/AnimeGANv2/blob/main/app.py class AnimeGANv2UI(ServeGradio): - inputs = gr.inputs.Image(type="pil") outputs = gr.outputs.Image(type="pil") elon = "https://upload.wikimedia.org/wikipedia/commons/3/34/Elon_Musk_Royal_Society_%28crop2%29.jpg" diff --git a/examples/app_dag/app.py b/examples/app_dag/app.py index 531e390284..578c47c0b3 100644 --- a/examples/app_dag/app.py +++ b/examples/app_dag/app.py @@ -17,7 +17,6 @@ def get_path(path): class GetDataWork(L.LightningWork): - """This component is responsible to download some data and store them with a PayLoad.""" def __init__(self): @@ -34,7 +33,6 @@ class GetDataWork(L.LightningWork): class ModelWork(L.LightningWork): - """This component is receiving some data and train a sklearn model.""" def __init__(self, model_path: str, parallel: bool): @@ -53,7 +51,6 @@ class ModelWork(L.LightningWork): class DAG(L.LightningFlow): - """This component is a DAG.""" def __init__(self, models_paths: list): diff --git a/examples/fabric/image_classifier_1_pytorch.py b/examples/fabric/image_classifier_1_pytorch.py index a7fe9ce51c..f00677837b 100644 --- a/examples/fabric/image_classifier_1_pytorch.py +++ b/examples/fabric/image_classifier_1_pytorch.py @@ -28,7 +28,6 @@ DATASETS_PATH = path.join(path.dirname(__file__), "..", "..", "Datasets") # Credit to the PyTorch team # Taken from https://github.com/pytorch/examples/blob/master/mnist/main.py and slightly adapted. def run(hparams): - torch.manual_seed(hparams.seed) use_cuda = torch.cuda.is_available() diff --git a/examples/pl_basics/profiler_example.py b/examples/pl_basics/profiler_example.py index 517c33c052..d187c247ae 100644 --- a/examples/pl_basics/profiler_example.py +++ b/examples/pl_basics/profiler_example.py @@ -90,7 +90,6 @@ class ModelToProfile(LightningModule): class CIFAR10DataModule(LightningDataModule): - transform = T.Compose([T.Resize(256), T.CenterCrop(224), T.ToTensor()]) def train_dataloader(self, *args, **kwargs): diff --git a/examples/pl_loops/kfold.py b/examples/pl_loops/kfold.py index 38103d95ff..b8017b9ccb 100644 --- a/examples/pl_loops/kfold.py +++ b/examples/pl_loops/kfold.py @@ -73,7 +73,6 @@ class BaseKFoldDataModule(LightningDataModule, ABC): @dataclass class MNISTKFoldDataModule(BaseKFoldDataModule): - train_dataset: Optional[Dataset] = None test_dataset: Optional[Dataset] = None train_fold: Optional[Dataset] = None diff --git a/examples/pl_servable_module/production.py b/examples/pl_servable_module/production.py index aef5a29a1f..1aee33793a 100644 --- a/examples/pl_servable_module/production.py +++ b/examples/pl_servable_module/production.py @@ -43,7 +43,6 @@ class LitModule(LightningModule): class CIFAR10DataModule(LightningDataModule): - transform = T.Compose([T.Resize(256), T.CenterCrop(224), T.ToTensor()]) def train_dataloader(self, *args, **kwargs): @@ -57,7 +56,6 @@ class CIFAR10DataModule(LightningDataModule): @dataclass(unsafe_hash=True) class Image: - height: Optional[int] = None width: Optional[int] = None extension: str = "JPEG" diff --git a/src/lightning_app/api/http_methods.py b/src/lightning_app/api/http_methods.py index 379e87cb68..8a29aa879a 100644 --- a/src/lightning_app/api/http_methods.py +++ b/src/lightning_app/api/http_methods.py @@ -215,12 +215,10 @@ class Post(_HttpMethod): class Get(_HttpMethod): - pass class Put(_HttpMethod): - pass diff --git a/src/lightning_app/cli/cmd_init.py b/src/lightning_app/cli/cmd_init.py index e3fbf4f680..d6f70c8f07 100644 --- a/src/lightning_app/cli/cmd_init.py +++ b/src/lightning_app/cli/cmd_init.py @@ -9,7 +9,6 @@ logger = Logger(__name__) def app(app_name: str) -> None: - if app_name is None: app_name = _capture_valid_app_component_name(resource_type="app") diff --git a/src/lightning_app/cli/cmd_install.py b/src/lightning_app/cli/cmd_install.py index 56c3d07b3d..556a9c5eee 100644 --- a/src/lightning_app/cli/cmd_install.py +++ b/src/lightning_app/cli/cmd_install.py @@ -148,7 +148,6 @@ def gallery_component(name: str, yes_arg: bool, version_arg: str, cwd: str = Non def non_gallery_component(gh_url: str, yes_arg: bool, cwd: str = None) -> None: - # give the user the chance to do a manual install git_url = _show_non_gallery_install_component_prompt(gh_url, yes_arg) @@ -157,7 +156,6 @@ def non_gallery_component(gh_url: str, yes_arg: bool, cwd: str = None) -> None: def gallery_app(name: str, yes_arg: bool, version_arg: str, cwd: str = None, overwrite: bool = False) -> str: - # make sure org/app-name syntax is correct org, app = _validate_name(name, resource_type="app", example="lightning/quick-start") @@ -179,7 +177,6 @@ def gallery_app(name: str, yes_arg: bool, version_arg: str, cwd: str = None, ove def non_gallery_app(gh_url: str, yes_arg: bool, cwd: str = None, overwrite: bool = False) -> None: - # give the user the chance to do a manual install repo_url, folder_name = _show_non_gallery_install_app_prompt(gh_url, yes_arg) diff --git a/src/lightning_app/cli/commands/logs.py b/src/lightning_app/cli/commands/logs.py index fb0746dd50..0f90d2b7ad 100644 --- a/src/lightning_app/cli/commands/logs.py +++ b/src/lightning_app/cli/commands/logs.py @@ -39,7 +39,6 @@ def logs(app_name: str, components: List[str], follow: bool) -> None: def _show_logs(app_name: str, components: List[str], follow: bool) -> None: - client = LightningClient() project = _get_project(client) diff --git a/src/lightning_app/cli/component-template/tests/test_placeholdername_component.py b/src/lightning_app/cli/component-template/tests/test_placeholdername_component.py index ca8e92d949..e1b30e1c11 100644 --- a/src/lightning_app/cli/component-template/tests/test_placeholdername_component.py +++ b/src/lightning_app/cli/component-template/tests/test_placeholdername_component.py @@ -1,5 +1,4 @@ -r""" -To test a lightning component: +r"""To test a lightning component: 1. Init the component. 2. call .run() diff --git a/src/lightning_app/components/database/server.py b/src/lightning_app/components/database/server.py index 0a93bf94f9..f095f18a07 100644 --- a/src/lightning_app/components/database/server.py +++ b/src/lightning_app/components/database/server.py @@ -30,7 +30,6 @@ logger = Logger(__name__) # Required to avoid Uvicorn Server overriding Lightning App signal handlers. # Discussions: https://github.com/encode/uvicorn/discussions/1708 class _DatabaseUvicornServer(uvicorn.Server): - has_started_queue = None def run(self, sockets=None): diff --git a/src/lightning_app/components/multi_node/pytorch_spawn.py b/src/lightning_app/components/multi_node/pytorch_spawn.py index 013bdbcaec..73af59ff1f 100644 --- a/src/lightning_app/components/multi_node/pytorch_spawn.py +++ b/src/lightning_app/components/multi_node/pytorch_spawn.py @@ -22,7 +22,6 @@ class _PyTorchSpawnWorkProtocol(Protocol): class _PyTorchSpawnRunExecutor(WorkRunExecutor): - enable_start_observer: bool = False def __call__( diff --git a/src/lightning_app/components/python/tracer.py b/src/lightning_app/components/python/tracer.py index af1eb678d6..332360469b 100644 --- a/src/lightning_app/components/python/tracer.py +++ b/src/lightning_app/components/python/tracer.py @@ -22,7 +22,6 @@ class Code(TypedDict): class TracerPythonScript(LightningWork): - _start_method = "spawn" def on_before_run(self): diff --git a/src/lightning_app/components/serve/auto_scaler.py b/src/lightning_app/components/serve/auto_scaler.py index 354e8c8227..3c1edb0e33 100644 --- a/src/lightning_app/components/serve/auto_scaler.py +++ b/src/lightning_app/components/serve/auto_scaler.py @@ -143,8 +143,8 @@ def _create_fastapi(title: str) -> FastAPI: class _LoadBalancer(LightningWork): - r"""The LoadBalancer is a LightningWork component that collects the requests and sends them to the prediciton API - asynchronously using RoundRobin scheduling. It also performs auto batching of the incoming requests. + r"""The LoadBalancer is a LightningWork component that collects the requests and sends them to the prediciton + API asynchronously using RoundRobin scheduling. It also performs auto batching of the incoming requests. The LoadBalancer exposes system endpoints with a basic HTTP authentication, in order to activate the authentication you need to provide a system password from environment variable:: diff --git a/src/lightning_app/components/serve/gradio.py b/src/lightning_app/components/serve/gradio.py index 29af372e03..1cddb454c0 100644 --- a/src/lightning_app/components/serve/gradio.py +++ b/src/lightning_app/components/serve/gradio.py @@ -13,7 +13,6 @@ else: class ServeGradio(LightningWork, abc.ABC): - """The ServeGradio Class enables to quickly create a ``gradio`` based UI for your LightningApp. In the example below, the ``ServeGradio`` is subclassed to deploy ``AnimeGANv2``. diff --git a/src/lightning_app/components/serve/python_server.py b/src/lightning_app/components/serve/python_server.py index f092843bf2..caae6f584c 100644 --- a/src/lightning_app/components/serve/python_server.py +++ b/src/lightning_app/components/serve/python_server.py @@ -142,7 +142,6 @@ class Number(BaseModel): class PythonServer(LightningWork, abc.ABC): - _start_method = "spawn" @requires(["torch"]) diff --git a/src/lightning_app/core/api.py b/src/lightning_app/core/api.py index 51b57b2c73..6a9f4e0722 100644 --- a/src/lightning_app/core/api.py +++ b/src/lightning_app/core/api.py @@ -417,7 +417,6 @@ def register_global_routes(): class LightningUvicornServer(uvicorn.Server): - has_started_queue = None def run(self, sockets=None): diff --git a/src/lightning_app/core/flow.py b/src/lightning_app/core/flow.py index ee2931a6af..f5782ff451 100644 --- a/src/lightning_app/core/flow.py +++ b/src/lightning_app/core/flow.py @@ -18,7 +18,6 @@ from lightning_app.utilities.packaging.cloud_compute import _maybe_create_cloud_ class LightningFlow: - _INTERNAL_STATE_VARS = { # Internal protected variables that are still part of the state (even though they are prefixed with "_") "_paths", diff --git a/src/lightning_app/core/work.py b/src/lightning_app/core/work.py index 863d50db47..e587b050b5 100644 --- a/src/lightning_app/core/work.py +++ b/src/lightning_app/core/work.py @@ -38,7 +38,6 @@ if TYPE_CHECKING: class LightningWork: - _INTERNAL_STATE_VARS = ( # Internal protected variables that are still part of the state (even though they are prefixed with "_") "_paths", diff --git a/src/lightning_app/runners/cloud.py b/src/lightning_app/runners/cloud.py index 9892060c32..2d7318a3ef 100644 --- a/src/lightning_app/runners/cloud.py +++ b/src/lightning_app/runners/cloud.py @@ -196,7 +196,6 @@ def _generate_works_json_gallery(filepath: str) -> str: @dataclass class CloudRuntime(Runtime): - backend: Union[str, CloudBackend] = "cloud" def dispatch( diff --git a/src/lightning_app/runners/multiprocess.py b/src/lightning_app/runners/multiprocess.py index e5d34fb768..86c81b8793 100644 --- a/src/lightning_app/runners/multiprocess.py +++ b/src/lightning_app/runners/multiprocess.py @@ -21,7 +21,6 @@ from lightning_app.utilities.port import disable_port @dataclass class MultiProcessRuntime(Runtime): - """Runtime to launch the LightningApp into multiple processes. The MultiProcessRuntime will generate 1 process for each :class:`~lightning_app.core.work.LightningWork` and attach diff --git a/src/lightning_app/runners/runtime.py b/src/lightning_app/runners/runtime.py index 19cd1a1610..7a70bc43e2 100644 --- a/src/lightning_app/runners/runtime.py +++ b/src/lightning_app/runners/runtime.py @@ -156,7 +156,6 @@ class Runtime: raise NotImplementedError def _add_stopped_status_to_work(self, work: "lightning_app.LightningWork") -> None: - if work.status.stage == WorkStageStatus.STOPPED: return diff --git a/src/lightning_app/storage/drive.py b/src/lightning_app/storage/drive.py index 7b6f268ffe..0a7656a894 100644 --- a/src/lightning_app/storage/drive.py +++ b/src/lightning_app/storage/drive.py @@ -11,7 +11,6 @@ from lightning_app.utilities.component import _is_flow_context class Drive: - __IDENTIFIER__ = "__drive__" __PROTOCOLS__ = ["lit://"] diff --git a/src/lightning_app/storage/mount.py b/src/lightning_app/storage/mount.py index 3c520f6ba0..a3073751a7 100644 --- a/src/lightning_app/storage/mount.py +++ b/src/lightning_app/storage/mount.py @@ -26,7 +26,6 @@ class Mount: mount_path: str = "" def __post_init__(self) -> None: - for protocol in __MOUNT_PROTOCOLS__: if self.source.startswith(protocol): protocol = protocol diff --git a/src/lightning_app/storage/payload.py b/src/lightning_app/storage/payload.py index 29789d31fc..eba89988d3 100644 --- a/src/lightning_app/storage/payload.py +++ b/src/lightning_app/storage/payload.py @@ -243,7 +243,6 @@ class _BasePayload(ABC): class Payload(_BasePayload): - """The Payload object enables to transfer python objects from one work to another in a similar fashion as :class:`~lightning_app.storage.path.Path`.""" diff --git a/src/lightning_app/utilities/app_helpers.py b/src/lightning_app/utilities/app_helpers.py index d9efeb6862..5f9399ae11 100644 --- a/src/lightning_app/utilities/app_helpers.py +++ b/src/lightning_app/utilities/app_helpers.py @@ -407,7 +407,6 @@ class LightningJSONEncoder(json.JSONEncoder): class Logger: - """This class is used to improve the debugging experience.""" def __init__(self, name: str): diff --git a/src/lightning_app/utilities/commands/base.py b/src/lightning_app/utilities/commands/base.py index 947456d8e4..8b0abd210b 100644 --- a/src/lightning_app/utilities/commands/base.py +++ b/src/lightning_app/utilities/commands/base.py @@ -36,7 +36,6 @@ def makedirs(path: str): class ClientCommand: - description: str = "" requirements: List[str] = [] diff --git a/src/lightning_app/utilities/imports.py b/src/lightning_app/utilities/imports.py index 19978fcf5d..7b8158e9b9 100644 --- a/src/lightning_app/utilities/imports.py +++ b/src/lightning_app/utilities/imports.py @@ -46,7 +46,6 @@ def _get_extras(extras: str) -> str: def requires(module_paths: Union[str, List]): - if not isinstance(module_paths, list): module_paths = [module_paths] diff --git a/src/lightning_app/utilities/introspection.py b/src/lightning_app/utilities/introspection.py index eb77a2fff8..19bd72e20c 100644 --- a/src/lightning_app/utilities/introspection.py +++ b/src/lightning_app/utilities/introspection.py @@ -269,7 +269,6 @@ class LightningProfilerVisitor(LightningVisitor): class Scanner: - """ Finds relevant Lightning objects in files in the file system. Attributes diff --git a/src/lightning_app/utilities/proxies.py b/src/lightning_app/utilities/proxies.py index 2e7dc6ce7e..0e6c23ed6c 100644 --- a/src/lightning_app/utilities/proxies.py +++ b/src/lightning_app/utilities/proxies.py @@ -341,7 +341,6 @@ class ComponentDelta: @dataclass class WorkRunExecutor: - work: "LightningWork" work_run: Callable delta_queue: "BaseQueue" diff --git a/src/lightning_app/utilities/state.py b/src/lightning_app/utilities/state.py index 775fa49ddd..80b56b6fbd 100644 --- a/src/lightning_app/utilities/state.py +++ b/src/lightning_app/utilities/state.py @@ -35,7 +35,6 @@ def headers_for(context: Dict[str, str]) -> Dict[str, str]: class AppState: - _APP_PRIVATE_KEYS: Tuple[str, ...] = ( "_host", "_session_id", diff --git a/src/lightning_fabric/fabric.py b/src/lightning_fabric/fabric.py index 978cc368d2..ffec6f705e 100644 --- a/src/lightning_fabric/fabric.py +++ b/src/lightning_fabric/fabric.py @@ -413,8 +413,7 @@ class Fabric: def all_gather( self, data: Union[Tensor, Dict, List, Tuple], group: Optional[Any] = None, sync_grads: bool = False ) -> Union[Tensor, Dict, List, Tuple]: - r""" - Gather tensors or collections of tensors from multiple processes. + r"""Gather tensors or collections of tensors from multiple processes. Args: data: int, float, tensor of shape (batch, ...), or a (possibly nested) collection thereof. diff --git a/src/lightning_fabric/strategies/deepspeed.py b/src/lightning_fabric/strategies/deepspeed.py index b94c94de44..3b3379c730 100644 --- a/src/lightning_fabric/strategies/deepspeed.py +++ b/src/lightning_fabric/strategies/deepspeed.py @@ -596,7 +596,6 @@ class DeepSpeedStrategy(DDPStrategy, _Sharded): import deepspeed def load(module: torch.nn.Module, prefix: str = "") -> None: - missing_keys: List[str] = [] unexpected_keys: List[str] = [] error_msgs: List[str] = [] diff --git a/src/lightning_fabric/strategies/launchers/subprocess_script.py b/src/lightning_fabric/strategies/launchers/subprocess_script.py index 54df6530c1..61a72bf652 100644 --- a/src/lightning_fabric/strategies/launchers/subprocess_script.py +++ b/src/lightning_fabric/strategies/launchers/subprocess_script.py @@ -25,8 +25,7 @@ _HYDRA_AVAILABLE = RequirementCache("hydra-core") class _SubprocessScriptLauncher(_Launcher): - r""" - A process laucher that invokes the current script as many times as desired in a single node. + r"""A process laucher that invokes the current script as many times as desired in a single node. This launcher needs to be invoked on each node. In its default behavior, the main process in each node then spawns N-1 child processes via :func:`subprocess.Popen`, diff --git a/src/pytorch_lightning/core/module.py b/src/pytorch_lightning/core/module.py index 2402bedbe9..cf86a4ccb7 100644 --- a/src/pytorch_lightning/core/module.py +++ b/src/pytorch_lightning/core/module.py @@ -1779,7 +1779,7 @@ class LightningModule( split_x: Union[Tensor, List[Tensor]] if isinstance(x, Tensor): split_x = x[:, t : t + split_size] - elif isinstance(x, collections.Sequence): + elif isinstance(x, collections.abc.Sequence): split_x = [x[batch_idx][t : t + split_size] for batch_idx in range(len(x))] batch_split.append(split_x) diff --git a/tests/tests_fabric/utilities/test_optimizer.py b/tests/tests_fabric/utilities/test_optimizer.py index 5473ca0f4c..9422af0fb1 100644 --- a/tests/tests_fabric/utilities/test_optimizer.py +++ b/tests/tests_fabric/utilities/test_optimizer.py @@ -25,7 +25,7 @@ def assert_opt_parameters_on_device(opt, device: str): # Not sure there are any global tensors in the state dict if isinstance(param, Tensor): assert param.data.device.type == device - elif isinstance(param, collections.Mapping): + elif isinstance(param, collections.abc.Mapping): for subparam in param.values(): if isinstance(subparam, Tensor): assert param.data.device.type == device