Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: astral-sh/setup-uv@v5
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use ruff-action? I don't recall why we went with installing it manually when we switched..

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole point of this PR is to encode ruff version ranges in pyproject.toml. AFAICT, ruff-action ignores that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if that was the case in the past, but their documentation says they do read pyproject.toml to get the version: https://github.com/astral-sh/ruff-action?tab=readme-ov-file#install-specific-versions

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, I find the version with uv easier to reason about. In addition, the actions thing wouldn't work on Gitlab, so then that would just introduce inconsistency.

- name: "Main Script"
run: |
pipx install ruff
ruff check
uv run --only-dev ruff check

typos:
name: Typos
Expand Down
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ Documentation:

Ruff:
script:
- pipx install ruff
- ruff check
- pipx install uv
- uv run --only-dev ruff check
tags:
- docker-runner
except:
Expand Down
3 changes: 2 additions & 1 deletion loopy/kernel/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
THE SOFTWARE.
"""

import itertools
import logging
import sys
from functools import reduce
Expand Down Expand Up @@ -1709,7 +1710,7 @@ def get_global_barrier_order(kernel):
visited = set()
visiting = set()

for prev_barrier, barrier in zip(barriers, barriers[1:]):
for prev_barrier, barrier in itertools.pairwise(barriers):
# Check if prev_barrier is reachable from barrier.
stack = [barrier]
visited.discard(prev_barrier)
Expand Down
7 changes: 4 additions & 3 deletions loopy/schedule/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"""

import enum
import itertools
from dataclasses import dataclass
from functools import cached_property, reduce
from typing import TYPE_CHECKING, AbstractSet, Sequence
Expand Down Expand Up @@ -752,7 +753,7 @@ def separate_loop_nest(

loop_nests = sorted(loop_nests, key=lambda nest: tree.depth(nest))

for outer, inner in zip(loop_nests[:-1], loop_nests[1:]):
for outer, inner in itertools.pairwise(loop_nests):
if outer != tree.parent(inner):
raise LoopyError(f"Cannot schedule loop nest {inames_to_separate} "
f" in the nesting tree:\n{tree}")
Expand Down Expand Up @@ -846,7 +847,7 @@ def _update_nesting_constraints(
priorities cannot be met.
"""
for priority in priorities:
for outer_iname, inner_iname in zip(priority[:-1], priority[1:]):
for outer_iname, inner_iname in itertools.pairwise(priority):
if inner_iname not in iname_to_tree_node_id:
cannot_satisfy_callback(f"Cannot enforce the constraint:"
f" {inner_iname} to be nested within"
Expand Down Expand Up @@ -929,7 +930,7 @@ def _raise_loopy_err(x):
new_tree = new_tree.add_node(ordered_nest[0],
parent=old_to_new_parent[not_none(loop_nest_tree
.parent(current_nest))])
for new_parent, new_child in zip(ordered_nest[:-1], ordered_nest[1:]):
for new_parent, new_child in itertools.pairwise(ordered_nest):
new_tree = new_tree.add_node(node=new_child, parent=new_parent)

old_to_new_parent[current_nest] = ordered_nest[-1]
Expand Down
16 changes: 10 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = { text = "MIT" }
authors = [
{ name = "Andreas Kloeckner", email = "inform@tiker.net" },
]
requires-python = ">=3.8"
requires-python = ">=3.10"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
Expand Down Expand Up @@ -50,14 +50,14 @@ pyopencl = [
"pyopencl>=2022.3",
]
fortran = [
# Note that this is *not* regular 'f2py2e', this is
# the Fortran parser from the (unfinished) third-edition
# f2py, as linked below. This package is not on the package index, AFAIK.
# -AK, 2024-08-02
"f2py @ git+https://github.com/pearu/f2py.git",
"fparser>=0.2.0",
"ply>=3.6",
]

[dependency-groups]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit for dependency-groups? I haven't looked into it much :(

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defined in https://peps.python.org/pep-0735/. The PEP describes the design decisions. It seems that dependency groups are the "hot new" way to do dev dependencies. A markedly useful aspect here is that, unlike the usual "extras", they permit only the dev dependencies to be installed, without fully installing loopy.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they permit only the dev dependencies to be installed

I see why that's quite useful here, thanks :D

dev = [
# https://github.com/astral-sh/ruff/issues/16943
"ruff!=0.11.1,!=0.11.2",
"mypy",
"types-colorama",
"types-Pygments",
Expand Down Expand Up @@ -116,6 +116,10 @@ extend-ignore = [
# FIXME
"UP031", # .format instead of %s
"UP032", # .format instead of %s
"B905", # zip without strict
"UP035", # typing.Tuple
"UP006", # typing.Tuple
"UP007", # Union -> X|Y
]

[tool.ruff.lint.per-file-ignores]
Expand Down
Loading