diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 0a6303c..45ba597 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -12,6 +12,7 @@ concurrency: jobs: test-cpython: + if: false runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -35,6 +36,7 @@ jobs: run: nox -s tests_venv_current test-conda: + if: false runs-on: ${{ matrix.os }} strategy: matrix: @@ -61,6 +63,7 @@ jobs: uses: mxschmitt/action-tmate@v3 test-twine: + if: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 78b4064..82e573f 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -1,9 +1,10 @@ name: performance on: -# push: -# branches: [ main ] -# paths: [ '**.py', 'src/**' ] + release: + types: [ published ] + pull_request: + branches: [ main ] workflow_dispatch: concurrency: @@ -12,9 +13,12 @@ concurrency: jobs: perf-import: + if: false runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: + python: [ '3.8', '3.9', '3.10', '3.11', '3.12' ] os: [ ubuntu-latest, macOS-latest, windows-latest ] steps: @@ -25,26 +29,70 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install nox pyperf + python -m pip install nox - name: Perf importing third-party packages + continue-on-error: true + env: + RUN: LONG run: | - sh scripts/perf_import.sh + nox -s test_import_third_party_perf-${{ matrix.python }} + - uses: actions/upload-artifact@v3 + with: + name: perf-import + path: "*.json" + + perf-import-result: + runs-on: ubuntu-latest + needs: [ perf-import ] + steps: + - uses: actions/setup-python@v4 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pyperf + + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: perf-import + path: ./ + - name: Result + run: | + for VERSION in 3.8 3.9 3.10 3.11 3.12 + do + for OS in linux darwin windows + do + pyperf compare_to perf-import-$VERSION-$OS-raw.json perf-import-$VERSION-$OS-cds.json --table | tee perf-import-$VERSION-$OS.table + done + done + - uses: actions/upload-artifact@v3 + with: + name: perf-import + path: "*.table" pyperformance: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: + python: [ '3.8', '3.9', '3.10', '3.11', '3.12' ] os: [ ubuntu-latest, macOS-latest, windows-latest ] steps: - uses: actions/checkout@v4 - - uses: s-weigand/setup-conda@v1 + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v4 with: - conda-channels: conda-forge + python-version: ${{ matrix.python }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install nox pyperf + python -m pip install nox - name: Pyperformance tests against cds + continue-on-error: true run: | - sh scripts/pyperformance.sh + nox -s pyperformance + - uses: actions/upload-artifact@v3 + with: + name: pyperformance + path: "*.json" diff --git a/noxfile.py b/noxfile.py index 695a7fc..c04fb51 100644 --- a/noxfile.py +++ b/noxfile.py @@ -3,6 +3,7 @@ """ import os import platform +import shutil import typing as t import nox @@ -19,7 +20,7 @@ GA = os.environ.get('GITHUB_ACTIONS') == 'true' -CDS_PYPERFORMANCE = 'git+https://github.com/oraluben/pyperformance.git@cds' +CDS_PYPERFORMANCE = 'git+https://github.com/oraluben/pyperformance.git@cds-dev' def _clean_nox(): @@ -43,6 +44,16 @@ def _py_version(session: nox.Session): return out +def _perf_config() -> t.List[str]: + result = [] + _run = os.environ.get('RUN', '').lower() + if _run in ('fast', 'short'): + result.append('--fast') + elif _run in ('long', 'rigorous'): + result.append('--rigorous') + return result + + def _self_tests(session: nox.Session): session.install(".") session.install("pytest") @@ -120,7 +131,7 @@ def tests_multiple_conda(session: nox.Session): # conda-provided tf might require pypy and this is not what we want, # and pypi only provides tf for CPython <= 3.11 Package('tensorflow', skip=lambda _py: _py in ('3.12',)), - Package('seaborn', conda=True), + Package('seaborn', conda=True, skip=lambda _py: OS == 'Windows'), Package('azureml-core', module='azureml.core'), Package('opencv-python', module='cv2') @@ -177,24 +188,26 @@ def test_import_third_party_perf(session: nox.Session, package): session.run('python', '-c', package.import_stmt, env={'PYCDSMODE': 'SHARE', 'PYCDSARCHIVE': img}, log=False) logger.info(f'finish generating CDS archive for {package.name}') - raw_out = f'perf-import-{session.python}-raw' - cds_out = f'perf-import-{session.python}-cds' + raw_out = f'perf-import-{session.python}-{OS.lower()}-raw' + cds_out = f'perf-import-{session.python}-{OS.lower()}-cds' - session.run('pyperf', 'command', '--fast', f'--append={raw_out}.json', f'--name={package.name}', + base_cmd = ['pyperf', 'command'] + _perf_config() + [f'--name={package.name}'] + + session.run(*base_cmd, f'--append={raw_out}.json', 'python', '-c', package.import_stmt) - session.run('pyperf', 'command', '--fast', f'--append={cds_out}.json', f'--name={package.name}', - '--inherit-environ=PYCDSMODE,PYCDSARCHIVE', + session.run(*base_cmd, f'--append={cds_out}.json', '--inherit-environ=PYCDSMODE,PYCDSARCHIVE', 'python', '-c', package.import_stmt, env={'PYCDSMODE': 'SHARE', 'PYCDSARCHIVE': img}) ci_session_cleanup() -def _pyperformance(session: nox.Session, pyperformance_args=None): +@nox.session(venv_backend='venv') +def pyperformance(session: nox.Session): session.install(CDS_PYPERFORMANCE) configs = [ - (os.path.realpath(f'pyperformance-{_py_version(session)}-{config_name}.json'), config_args) + (os.path.realpath(f'pyperformance-{_py_version(session)}-{OS.lower()}-{config_name}.json'), config_args) for (config_name, config_args) in [ ('raw', []), ('cds-site', ['--install-cds', PYCDS_ROOT]), @@ -205,15 +218,14 @@ def _pyperformance(session: nox.Session, pyperformance_args=None): tmp = session.create_tmp() session.chdir(tmp) - if pyperformance_args is None: - pyperformance_args = ['pyperformance', 'run'] + pyperformance_cmd = ['pyperformance', 'run'] + _perf_config() cmd_exc = None for out, args in configs: if os.path.exists(out): - session.run('mv', out, out + '.old') + shutil.move(out, out + '.old') try: - session.run(*(pyperformance_args + args), f'--out={out}') + session.run(*(pyperformance_cmd + args), f'--out={out}') except CommandFailed as e: if cmd_exc is None: cmd_exc = e @@ -222,21 +234,6 @@ def _pyperformance(session: nox.Session, pyperformance_args=None): raise cmd_exc -@nox.session(venv_backend='venv') -def pyperformance_current(session: nox.Session): - _pyperformance(session, ['pyperformance', 'run', '--fast']) - - -@nox.session(python=SUPPORTED_PYTHONS) -def pyperformance(session: nox.Session): - _pyperformance(session, ['pyperformance', 'run', '--fast']) - - -@nox.session(python=SUPPORTED_PYTHONS) -def pyperformance_looong(session: nox.Session): - _pyperformance(session, ['pyperformance', 'run', '--rigorous']) - - @nox.session(venv_backend='venv') def build_sdist(session: nox.Session): """