From 65d09f1c285cbd103757cc0edf4d05c7876c49bb Mon Sep 17 00:00:00 2001 From: Enrique Gonzalez Paredes Date: Tue, 21 Jan 2025 14:31:50 +0100 Subject: [PATCH] Fixes --- .github/workflows/daily-ci.yml | 128 ++++++++++++++---- .github/workflows/test-cartesian.yml | 4 +- .github/workflows/test-docs.yml | 44 +++++++ .github/workflows/test-eve.yml | 2 +- .github/workflows/test-next.yml | 4 +- .github/workflows/test-notebooks.yml | 42 ------ .github/workflows/test-storage.yml | 2 +- noxfile.py | 65 +++++---- tox.ini | 190 --------------------------- 9 files changed, 189 insertions(+), 292 deletions(-) create mode 100644 .github/workflows/test-docs.yml delete mode 100644 .github/workflows/test-notebooks.yml delete mode 100644 tox.ini diff --git a/.github/workflows/daily-ci.yml b/.github/workflows/daily-ci.yml index dc5993770e..3b176d642e 100644 --- a/.github/workflows/daily-ci.yml +++ b/.github/workflows/daily-ci.yml @@ -5,7 +5,8 @@ on: - cron: '0 4 * * *' workflow_dispatch: - # COMMENTED OUT: only for testing CI action changes + # COMMENTED OUT: only for testing CI action changes. + # It only works for PRs to `main` branch from branches in the same gt4py repo. pull_request: branches: - main @@ -23,51 +24,120 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Install C++ libraries - if: ${{ matrix.os == 'macos-latest' }} - shell: bash - run: brew install boost + - name: Get current date + id: date + run: | + echo "{day_of_the_week}={$(date +'%u')}" >> $GITHUB_STATE - - name: Install C++ libraries - if: ${{ matrix.os == 'ubuntu-latest' }} - shell: bash - run: sudo apt install libboost-dev - - - name: Install uv and set the python version - uses: astral-sh/setup-uv@v5 + - name: Weekly notification + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + uses: slackapi/slack-github-action@v1.23.0 with: - enable-cache: true - cache-dependency-glob: "uv.lock" - python-version: ${{ matrix.python-version }} - - # - name: Update requirements - # run: uv lock --resolution=${{ matrix.dependencies-factor }} --prerelease=allow + channel-id: ${{ vars.SLACK_BOT_CHANNEL_TEST }} + payload: | + { + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "Weekly reminder to check the latest runs of the workflow at the ." + } + } + ] + } - - name: Run CPU tests for '${{ matrix.module-factor }}' with '${{ matrix.dependencies-factor }}' resolution strategy + - name: Test with environment variables + if: ${{ env.day_of_the_week == '3' }} env: - NUM_PROCESSES: auto - UV_RESOLUTION: ${{ matrix.dependencies-factor }} - run: uv run nox -s '${{ matrix.module-factor }}_tests-${{ matrix.python-version }}' -t 'cpu' - - - name: Notify slack - if: ${{ failure() }} + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + uses: slackapi/slack-github-action@v1.23.0 + with: + channel-id: ${{ vars.SLACK_BOT_CHANNEL_TEST }} + payload: | + { + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "if3 Weekly reminder to check the latest runs of the workflow at the ." + } + } + ] + } + + - name: Test not + if: ${{ env.day_of_the_week != '3' }} env: SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} uses: slackapi/slack-github-action@v1.23.0 with: - channel-id: ${{ vars.SLACK_BOT_CHANNEL }} + channel-id: ${{ vars.SLACK_BOT_CHANNEL_TEST }} payload: | { - "text": "${{ github.workflow }}: `Daily CI: '**${{ matrix.module-factor }} (CPU)** for **Python-${{ matrix.python-version }}**>: *Failed tests!*", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", - "text": ": *Failed tests!*" + "text": "ifnot3 Weekly reminder to check the latest runs of the workflow at the ." } } ] } + + + + # - uses: actions/checkout@v4 + + # - name: Install C++ libraries + # if: ${{ matrix.os == 'macos-latest' }} + # shell: bash + # run: brew install boost + + # - name: Install C++ libraries + # if: ${{ matrix.os == 'ubuntu-latest' }} + # shell: bash + # run: sudo apt install libboost-dev + + # - name: Install uv and set the python version + # uses: astral-sh/setup-uv@v5 + # with: + # enable-cache: true + # cache-dependency-glob: "uv.lock" + # python-version: ${{ matrix.python-version }} + + # - name: Run CPU tests for '${{ matrix.module-factor }}' with '${{ matrix.dependencies-factor }}' resolution strategy + # env: + # NUM_PROCESSES: auto + # UV_RESOLUTION: ${{ matrix.dependencies-factor }} + # run: uv run nox -s 'test_${{ matrix.module-factor }}-${{ matrix.python-version }}' -t 'cpu' + + + # - name: Notify slack + # #if: ${{ failure() }} + # env: + # SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + # uses: slackapi/slack-github-action@v1.23.0 + # with: + # channel-id: ${{ vars.SLACK_BOT_CHANNEL_TEST }} + # # payload: | + # # { + # # "text": "${{ github.workflow }}: Daily CI: '**${{ matrix.module-factor }} (CPU)** for **Python-${{ matrix.python-version }}**>: *Failed tests!*" + # # } + # payload: | + # { + # "text": "${{ github.workflow }}: Daily CI: '**${{ matrix.module-factor }} (CPU)** for **Python-${{ matrix.python-version }}**: *Failed tests!*", + # "blocks": [ + # { + # "type": "section", + # "text": { + # "type": "mrkdwn", + # "text": ": *Failed tests!*" + # } + # } + # ] + # } diff --git a/.github/workflows/test-cartesian.yml b/.github/workflows/test-cartesian.yml index 0297d5a257..ea6b7940a3 100644 --- a/.github/workflows/test-cartesian.yml +++ b/.github/workflows/test-cartesian.yml @@ -7,7 +7,7 @@ on: pull_request: branches: - main - paths-ignore: # Skip if only gt4py.next and irrelevant doc files have been updated + paths-ignore: # Skip when only gt4py.next or doc files have been updated - "src/gt4py/next/**" - "tests/next_tests/**" - "examples/**" @@ -52,4 +52,4 @@ jobs: env: NUM_PROCESSES: auto shell: bash - run: uv run nox -s 'cartesian_tests-${{ matrix.python-version }}(${{ matrix.codegen-factor }}, cpu)' + run: uv run nox -s 'test_cartesian-${{ matrix.python-version }}(${{ matrix.codegen-factor }}, cpu)' diff --git a/.github/workflows/test-docs.yml b/.github/workflows/test-docs.yml new file mode 100644 index 0000000000..a9bd81e141 --- /dev/null +++ b/.github/workflows/test-docs.yml @@ -0,0 +1,44 @@ +name: "Test Jupyter Notebooks" + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test-notebooks: + strategy: + matrix: + os: ["ubuntu-latest"] + python-version: ["3.10", "3.11"] + fail-fast: false + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Install C++ libraries + if: ${{ matrix.os == 'macos-latest' }} + shell: bash + run: brew install boost + + - name: Install C++ libraries + if: ${{ matrix.os == 'ubuntu-latest' }} + shell: bash + run: sudo apt install libboost-dev + + - name: Install uv and set the python version + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + cache-dependency-glob: "uv.lock" + python-version: ${{ matrix.python-version }} + + - name: Run 'docs' nox session + env: + NUM_PROCESSES: auto + shell: bash + run: uv run nox -s 'test_docs-${{ matrix.python-version }}' diff --git a/.github/workflows/test-eve.yml b/.github/workflows/test-eve.yml index 2d9f577878..aad3971ad0 100644 --- a/.github/workflows/test-eve.yml +++ b/.github/workflows/test-eve.yml @@ -38,4 +38,4 @@ jobs: env: NUM_PROCESSES: auto shell: bash - run: uv run nox -s eve_tests-${{ matrix.python-version }} + run: uv run nox -s test_eve-${{ matrix.python-version }} diff --git a/.github/workflows/test-next.yml b/.github/workflows/test-next.yml index 3c9a1cf348..068377c6c7 100644 --- a/.github/workflows/test-next.yml +++ b/.github/workflows/test-next.yml @@ -7,7 +7,7 @@ on: pull_request: branches: - main - paths-ignore: # Skip if only gt4py.cartesian and irrelevant doc files have been updated + paths-ignore: # Skip when only gt4py.cartesian or doc files have been updated - "src/gt4py/cartesian/**" - "tests/cartesian_tests/**" - "examples/**" @@ -49,4 +49,4 @@ jobs: env: NUM_PROCESSES: auto shell: bash - run: uv run nox -s 'next_tests-${{ matrix.python-version }}(${{ matrix.codegen-factor }}, cpu, ${{ matrix.mesh-factor }})' + run: uv run nox -s 'test_next-${{ matrix.python-version }}(${{ matrix.codegen-factor }}, cpu, ${{ matrix.mesh-factor }})' diff --git a/.github/workflows/test-notebooks.yml b/.github/workflows/test-notebooks.yml deleted file mode 100644 index ae45cb154d..0000000000 --- a/.github/workflows/test-notebooks.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: "Test Jupyter Notebooks" - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - test-notebooks: - strategy: - matrix: - python-version: ["3.10", "3.11"] - os: ["ubuntu-latest"] - fail-fast: false - - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: | - **/pyproject.toml - **/constraints.txt - **/requirements-dev.txt - - name: Install python dependencies - run: | - python -m pip install -c ./constraints.txt pip setuptools wheel - python -m pip install -r ./requirements-dev.txt - - name: Run tox tests - env: - NUM_PROCESSES: auto - shell: bash - run: | - pyversion=${{ matrix.python-version }} - pyversion_no_dot=${pyversion//./} - tox run -e notebooks-py${pyversion_no_dot} diff --git a/.github/workflows/test-storage.yml b/.github/workflows/test-storage.yml index b2baed5542..b2bb09dfcc 100644 --- a/.github/workflows/test-storage.yml +++ b/.github/workflows/test-storage.yml @@ -39,4 +39,4 @@ jobs: env: NUM_PROCESSES: auto shell: bash - run: uv run nox -s 'storage_tests-${{ matrix.python-version }}(cpu)' + run: uv run nox -s 'test_storage-${{ matrix.python-version }}(cpu)' diff --git a/noxfile.py b/noxfile.py index a9187197d9..c5cd701218 100644 --- a/noxfile.py +++ b/noxfile.py @@ -26,18 +26,18 @@ # -- nox configuration -- nox.options.default_venv_backend = "uv" nox.options.sessions = [ - "cartesian_tests-3.10(internal, cpu)", - "cartesian_tests-3.10(dace, cpu)", - "cartesian_tests-3.11(internal, cpu)", - "cartesian_tests-3.11(dace, cpu)", - "eve_tests-3.10", - "eve_tests-3.11", - "next_tests-3.10(internal, cpu, nomesh)", - "next_tests-3.10(dace, cpu, nomesh)", - "next_tests-3.11(internal, cpu, nomesh)", - "next_tests-3.11(dace, cpu, nomesh)", - "storage_tests-3.10(cpu)", - "storage_tests-3.11(cpu)", + "test_cartesian-3.10(internal, cpu)", + "test_cartesian-3.10(dace, cpu)", + "test_cartesian-3.11(internal, cpu)", + "test_cartesian-3.11(dace, cpu)", + "test_eve-3.10", + "test_eve-3.11", + "test_next-3.10(internal, cpu, nomesh)", + "test_next-3.10(dace, cpu, nomesh)", + "test_next-3.11(internal, cpu, nomesh)", + "test_next-3.11(dace, cpu, nomesh)", + "test_storage-3.10(cpu)", + "test_storage-3.11(cpu)", ] # -- Parameter sets -- @@ -70,7 +70,7 @@ @nox.session(python=["3.10", "3.11"], tags=["cartesian"]) @nox.parametrize("device", [DeviceNoxParam.cpu, DeviceNoxParam.cuda12]) @nox.parametrize("codegen", [CodeGenNoxParam.internal, CodeGenNoxParam.dace]) -def cartesian_tests( +def test_cartesian( session: nox.Session, codegen: CodeGenOption, device: DeviceOption, @@ -101,8 +101,30 @@ def cartesian_tests( ) +@nox.session(python=["3.10", "3.11"]) +def test_docs(session: nox.Session) -> None: + """Run and test documentation workflows.""" + + _install_session_venv(session, extras=["testing"], groups=["docs", "test"]) + + session.run(*"jupytext docs/user/next/QuickstartGuide.md --to .ipynb".split()) + session.run(*"jupytext docs/user/next/advanced/*.md --to .ipynb".split()) + + num_processes = session.env.get("NUM_PROCESSES", "auto") + for notebook in [ + "docs/user/next/workshop/slides", + "docs/user/next/workshop/exercises", + "docs/user/next/QuickstartGuide.ipynb", + "docs/user/next/advanced", + "examples", + ]: + session.run( + *f"pytest --nbmake {notebook} -sv -n {num_processes}".split(), + ) + + @nox.session(python=["3.10", "3.11"], tags=["cartesian", "next", "cpu"]) -def eve_tests(session: nox.Session) -> None: +def test_eve(session: nox.Session) -> None: """Run 'gt4py.eve' tests.""" _install_session_venv(session, groups=["test"]) @@ -130,7 +152,7 @@ def eve_tests(session: nox.Session) -> None: ) @nox.parametrize("device", [DeviceNoxParam.cpu, DeviceNoxParam.cuda12]) @nox.parametrize("codegen", [CodeGenNoxParam.internal, CodeGenNoxParam.dace]) -def next_tests( +def test_next( session: nox.Session, codegen: CodeGenOption, device: DeviceOption, @@ -170,7 +192,7 @@ def next_tests( @nox.session(python=["3.10", "3.11"], tags=["cartesian", "next"]) @nox.parametrize("device", [DeviceNoxParam.cpu, DeviceNoxParam.cuda12]) -def storage_tests( +def test_storage( session: nox.Session, device: DeviceOption, ) -> None: @@ -206,21 +228,14 @@ def _install_session_venv( groups: Sequence[str] = (), ) -> None: """Install session packages using uv.""" - uv_venv = { - key: value - for key, value in os.environ.items() - if key.startswith("NOX") - or key.startswith("PYTEST_") - or key.startswith("PYTHON") - or key.startswith("UV_") - } | {"UV_PROJECT_ENVIRONMENT": session.virtualenv.location} session.run_install( "uv", "sync", "--no-dev", *(f"--extra={e}" for e in extras), *(f"--group={g}" for g in groups), - env=uv_venv, + env={key: value for key, value in os.environ.items()} + | {"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}, ) for item in args: session.run_install( diff --git a/tox.ini b/tox.ini deleted file mode 100644 index e7bfd4a3e4..0000000000 --- a/tox.ini +++ /dev/null @@ -1,190 +0,0 @@ -[tox] -requires = - tox>=4.2 - virtualenv>20.2 -envlist = - cartesian-py{310}-{internal,dace}-{cpu} - eve-py{310} - next-py{310}-{nomesh,atlas}-{cpu} - storage-py{310}-{internal,dace}-{cpu} - # docs -labels = - test-cartesian-cpu = cartesian-internal-py310-cpu, cartesian-py311-internal-cpu, cartesian-py310-dace-cpu, cartesian-py311-dace-cpu - test-eve-cpu = eve-py310, eve-py311 - test-next-cpu = next-py310-nomesh-cpu, next-py311-nomesh-cpu, next-py310-atlas-cpu, next-py311-atlas-cpu - test-storage-cpu = storage-py310-internal-cpu, storage-py311-internal-cpu, storage-py310-dace-cpu, storage-py311-dace-cpu - test-cpu = cartesian-py310-internal-cpu, cartesian-py311-internal-cpu, cartesian-py310-dace-cpu, cartesian-py311-dace-cpu, \ - eve-py310, eve-py311, \ - next-py310-nomesh-cpu, next-py311-nomesh-cpu, next-py310-atlas-cpu, next-py311-atlas-cpu, \ - storage-py310-internal-cpu, storage-py311-internal-cpu, storage-py310-dace-cpu, storage-py311-dace-cpu - -[testenv] -deps = -r {tox_root}{/}{env:ENV_REQUIREMENTS_FILE:requirements-dev.txt} -constrain_package_deps = true -use_frozen_constraints = true -extras = - testing - formatting - dace: dace - cuda: cuda - cuda11x: cuda11x - cuda12x: cuda12x -package = wheel -wheel_build_env = .pkg -pass_env = CUDAARCHS, NUM_PROCESSES, GT4PY_* -set_env = - PYTEST_ADDOPTS = --color=auto --instafail - PYTHONWARNINGS = {env:PYTHONWARNINGS:ignore:Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*:UserWarning,ignore:Field View Program:UserWarning} - -# -- Primary tests -- -[testenv:cartesian-py{310,311}-{internal,dace}-{cpu,cuda,cuda11x,cuda12x}] -description = Run 'gt4py.cartesian' tests -pass_env = {[testenv]pass_env}, BOOST_ROOT, BOOST_HOME, CUDA_HOME, CUDA_PATH, CXX, CC, OPENMP_CPPFLAGS, OPENMP_LDFLAGS, PIP_USER, PYTHONUSERBASE -allowlist_externals = - make - gcc - g++ - ldd - rm -commands = - python -m pytest --cache-clear -v -n {env:NUM_PROCESSES:1} -m "\ - internal: not requires_dace \ - dace: requires_dace \ - cpu: and not requires_gpu \ - {cuda,cuda11x,cuda12x}: and requires_gpu \ - " {posargs} tests{/}cartesian_tests - python -m pytest --doctest-modules --doctest-ignore-import-errors src{/}gt4py{/}cartesian -# commands_pre = -# rm -Rf tests/_reports/coverage* -# commands_post = -# coverage json --rcfile=setup.cfg -# coverage html --rcfile=setup.cfg --show-contexts - -[testenv:eve-py{310,311}] -description = Run 'gt4py.eve' tests -commands = - python -m pytest --cache-clear -v -n {env:NUM_PROCESSES:1} {posargs} tests{/}eve_tests - python -m pytest --doctest-modules src{/}gt4py{/}eve - -[testenv:next-py{310,311}-{nomesh,atlas}-{cpu,cuda,cuda11x,cuda12x}] -description = Run 'gt4py.next' tests -pass_env = {[testenv]pass_env}, BOOST_ROOT, BOOST_HOME, CUDA_HOME, CUDA_PATH -deps = - -r {tox_root}{/}requirements-dev.txt - atlas: atlas4py -set_env = - {[testenv]set_env} - PIP_EXTRA_INDEX_URL = {env:PIP_EXTRA_INDEX_URL:https://test.pypi.org/simple/} -commands = - python -m pytest --suppress-no-test-exit-code --cache-clear -v -n {env:NUM_PROCESSES:1} -m "\ - nomesh: not requires_atlas \ - atlas: requires_atlas \ - cpu: and not requires_gpu \ - {cuda,cuda11x,cuda12x}: and requires_gpu \ - " {posargs} tests{/}next_tests - pytest --doctest-modules src{/}gt4py{/}next - -[testenv:storage-py{310,311}-{internal,dace}-{cpu,cuda,cuda11x,cuda12x}] -description = Run 'gt4py.storage' tests -commands = - python -m pytest --cache-clear -v -n {env:NUM_PROCESSES:1} -m "\ - cpu: not requires_gpu \ - {cuda,cuda11x,cuda12x}: requires_gpu \ - " {posargs} tests{/}storage_tests - # pytest doctest-modules {posargs} src{/}gt4py{/}storage - -# -- Secondary tests -- -[testenv:notebooks-py{310,311}] -description = Run notebooks -commands_pre = - jupytext docs/user/next/QuickstartGuide.md --to .ipynb - jupytext docs/user/next/advanced/*.md --to .ipynb -commands = - python -m pytest --nbmake docs/user/next/workshop/slides -v -n {env:NUM_PROCESSES:1} - python -m pytest --nbmake docs/user/next/workshop/exercises -k 'solutions' -v -n {env:NUM_PROCESSES:1} - python -m pytest --nbmake docs/user/next/QuickstartGuide.ipynb -v -n {env:NUM_PROCESSES:1} - python -m pytest --nbmake docs/user/next/advanced -v -n {env:NUM_PROCESSES:1} - python -m pytest --nbmake examples -v -n {env:NUM_PROCESSES:1} - -# -- Other artefacts -- -[testenv:dev-py{310,311}{-atlas,}] -description = Initialize development environment for gt4py -deps = - -r {tox_root}{/}requirements-dev.txt - atlas: atlas4py -package = editable-legacy # => use_develop = True -set_env = - {[testenv]set_env} - PIP_EXTRA_INDEX_URL = {env:PIP_EXTRA_INDEX_URL:https://test.pypi.org/simple/} - -# [testenv:diagrams] -# install_command = echo {packages} -# skip_install = true -# allowlist_externals = -# /bin/bash -# make -# gcc -# g++ -# ldd -# rm -# plantuml -# git -# echo -# changedir = docs/development/ADRs -# commands = -# plantuml ./*.md -tsvg -o _static -# git add _static -# commands_post = - -[testenv:requirements-{base,py310,py311}] -description = - base: Update pinned development requirements - py310: Update requirements for testing a specific python version - py311: Update requirements for testing a specific python version -base_python = - base: py310 - py310: py310 - py311: py311 -deps = - cogapp>=3.3 - packaging>=20.0 - pip-tools>=6.10 -package = skip -set_env = - CUSTOM_COMPILE_COMMAND = "tox run -e requirements-base" -allowlist_externals = - mv -commands = - -mv constraints.txt constraints.txt.old - -mv requirements-dev.txt requirements-dev.old - # Run cog to update requirements files from pyproject - cog -r -P min-requirements-test.txt min-extra-requirements-test.txt - # Generate constraints file removing extras - # (extras are not supported by pip in constraints files) - pip-compile -r --resolver=backtracking \ - --annotation-style line \ - --build-isolation \ - --strip-extras \ - --allow-unsafe \ - --extra dace \ - --extra formatting \ - --extra jax-cpu \ - --extra performance \ - --extra testing \ - -o constraints.txt \ - pyproject.toml requirements-dev.in - # Generate actual requirements file - # (compiling from scratch again to print actual package sources) - pip-compile --resolver=backtracking \ - --annotation-style line \ - --build-isolation \ - --allow-unsafe \ - --extra dace \ - --extra formatting \ - --extra jax-cpu \ - --extra testing \ - -c constraints.txt \ - -o requirements-dev.txt \ - pyproject.toml requirements-dev.in - # Run cog to update .pre-commit-config.yaml with new versions - base: cog -r -P .pre-commit-config.yaml