Skip to content

Commit 39e1e89

Browse files
authored
Merge branch 'master' into deepspeed_mics_init
2 parents 9ccbb1f + 6b88ddc commit 39e1e89

File tree

9 files changed

+53
-6
lines changed

9 files changed

+53
-6
lines changed

.actions/assistant.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,21 @@ def convert_version2nightly(ver_file: str = "src/version.info") -> None:
483483

484484

485485
if __name__ == "__main__":
486+
import sys
487+
486488
import jsonargparse
489+
from jsonargparse import ArgumentParser
490+
491+
def patch_jsonargparse_python_3_12_8():
492+
if sys.version_info < (3, 12, 8):
493+
return
494+
495+
def _parse_known_args_patch(self: ArgumentParser, args: Any = None, namespace: Any = None) -> tuple[Any, Any]:
496+
namespace, args = super(ArgumentParser, self)._parse_known_args(args, namespace, intermixed=False) # type: ignore
497+
return namespace, args
498+
499+
setattr(ArgumentParser, "_parse_known_args", _parse_known_args_patch)
500+
501+
patch_jsonargparse_python_3_12_8() # Required until fix https://github.com/omni-us/jsonargparse/issues/641
487502

488503
jsonargparse.CLI(AssistantCLI, as_positional=False)

_notebooks

dockers/base-cuda/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ RUN \
5959
add-apt-repository ppa:deadsnakes/ppa && \
6060
apt-get install -y \
6161
python${PYTHON_VERSION} \
62-
python${PYTHON_VERSION}-distutils \
62+
python3-setuptools \
6363
python${PYTHON_VERSION}-dev \
6464
&& \
6565
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \

dockers/docs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ RUN \
4444
dvipng \
4545
texlive-pictures \
4646
python3 \
47-
python3-distutils \
47+
python3-setuptools \
4848
python3-dev \
4949
&& \
5050
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \

examples/fabric/reinforcement_learning/rl/utils.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import argparse
22
import math
33
import os
4-
from distutils.util import strtobool
54
from typing import TYPE_CHECKING, Optional, Union
65

76
import gymnasium as gym
@@ -12,6 +11,23 @@
1211
from rl.agent import PPOAgent, PPOLightningAgent
1312

1413

14+
def strtobool(val):
15+
"""Convert a string representation of truth to true (1) or false (0).
16+
17+
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'.
18+
Raises ValueError if 'val' is anything else.
19+
20+
Note: taken from distutils after its deprecation.
21+
22+
"""
23+
val = val.lower()
24+
if val in ("y", "yes", "t", "true", "on", "1"):
25+
return 1
26+
if val in ("n", "no", "f", "false", "off", "0"):
27+
return 0
28+
raise ValueError(f"invalid truth value {val!r}")
29+
30+
1531
def parse_args():
1632
parser = argparse.ArgumentParser()
1733
parser.add_argument("--exp-name", type=str, default="default", help="the name of this experiment")

src/lightning/pytorch/cli.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@
3737

3838
_JSONARGPARSE_SIGNATURES_AVAILABLE = RequirementCache("jsonargparse[signatures]>=4.27.7")
3939

40+
41+
def patch_jsonargparse_python_3_12_8() -> None:
42+
if sys.version_info < (3, 12, 8):
43+
return
44+
45+
def _parse_known_args_patch(self: ArgumentParser, args: Any = None, namespace: Any = None) -> tuple[Any, Any]:
46+
namespace, args = super(ArgumentParser, self)._parse_known_args(args, namespace, intermixed=False) # type: ignore
47+
return namespace, args
48+
49+
setattr(ArgumentParser, "_parse_known_args", _parse_known_args_patch)
50+
51+
4052
if _JSONARGPARSE_SIGNATURES_AVAILABLE:
4153
import docstring_parser
4254
from jsonargparse import (
@@ -48,6 +60,8 @@
4860
set_config_read_mode,
4961
)
5062

63+
patch_jsonargparse_python_3_12_8() # Required until fix https://github.com/omni-us/jsonargparse/issues/641
64+
5165
register_unresolvable_import_paths(torch) # Required until fix https://github.com/pytorch/pytorch/issues/74483
5266
set_config_read_mode(fsspec_enabled=True)
5367
else:

src/pytorch_lightning/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ Lightning is rigorously tested across multiple CPUs, GPUs and TPUs and against m
8080
| System / PyTorch ver. | 1.12 | 1.13 | 2.0 | 2.1 |
8181
| :--------------------------------: | :---------------------------------------------------------------------------------------------------------: | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
8282
| Linux py3.9 \[GPUs\] | | | | ![Build Status](https://dev.azure.com/Lightning-AI/lightning/_apis/build/status%2Fpytorch-lightning%20%28GPUs%29) |
83-
| Linux py3.9 \[TPUs\] | | | ![Test PyTorch - TPU](https://github.com/Lightning-AI/lightning/actions/workflows/tpu-tests.yml/badge.svg) | |
8483
| Linux (multiple Python versions) | ![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg) | ![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg) | ![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg) | ![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg) |
8584
| OSX (multiple Python versions) | ![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg) | ![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg) | ![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg) | ![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg) |
8685
| Windows (multiple Python versions) | ![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg) | ![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg) | ![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg) | ![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg) |

tests/parity_fabric/test_parity_ddp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,8 @@ def run_parity_test(accelerator: str = "cpu", devices: int = 2, tolerance: float
162162

163163
if __name__ == "__main__":
164164
from jsonargparse import CLI
165+
from lightning.pytorch.cli import patch_jsonargparse_python_3_12_8
166+
167+
patch_jsonargparse_python_3_12_8() # Required until fix https://github.com/omni-us/jsonargparse/issues/641
165168

166169
CLI(run_parity_test)

tests/tests_pytorch/checkpointing/test_model_checkpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
import pytest
3030
import torch
3131
import yaml
32-
from jsonargparse import ArgumentParser
3332
from lightning.fabric.utilities.cloud_io import _load as pl_load
3433
from lightning.pytorch import Trainer, seed_everything
3534
from lightning.pytorch.callbacks import ModelCheckpoint
35+
from lightning.pytorch.cli import LightningArgumentParser as ArgumentParser
3636
from lightning.pytorch.demos.boring_classes import BoringModel
3737
from lightning.pytorch.loggers import CSVLogger, TensorBoardLogger
3838
from lightning.pytorch.utilities.exceptions import MisconfigurationException

0 commit comments

Comments
 (0)