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
94 changes: 94 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v2.9.1

- uses: astral-sh/setup-uv@v7

- name: Install Python dependencies
run: uv sync --group dev

- name: Check Rust formatting
run: cargo fmt --all --check

- name: Run pre-commit
uses: pre-commit/action@v3.0.1

rust-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2.9.1
with:
save-if: false

- name: Run Rust tests
run: cargo test --workspace

test:
needs: lint
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.12", "3.13"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2.9.1

- uses: astral-sh/setup-uv@v7
with:
cache-dependency-glob: pyproject.toml

- name: Install dependencies
run: uv sync --group dev

- name: Build native extension
uses: PyO3/maturin-action@v1
with:
command: develop
args: --release

- name: Run tests
run: uv run pytest tests/python/ -v --tb=short --junit-xml=results.xml --ignore=tests/python/test_benchmarks.py

- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
with:
name: test-results-${{ matrix.os }}-py${{ matrix.python-version }}
path: results.xml
24 changes: 24 additions & 0 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: PR Cache Cleanup

on:
pull_request:
types: [closed]

permissions:
actions: write

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Delete PR caches
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Cleaning caches for PR #${{ github.event.pull_request.number }}"
gh cache list --ref refs/pull/${{ github.event.pull_request.number }}/merge --json id -q '.[].id' | while read id; do
echo "Deleting cache $id"
gh cache delete "$id" || true
done
53 changes: 53 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Docs

on:
push:
branches: [master]
paths:
- "docs/**"
- ".github/workflows/docs.yml"
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "22"
cache: npm
cache-dependency-path: docs/package-lock.json

- name: Install dependencies
run: cd docs && npm ci

- name: Build Docusaurus
run: cd docs && npm run build

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/build

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
142 changes: 142 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Publish to PyPI

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+*"

permissions:
contents: read

jobs:
build-wheels-linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v6

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --interpreter 3.12 3.13
manylinux: auto

- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-linux-${{ matrix.target }}
path: dist/*.whl

build-wheels-musllinux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v6

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --interpreter 3.12 3.13
manylinux: musllinux_1_2

- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-musllinux-${{ matrix.target }}
path: dist/*.whl

build-wheels-macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: "3.12"

- uses: actions/setup-python@v6
with:
python-version: "3.13"

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --interpreter 3.12 3.13

- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-macos-${{ matrix.target }}
path: dist/*.whl

build-wheels-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: "3.12"

- uses: actions/setup-python@v6
with:
python-version: "3.13"

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: x86_64-pc-windows-msvc
args: --release --out dist --interpreter 3.12 3.13

- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-windows-x86_64
path: dist/*.whl

build-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist

- name: Upload sdist
uses: actions/upload-artifact@v7
with:
name: sdist
path: dist/*.tar.gz

publish:
needs: [build-wheels-linux, build-wheels-musllinux, build-wheels-macos, build-wheels-windows, build-sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
verbose: true
skip-existing: true
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.2
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.0
hooks:
- id: mypy
args: [--ignore-missing-imports]
additional_dependencies: []
pass_filenames: false
entry: mypy py_src/dagron/ tests/

- repo: local
hooks:
- id: cargo-fmt
name: cargo fmt
entry: cargo fmt --all --check
language: system
types: [rust]
pass_filenames: false
- id: clippy
name: clippy
entry: cargo clippy --workspace --all-targets -- -D warnings
language: system
types: [rust]
pass_filenames: false
28 changes: 16 additions & 12 deletions crates/dagron-core/src/algorithms/partition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,18 +256,24 @@ pub fn partition_communication_min<P>(

// Check topological constraint: all predecessors must be in
// earlier-or-same partition, all successors in same-or-later
let can_move = graph.edges_directed(node, petgraph::Direction::Incoming)
let can_move = graph
.edges_directed(node, petgraph::Direction::Incoming)
.all(|e| {
let pred_pid = result.node_to_partition.get(&e.source())
.copied().unwrap_or(0);
let pred_pid = result
.node_to_partition
.get(&e.source())
.copied()
.unwrap_or(0);
pred_pid <= to_pid
})
&& graph.edges(node)
.all(|e| {
let succ_pid = result.node_to_partition.get(&e.target())
.copied().unwrap_or(0);
succ_pid >= to_pid
});
&& graph.edges(node).all(|e| {
let succ_pid = result
.node_to_partition
.get(&e.target())
.copied()
.unwrap_or(0);
succ_pid >= to_pid
});

if !can_move {
continue;
Expand Down Expand Up @@ -390,9 +396,7 @@ fn compute_partition_order(
}

let mut levels = Vec::new();
let mut current: Vec<usize> = (0..num_partitions)
.filter(|&i| in_degree[i] == 0)
.collect();
let mut current: Vec<usize> = (0..num_partitions).filter(|&i| in_degree[i] == 0).collect();
current.sort();

while !current.is_empty() {
Expand Down
Loading
Loading