enable import `lightning.app` if it is installed (#20059)
This commit is contained in:
parent
249230a95a
commit
cc457fe5eb
|
@ -14,7 +14,6 @@ Brief description of all our automation tools used for boosting development perf
|
|||
| .azure-pipelines/gpu-tests-fabric.yml | Run only GPU-specific tests, standalone\*, and examples. | GPU |
|
||||
| .azure-pipelines/gpu-tests-pytorch.yml | Run only GPU-specific tests, standalone\*, and examples. | GPU |
|
||||
| .azure-pipelines/gpu-benchmarks.yml | Run speed/memory benchmarks for parity with vanila PyTorch. | GPU |
|
||||
| .github/workflows/ci-flagship-apps.yml | Run end-2-end tests with full applications, including deployment to the production cloud. | CPU |
|
||||
| .github/workflows/ci-tests-pytorch.yml | Run all tests except for accelerator-specific, standalone and slow tests. | CPU |
|
||||
| .github/workflows/tpu-tests.yml | Run only TPU-specific tests. Requires that the PR title contains '\[TPU\]' | TPU |
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
name: Package extras
|
||||
|
||||
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
|
||||
on:
|
||||
push:
|
||||
branches: [master, "release/*"]
|
||||
pull_request:
|
||||
branches: [master, "release/*"]
|
||||
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
|
||||
paths:
|
||||
- ".github/workflows/ci-pkg-extend.yml"
|
||||
- "requirements/ci.txt"
|
||||
- "requirements/app/*"
|
||||
- "requirements/data/*"
|
||||
- "src/lightning/app/*"
|
||||
- "src/lightning/data/*"
|
||||
- "!*.md"
|
||||
- "!**/*.md"
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
|
||||
import-pkg:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
os: ["ubuntu-22.04", "macOS-12", "windows-2022"]
|
||||
pkg-name: ["app", "data"]
|
||||
python-version: ["3.8", "3.11"]
|
||||
env:
|
||||
TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Install package
|
||||
run: pip install lightning[${{ matrix.pkg-name }}] -f $TORCH_URL
|
||||
timeout-minutes: 10
|
||||
|
||||
- name: Try importing
|
||||
run: from lightning.${{ matrix.pkg-name }} import *
|
||||
shell: python
|
||||
|
|
@ -88,7 +88,7 @@ jobs:
|
|||
if: ${{ matrix.pkg-name == 'lightning' || matrix.pkg-name == 'notset' }}
|
||||
working-directory: src/lit
|
||||
run: |
|
||||
items=("data")
|
||||
items=("app" "data")
|
||||
for item in "${items[@]}"; do
|
||||
echo "Removing $item"
|
||||
rm -rf $item
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import lightning as L
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
from data import RandomTokenDataset
|
||||
from lightning.fabric.strategies import ModelParallelStrategy
|
||||
from model import ModelArgs, Transformer
|
||||
from parallelism import parallelize
|
||||
from torch.distributed.tensor.parallel import loss_parallel
|
||||
from torch.utils.data import DataLoader
|
||||
|
||||
from data import RandomTokenDataset
|
||||
|
||||
|
||||
def train():
|
||||
strategy = ModelParallelStrategy(
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import lightning as L
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
from data import RandomTokenDataset
|
||||
from lightning.pytorch.strategies import ModelParallelStrategy
|
||||
from model import ModelArgs, Transformer
|
||||
from parallelism import parallelize
|
||||
from torch.distributed.tensor.parallel import loss_parallel
|
||||
from torch.utils.data import DataLoader
|
||||
|
||||
from data import RandomTokenDataset
|
||||
|
||||
|
||||
class Llama3(L.LightningModule):
|
||||
def __init__(self):
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# NOTE: this is here only to expose `pip install lightning[app]`. we don't install or test it in this project's CI
|
||||
|
||||
lightning_app >= 2.3.3, <2.3.4
|
|
@ -0,0 +1,26 @@
|
|||
import sys
|
||||
|
||||
from lightning_utilities.core.imports import RequirementCache, module_available
|
||||
|
||||
__all__ = []
|
||||
|
||||
if not RequirementCache("lightning_app"):
|
||||
raise ModuleNotFoundError("Please, run `pip install lightning-app`") # E111
|
||||
|
||||
else:
|
||||
import lightning_app
|
||||
|
||||
# Enable resolution at least for lower data namespace
|
||||
sys.modules["lightning.app"] = lightning_app
|
||||
|
||||
from lightning_app.core.app import LightningApp # noqa: E402
|
||||
from lightning_app.core.flow import LightningFlow # noqa: E402
|
||||
from lightning_app.core.work import LightningWork # noqa: E402
|
||||
from lightning_app.plugin.plugin import LightningPlugin # noqa: E402
|
||||
from lightning_app.utilities.packaging.build_config import BuildConfig # noqa: E402
|
||||
from lightning_app.utilities.packaging.cloud_compute import CloudCompute # noqa: E402
|
||||
|
||||
if module_available("lightning_app.components.demo"):
|
||||
from lightning.app.components import demo # noqa: F401
|
||||
|
||||
__all__ = ["LightningApp", "LightningFlow", "LightningWork", "LightningPlugin", "BuildConfig", "CloudCompute"]
|
Loading…
Reference in New Issue