Skip to content

Commit

Permalink
Merge branch 'master' into issue-20182-cli-private-hparams-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lantiga authored Dec 11, 2024
2 parents ea8608f + 60289d7 commit 1dc28c2
Show file tree
Hide file tree
Showing 276 changed files with 2,726 additions and 1,531 deletions.
26 changes: 21 additions & 5 deletions .actions/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
import shutil
import tempfile
import urllib.request
from collections.abc import Iterable, Iterator, Sequence
from itertools import chain
from os.path import dirname, isfile
from pathlib import Path
from typing import Any, Dict, Iterable, Iterator, List, Optional, Sequence, Tuple
from typing import Any, Optional

from packaging.requirements import Requirement
from packaging.version import Version
Expand Down Expand Up @@ -127,7 +128,7 @@ def _parse_requirements(lines: Iterable[str]) -> Iterator[_RequirementWithCommen
pip_argument = None


def load_requirements(path_dir: str, file_name: str = "base.txt", unfreeze: str = "all") -> List[str]:
def load_requirements(path_dir: str, file_name: str = "base.txt", unfreeze: str = "all") -> list[str]:
"""Loading requirements from a file.
>>> path_req = os.path.join(_PROJECT_ROOT, "requirements")
Expand Down Expand Up @@ -222,7 +223,7 @@ def _load_aggregate_requirements(req_dir: str = "requirements", freeze_requireme
fp.writelines([ln + os.linesep for ln in requires] + [os.linesep])


def _retrieve_files(directory: str, *ext: str) -> List[str]:
def _retrieve_files(directory: str, *ext: str) -> list[str]:
all_files = []
for root, _, files in os.walk(directory):
for fname in files:
Expand All @@ -232,7 +233,7 @@ def _retrieve_files(directory: str, *ext: str) -> List[str]:
return all_files


def _replace_imports(lines: List[str], mapping: List[Tuple[str, str]], lightning_by: str = "") -> List[str]:
def _replace_imports(lines: list[str], mapping: list[tuple[str, str]], lightning_by: str = "") -> list[str]:
"""Replace imports of standalone package to lightning.
>>> lns = [
Expand Down Expand Up @@ -320,7 +321,7 @@ def copy_replace_imports(
fo.writelines(lines)


def create_mirror_package(source_dir: str, package_mapping: Dict[str, str]) -> None:
def create_mirror_package(source_dir: str, package_mapping: dict[str, str]) -> None:
"""Create a mirror package with adjusted imports."""
# replace imports and copy the code
mapping = package_mapping.copy()
Expand Down Expand Up @@ -482,6 +483,21 @@ def convert_version2nightly(ver_file: str = "src/version.info") -> None:


if __name__ == "__main__":
import sys

import jsonargparse
from jsonargparse import ArgumentParser

def patch_jsonargparse_python_3_12_8():
if sys.version_info < (3, 12, 8):
return

def _parse_known_args_patch(self: ArgumentParser, args: Any = None, namespace: Any = None) -> tuple[Any, Any]:
namespace, args = super(ArgumentParser, self)._parse_known_args(args, namespace, intermixed=False) # type: ignore
return namespace, args

setattr(ArgumentParser, "_parse_known_args", _parse_known_args_patch)

patch_jsonargparse_python_3_12_8() # Required until fix https://github.com/omni-us/jsonargparse/issues/641

jsonargparse.CLI(AssistantCLI, as_positional=False)
4 changes: 3 additions & 1 deletion .azure/gpu-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ jobs:
pip list
displayName: "Image info & NVIDIA"
- bash: pip install -e .[dev] --find-links ${TORCH_URL}
- bash: |
pip install -e .[dev] --find-links ${TORCH_URL}
pip install setuptools==75.6.0
env:
FREEZE_REQUIREMENTS: "1"
displayName: "Install package"
Expand Down
11 changes: 6 additions & 5 deletions .azure/gpu-tests-fabric.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ jobs:
- bash: |
extra=$(python -c "print({'lightning': 'fabric-'}.get('$(PACKAGE_NAME)', ''))")
pip install -e ".[${extra}dev]" pytest-timeout -U --find-links="${TORCH_URL}" --find-links="${TORCHVISION_URL}"
pip install setuptools==75.6.0
displayName: "Install package & dependencies"
- bash: |
Expand Down Expand Up @@ -134,13 +135,13 @@ jobs:
condition: and(succeeded(), eq(variables['PACKAGE_NAME'], 'fabric'))
displayName: "Adjust tests & examples"
- bash: python -m coverage run --source ${COVERAGE_SOURCE} -m pytest . -v --durations=50
workingDirectory: tests/tests_fabric/
- bash: python -m coverage run --source ${COVERAGE_SOURCE} -m pytest tests_fabric/ -v --durations=50
workingDirectory: tests/
displayName: "Testing: fabric standard"
timeoutInMinutes: "10"

- bash: bash ../run_standalone_tests.sh "."
workingDirectory: tests/tests_fabric/
- bash: bash ./run_standalone_tests.sh "tests_fabric"
workingDirectory: tests/
env:
PL_STANDALONE_TESTS_SOURCE: $(COVERAGE_SOURCE)
displayName: "Testing: fabric standalone"
Expand All @@ -157,7 +158,7 @@ jobs:
./codecov --token=$(CODECOV_TOKEN) --commit=$(Build.SourceVersion) \
--flags=gpu,pytest,${COVERAGE_SOURCE} --name="GPU-coverage" --env=linux,azure
ls -l
workingDirectory: tests/tests_fabric/
workingDirectory: tests/
displayName: "Statistics"
- script: |
Expand Down
9 changes: 5 additions & 4 deletions .azure/gpu-tests-pytorch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ jobs:
- bash: |
extra=$(python -c "print({'lightning': 'pytorch-'}.get('$(PACKAGE_NAME)', ''))")
pip install -e ".[${extra}dev]" pytest-timeout -U --find-links="${TORCH_URL}" --find-links="${TORCHVISION_URL}"
pip install setuptools==75.6.0
displayName: "Install package & dependencies"
- bash: pip uninstall -y lightning
Expand Down Expand Up @@ -155,13 +156,13 @@ jobs:
ls -l checkpoints/
displayName: "Get legacy checkpoints"
- bash: python -m coverage run --source ${COVERAGE_SOURCE} -m pytest -v --durations=50
workingDirectory: tests/tests_pytorch
- bash: python -m coverage run --source ${COVERAGE_SOURCE} -m pytest tests_pytorch/ -v --durations=50
workingDirectory: tests/
displayName: "Testing: PyTorch standard"
timeoutInMinutes: "35"

- bash: bash ../run_standalone_tests.sh "."
workingDirectory: tests/tests_pytorch
- bash: bash ./run_standalone_tests.sh "tests_pytorch"
workingDirectory: tests/
env:
PL_USE_MOCKED_MNIST: "1"
PL_STANDALONE_TESTS_SOURCE: $(COVERAGE_SOURCE)
Expand Down
31 changes: 4 additions & 27 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,16 @@
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
* @lantiga @borda @tchaton @awaelchli @justusschock

# CI/CD and configs
/.actions/ @borda @ethanwharris @justusschock
/.github/ @borda @ethanwharris @justusschock
/.azure/ @borda @ethanwharris @justusschock
/dockers/ @borda @ethanwharris @justusschock
*.yml @borda @ethanwharris @justusschock
* @lantiga @borda @tchaton @justusschock @ethanwharris

# Docs
/docs/ @lantiga @borda @awaelchli
/docs/*/conf.py @borda @awaelchli
/.github/*.md @williamfalcon @lantiga @borda
/.github/ISSUE_TEMPLATE/ @borda @tchaton @awaelchli
/docs/source-fabric/conf.py @borda @awaelchli
/docs/source-fabric/index.rst @awaelchli @lantiga
/docs/source-pytorch/conf.py @borda @awaelchli
/docs/source-fabric/index.rst @williamfalcon @lantiga
/docs/source-pytorch/index.rst @williamfalcon @lantiga
/docs/source-pytorch/levels @williamfalcon @lantiga

# PyTorch Lightning
/src/lightning/pytorch @lantiga @borda @tchaton @awaelchli @justusschock

# Lightning Data
/src/lightning/data/ @tchaton @lantiga

# Lightning Fabric
/src/lightning/fabric @lantiga @borda @tchaton @awaelchli @justusschock

/.github/CODEOWNERS @williamfalcon
/SECURITY.md @williamfalcon @lantiga
/README.md @williamfalcon @lantiga
/setup.py @williamfalcon @borda
/src/pytorch_lightning/__about__.py @williamfalcon @borda
/src/lightning_fabric/__about__.py @williamfalcon @borda @awaelchli
/src/*/__setup__.py @borda @justusschock
/src/pytorch_lightning/__about__.py @williamfalcon @lantiga @borda
/src/lightning_fabric/__about__.py @williamfalcon @lantiga @borda
2 changes: 1 addition & 1 deletion .github/workflows/_legacy-checkpoints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- uses: actions/setup-python@v5
with:
# Python version here needs to be supported by all PL versions listed in back-compatible-versions.txt.
python-version: 3.8
python-version: "3.9"

- name: Install PL from source
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/call-clear-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
jobs:
cron-clear:
if: github.event_name == 'schedule' || github.event_name == 'pull_request'
uses: Lightning-AI/utilities/.github/workflows/cleanup-caches.yml@v0.11.8
uses: Lightning-AI/utilities/.github/workflows/cleanup-caches.yml@v0.11.9
with:
scripts-ref: v0.11.8
dry-run: ${{ github.event_name == 'pull_request' }}
Expand All @@ -32,7 +32,7 @@ jobs:

direct-clear:
if: github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request'
uses: Lightning-AI/utilities/.github/workflows/cleanup-caches.yml@v0.11.8
uses: Lightning-AI/utilities/.github/workflows/cleanup-caches.yml@v0.11.9
with:
scripts-ref: v0.11.8
dry-run: ${{ github.event_name == 'pull_request' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-check-md-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

jobs:
check-md-links:
uses: Lightning-AI/utilities/.github/workflows/check-md-links.yml@v0.11.8
uses: Lightning-AI/utilities/.github/workflows/check-md-links.yml@v0.11.9
with:
config-file: ".github/markdown-links-config.json"
base-branch: "master"
2 changes: 1 addition & 1 deletion .github/workflows/ci-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
check:
uses: Lightning-AI/utilities/.github/workflows/check-schema.yml@v0.11.8
uses: Lightning-AI/utilities/.github/workflows/check-schema.yml@v0.11.9
with:
# skip azure due to the wrong schema file by MSFT
# https://github.com/Lightning-AI/lightning-flash/pull/1455#issuecomment-1244793607
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests-fabric.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
# see: https://github.com/actions/toolkit/issues/399
continue-on-error: true
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests-pytorch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
# see: https://github.com/actions/toolkit/issues/399
continue-on-error: true
with:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ repos:
hooks:
# try to fix what is possible
- id: ruff
args: ["--fix"]
args: ["--fix", "--unsafe-fixes"]
# perform formatting updates
- id: ruff-format
# validate if all is fine with preview mode
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,6 @@ Lightning is rigorously tested across multiple CPUs, GPUs and TPUs and against m
| System / PyTorch ver. | 1.13 | 2.0 | 2.1 |
| :--------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| Linux py3.9 \[GPUs\] | | | [![Build Status](https://dev.azure.com/Lightning-AI/lightning/_apis/build/status%2Fpytorch-lightning%20%28GPUs%29?branchName=master)](https://dev.azure.com/Lightning-AI/lightning/_build/latest?definitionId=24&branchName=master) |
| Linux py3.9 \[TPUs\] | | [![Test PyTorch - TPU](https://github.com/Lightning-AI/lightning/actions/workflows/tpu-tests.yml/badge.svg)](https://github.com/Lightning-AI/lightning/actions/workflows/tpu-tests.yml) | |
| Linux (multiple Python versions) | [![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg)](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml) | [![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg)](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml) | [![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg)](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml) |
| OSX (multiple Python versions) | [![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg)](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml) | [![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg)](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml) | [![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg)](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml) |
| Windows (multiple Python versions) | [![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg)](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml) | [![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg)](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml) | [![Test PyTorch](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml/badge.svg)](https://github.com/Lightning-AI/lightning/actions/workflows/ci-tests-pytorch.yml) |
Expand Down
2 changes: 1 addition & 1 deletion _notebooks
3 changes: 2 additions & 1 deletion dockers/base-cuda/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ RUN \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get install -y \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-distutils \
python${PYTHON_VERSION}-dev \
&& \
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
Expand All @@ -79,6 +78,8 @@ RUN \
curl https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} && \
# Disable cache \
pip config set global.cache-dir false && \
# Install recent setuptools to obtain pkg_resources \
pip install setuptools==75.6.0 && \
# set particular PyTorch version \
pip install -q wget packaging && \
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py && \
Expand Down
2 changes: 1 addition & 1 deletion dockers/docs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RUN \
dvipng \
texlive-pictures \
python3 \
python3-distutils \
python3-setuptools \
python3-dev \
&& \
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \
Expand Down
2 changes: 1 addition & 1 deletion dockers/release/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RUN \
fi && \
# otherwise there is collision with folder name and pkg name on Pypi
cd pytorch-lightning && \
pip install setuptools && \
pip install setuptools==75.6.0 && \
PACKAGE_NAME=lightning pip install '.[extra,loggers,strategies]' --no-cache-dir && \
PACKAGE_NAME=pytorch pip install '.[extra,loggers,strategies]' --no-cache-dir && \
cd .. && \
Expand Down
Loading

0 comments on commit 1dc28c2

Please sign in to comment.