Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not modify PACKAGE_NAME on install #15493

Merged
merged 36 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a989e31
Do not modify PACKAGE_NAME on install
carmocca Nov 3, 2022
3531b0d
Fix ci pkg action
carmocca Nov 3, 2022
0c036bc
Required
carmocca Nov 3, 2022
c5f8885
Typos
carmocca Nov 3, 2022
f8f1df2
Apply suggestions from code review
Borda Nov 3, 2022
99492cb
Undo defaults
carmocca Nov 3, 2022
1430b4b
Cleanup
carmocca Nov 3, 2022
52c2b5a
Implement idea
carmocca Nov 3, 2022
5ee1cdc
Fuck
carmocca Nov 3, 2022
165bb52
Apps mock fix
carmocca Nov 3, 2022
777a7f3
Merge branch 'master' into ci/avoid-writing-pkg-name
carmocca Nov 3, 2022
911fb91
Fix app-pytest with PKG_NAME=app
carmocca Nov 3, 2022
4fd30c8
Justus suggestion
carmocca Nov 3, 2022
9fe3ba3
Debug Windows
carmocca Nov 3, 2022
54dcb90
Update setup.py
carmocca Nov 3, 2022
db1329b
Revert "Debug Windows"
carmocca Nov 3, 2022
5061e8e
SSH action
carmocca Nov 3, 2022
ff1305e
Crazy bug
carmocca Nov 3, 2022
ee50976
Revert "SSH action"
carmocca Nov 3, 2022
d356c96
Merge branch 'master' into ci/avoid-writing-pkg-name
carmocca Nov 3, 2022
4570715
Package import step
carmocca Nov 4, 2022
7930615
Avoid env conflict
carmocca Nov 4, 2022
54c26bf
Debug
carmocca Nov 4, 2022
0eab710
Whitespace
carmocca Nov 4, 2022
c6b3751
Try removing existing lite build
carmocca Nov 4, 2022
fac814a
This should be redundant now
carmocca Nov 4, 2022
ed1b138
Merge branch 'master' into ci/avoid-writing-pkg-name
carmocca Nov 4, 2022
7e5f48e
Add back env now that source-lit is gone
carmocca Nov 4, 2022
f735796
Merge branch 'master' into ci/avoid-writing-pkg-name
carmocca Nov 4, 2022
1aee68a
Remove download artifact
carmocca Nov 4, 2022
f81ae59
checkgroup
carmocca Nov 4, 2022
074af07
Merge branch 'master' into ci/avoid-writing-pkg-name
carmocca Nov 4, 2022
ac9dbb9
TODOs suggested by Jirka
carmocca Nov 4, 2022
274ec75
Merge branch 'master' into ci/avoid-writing-pkg-name
Borda Nov 4, 2022
8340b85
_
Borda Nov 4, 2022
a5fcaa2
Revert "_". These are local variables, do not need protected
carmocca Nov 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions .actions/setup_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@ def create_mirror_package(src_folder: str, lit_pkg_mapping: dict) -> None:
... {"pytorch": "pytorch_lightning", "app": "lightning_app", "lite": "lightning_lite"}
... )
"""
for lit_name, pkg_name in lit_pkg_mapping.items():
copy_adjusted_modules(src_folder, pkg_name, lit_name, lit_pkg_mapping)
mapping = lit_pkg_mapping.copy()
mapping.pop("lightning", None) # pop this key to avoid replacing `lightning` to `lightning.lightning`
for lit_name, pkg_name in mapping.items():
copy_adjusted_modules(src_folder, pkg_name, lit_name, mapping)


def _download_frontend(pkg_path: str):
Expand Down Expand Up @@ -272,19 +274,3 @@ def _load_aggregate_requirements(req_dir: str = "requirements", freeze_requireme
requires = list(chain(*requires))
with open(os.path.join(req_dir, "base.txt"), "w") as fp:
fp.writelines([ln + os.linesep for ln in requires])


def set_actual_version_from_src(req_path: str, src_root: str, pkg_name: str) -> None:
"""Setting actual version from source code for a given package."""
with open(req_path, encoding="utf-8") as fo:
lines = fo.readlines()
ver = parse_version_from_file(os.path.join(src_root, pkg_name.replace("-", "_")))
for i, ln in enumerate(lines):
reqs = list(parse_requirements([ln]))
if not reqs:
continue
if reqs[0].name == pkg_name:
lines[i] = f"{pkg_name}=={ver}{os.linesep}"

with open(req_path, "w", encoding="utf-8") as fw:
fw.writelines(lines)
10 changes: 0 additions & 10 deletions .azure/gpu-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ jobs:
echo "##vso[task.setvariable variable=TORCH_URL]https://download.pytorch.org/whl/cu${cuda_ver}/torch_stable.html"
displayName: 'set env. vars'

- bash: |
pip install -e . --find-links ${TORCH_URL}
git checkout -- setup.py MANIFEST.in
carmocca marked this conversation as resolved.
Show resolved Hide resolved
env:
PACKAGE_NAME: lite
FREEZE_REQUIREMENTS: 1
# Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi
# also installing from source not from on-the-fly created package tp prevent accidental interaction with cache
displayName: 'Install Lite pkg'

- bash: |
pip install -e .[strategies] --find-links ${TORCH_URL}
pip list
Expand Down
10 changes: 0 additions & 10 deletions .azure/gpu-tests-pytorch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,6 @@ jobs:
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/examples.txt ${PYTORCH_VERSION}
displayName: 'Adjust dependencies'

- bash: |
pip install -e . --find-links ${TORCH_URL}
git checkout -- setup.py MANIFEST.in
env:
PACKAGE_NAME: "lite"
FREEZE_REQUIREMENTS: "1"
# Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi
# also installing from source not from on-the-fly created package to prevent accidental interaction with cache
displayName: 'Install Lite pkg'

- bash: pip install -e .[strategies] -r requirements/pytorch/devel.txt -r requirements/pytorch/examples.txt --find-links ${TORCH_URL}
env:
PACKAGE_NAME: "pytorch"
Expand Down
10 changes: 0 additions & 10 deletions .azure/hpu-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ jobs:
sudo pip install pip -U
displayName: 'Instance HW info'

- bash: |
pip install -e .
git checkout -- setup.py MANIFEST.in
env:
PACKAGE_NAME: "lite"
FREEZE_REQUIREMENTS: "1"
# Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi
# also installing from source not from on-the-fly created package to prevent accidental interaction with cache
displayName: 'Install Lite pkg'

- bash: |
set -e
pip --version
Expand Down
10 changes: 0 additions & 10 deletions .azure/ipu-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ jobs:
done
displayName: "Reset IPU devices"

- bash: |
pip install -e .
git checkout -- setup.py MANIFEST.in
env:
PACKAGE_NAME: "lite"
FREEZE_REQUIREMENTS: "1"
# Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi
# also installing from source not from on-the-fly created package tp prevent accidental interaction with cache
displayName: 'Install Lite pkg'

- bash: |
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/extra.txt
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/examples.txt
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/pkg-check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ runs:
shell: bash

- name: Unzip packages
if: ${{ inputs.pkg-name != '' }}
if: ${{ inputs.pkg-name != 'lightning' }}
working-directory: dist
run: for file in `ls *.gz`; do tar -xzf $file; done
shell: bash

- name: Check single pkg/folder
if: ${{ inputs.pkg-name != '' }}
if: ${{ inputs.pkg-name != 'lightning' }}
working-directory: dist
run: |
import os, glob, pathlib, shutil
Expand Down
27 changes: 10 additions & 17 deletions .github/actions/pkg-install/action.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,35 @@
name: Install and check package
description: installing and validationg the package
name: Install and validate the package
description: Install and validate the package

inputs:
pkg-name:
description: package name for import
required: false
default: ""
description: Package name to import
required: true
pip-flags:
description: additional pil install flags
description: Additional pip install flags
carmocca marked this conversation as resolved.
Show resolved Hide resolved
required: false
default: ""

runs:
using: "composite"
steps:
- name: Determine package name
if: ${{ inputs.pkg-import == '' }}
working-directory: ./dist
run: python -c "import glob ; ls = glob.glob('*.tar.gz') ; name = '_'.join(ls[0].split('-')[:-1]) ; print(f'PKG_NAME={name}')" >> $GITHUB_ENV
shell: bash

- name: Pass package name
if: ${{ inputs.pkg-import != '' }}
run: echo "PKG_NAME=${{ inputs.pkg-name }}" >> $GITHUB_ENV
- name: Choose package import
run: |
python -c "print('PKG_IMPORT=' + {'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning', 'lightning': 'lightning'}['${{matrix.pkg-name}}'])" >> $GITHUB_ENV
shell: bash

- name: Install package - archive
working-directory: ./dist
run: |
pip install *.tar.gz ${{ inputs.pip-flags }}
pip list | grep lightning
python -c "import ${PKG_NAME} ; print(${PKG_NAME}.__version__)"
python -c "import ${{ env.PKG_IMPORT }}; print(${{ env.PKG_IMPORT }}.__version__)"
shell: bash
carmocca marked this conversation as resolved.
Show resolved Hide resolved

- name: Install package - wheel
working-directory: ./dist
run: |
pip install *.whl ${{ inputs.pip-flags }}
pip list | grep lightning
python -c "import ${PKG_NAME} ; print(${PKG_NAME}.__version__)"
python -c "import ${{ env.PKG_IMPORT }}; print(${{ env.PKG_IMPORT }}.__version__)"
shell: bash
3 changes: 1 addition & 2 deletions .github/workflows/ci-app-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ jobs:
- name: Adjust examples
if: ${{ matrix.pkg-name != 'lightning' }}
run: |
python .actions/assistant.py copy_replace_imports --source_dir="./examples" --source_import="lightning.app" --target_import="lightning_app"
python .actions/assistant.py copy_replace_imports --source_dir="./examples" --source_import="lightning" --target_import="lightning_app"
python .actions/assistant.py copy_replace_imports --source_dir="./examples" --source_import="lightning.app,lightning" --target_import="lightning_app,lightning_app"

- name: Switch coverage scope
run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci-app-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ jobs:
- name: Adjust examples
if: ${{ matrix.pkg-name != 'lightning' }}
run: |
python .actions/assistant.py copy_replace_imports --source_dir="./examples" --source_import="lightning.app" --target_import="lightning_app"
python .actions/assistant.py copy_replace_imports --source_dir="./examples" --source_import="lightning" --target_import="lightning_app"
python .actions/assistant.py copy_replace_imports --source_dir="./examples" --source_import="lightning.app,lightning" --target_import="lightning_app,lightning_app"
carmocca marked this conversation as resolved.
Show resolved Hide resolved

- name: Switch coverage scope
run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV
Expand Down
58 changes: 7 additions & 51 deletions .github/workflows/ci-pkg-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,56 +23,17 @@ defaults:
shell: bash

jobs:

init-pypi:
runs-on: ubuntu-20.04
steps:
- run: mkdir pypi && touch pypi/.placeholder
- uses: actions/upload-artifact@v3
with:
name: ci-packages-${{ github.sha }}
path: pypi

build-pypi:
needs: init-pypi
# This serves to create packages for potential internal dependencies
runs-on: ubuntu-20.04
strategy:
fail-fast: true
max-parallel: 1
matrix:
pkg-name: ["lite"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- uses: actions/download-artifact@v3
with:
name: ci-packages-${{ github.sha }}
path: pypi
- name: Build package
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
run: |
python setup.py sdist
cp dist/* pypi/
- uses: actions/upload-artifact@v3
with:
name: ci-packages-${{ github.sha }}
path: pypi

install-pkg:
needs: build-pypi
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macOS-12, windows-2022]
pkg-name: ["app", "lite", "pytorch", ""]
pkg-name: ["app", "lite", "pytorch", "lightning"]
carmocca marked this conversation as resolved.
Show resolved Hide resolved
python-version: ["3.7" , "3.10"]
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -84,27 +45,22 @@ jobs:
python -m pytest setup_tools.py

- run: python -c "print('NB_DIRS=' + str(2 if '${{ matrix.pkg-name }}' == 'pytorch' else 1))" >> $GITHUB_ENV

- uses: ./.github/actions/pkg-check
with:
pkg-name: ${{ matrix.pkg-name }}
nb-dirs: ${{ env.NB_DIRS }}

- uses: actions/download-artifact@v3
with:
name: ci-packages-${{ github.sha }}
path: pypi
- run: ls -l pypi/
- uses: ./.github/actions/pkg-install
with:
pip-flags: "--pre --find-links ../pypi/"
pkg-name: ${{ matrix.pkg-name }}

- name: Run CLI
# todo: add testing for `lightning_app`
if: ${{ matrix.pkg-name == '' }}
if: ${{ matrix.pkg-name == 'lightning' }}
run: python -m lightning --version

- name: DocTest package
run: |
pip list
scope=$(python -c "lut = {'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning'} ; print(lut.get('${{matrix.pkg-name}}', 'lightning'))")
python -m pytest src/${scope} --ignore-glob="**/cli/*-template/**"
PKG_NAME=$(python -c "print({'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning', 'lightning': 'lightning'}['${{matrix.pkg-name}}'])")
python -m pytest src/${PKG_NAME} --ignore-glob="**/cli/*-template/**"
9 changes: 0 additions & 9 deletions .github/workflows/ci-pytorch-tests-slow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-py${{ matrix.python-version }}-

- name: Install lite for PL
# Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi
# also installing from source not from on-the-fly created package to prevent accidental interaction with cache
env:
PACKAGE_NAME: "lite"
run: |
pip install -e . --upgrade --find-links https://download.pytorch.org/whl/cpu/torch_stable.html
git checkout -- setup.py MANIFEST.in

- name: Install package & dependencies
env:
PACKAGE_NAME: "pytorch"
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/ci-pytorch-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,6 @@ jobs:
- name: Switch PyTorch URL
run: python -c "print('TORCH_URL=https://download.pytorch.org/whl/' + str('test/cpu/torch_test.html' if '${{matrix.release}}' == 'pre' else 'cpu/torch_stable.html'))" >> $GITHUB_ENV

- name: Install lite for PL
# Lite shall have pin version, so to keep development aligned we need to install lite from source not from pypi
# also installing from source not from on-the-fly created package tp prevent accidental interaction with cache
if: ${{ matrix.pkg-name != 'lightning' }}
env:
PACKAGE_NAME: "lite"
run: |
pip install -e . --upgrade --find-links ${TORCH_URL}
git checkout -- setup.py MANIFEST.in

- name: Install package & dependencies
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
Expand Down
Loading