Skip to content

Commit

Permalink
feat(lib): add compute_paths method for image method and "coherence…
Browse files Browse the repository at this point in the history
…" of paths example (#117)

* chore(lib): warn about overflow and add Rust coverage

* fix(ci): setup Python inside container

* chore(ci): does it work?

* chore(ci): setup-python reads `.python-version`

* fix(ci): `.python-version`

* fix(ci): install cargo-tarpaulin manually

* WIP on coherence

* chore(lib): add masked vertices

* chore(deps): bump JAX and Python>=3.10

* chore(lib): upgrade Python 3.10 and add fibonacci lattice

* chore(lint): some fixes

* fix(docs): typos

* chore(docs): improve

* fix(docs): typo

* chore(tests): improved coverage

* fix(docs): explicit variable name

* chore(fmt): run ruff

* try(docs): comment code

* chore(docs): add reference to paper

* wip(lib): ray casting for visibility check

* chore(lib): avoid unnecessary broadcasting

* chore(docs): cleanup

* chore(lib): avoid unnecessary broadcasting

* wip: addressing last issues

* chore(lib): are we done with broadcasting?

* chore(tests): improve PLY parsing and test logging

* feat(lib): support reading materials from OBJ files

* chore(lint): happy linting

* chore(ci): codedoc ignore pyo3 modules

* chore(docs): clear nb

* fix(ci): justfile

* fix(tests): remove materials

* fix(lib): use re-entrant lock and add more tests

* fix(ci): tests and justfile

* chore(ci): disable xdist in CI

* try(ci): or this?

* chore(tests): one more test

* feat(lib): use IndexMap to have reproducible results

* fix(tests): lots of fixes and better naming

* fix(ci): remove post-install

* chore(lib): better defaults for hit tolerance and epsilon value

* feat(lib): allow to iterate over chunks

* chore(ci): remove fail on warning

* chore(tests): add new benchmarks

* fix(ci): fixes

* chore(ci): codspeed

* fix(ci): oops

* fix(ci): use uv?

* fix(tests): import

* try(ci): fix?

* try(ci): use real pip?

* fix(ci): don't use uv

* try(ci): :-(

* fix(ci): oops

* fix(deps): pin `numpy<2`

See PyO3/rust-numpy#409

* chore(deps): update lock file

* chore(tests): cleanup

* chore(ci): disable xdist when benchmarking

* chore(ci): force set `-n0`

* chore(ci): remove Rust bench from comments

* chore(ci): update

* try(ci): add stupid benchmark

* try...

* fix(ci): install from local packages, not remote

* fix(ci): missing interpolation

* fix(ci): pip install actually

* fix(ci): actually it was installing from remote :o

* wip

* fix(ci): finally

* fix(ci): apt_packages are no longer installed

* can we sudo?

* :-(

* fix(ci): rtd build

* fix(ci): point to venv

* chore(ci): use asdf install instead

* fix(ci): must also install self
  • Loading branch information
jeertmans authored Sep 27, 2024
1 parent c8f2798 commit 06cade7
Show file tree
Hide file tree
Showing 83 changed files with 27,409 additions and 26,049 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
run: uv run pre-commit run --all-files

- name: Apply fixes when present
uses: pre-commit-ci/lite-action@v1.0.2
uses: pre-commit-ci/lite-action@v1.0.3
if: always()
with:
msg: 'chore(fmt): auto fixes from pre-commit hooks'
159 changes: 34 additions & 125 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
uses: dtolnay/rust-toolchain@stable

- name: Install dependencies
run: uv sync --no-dev --extra tests
run: uv sync --locked --no-dev --extra tests

- name: Run tests
run: uv run pytest
Expand All @@ -63,7 +63,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
pyversion: ['3.9', '3.10', '3.11', '3.12']
pyversion: ['3.10', '3.11', '3.12']
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
Expand Down Expand Up @@ -120,28 +120,30 @@ jobs:
uses: actions/checkout@v4

- uses: actions/setup-python@v5
id: setup-python
with:
cache: pip
cache-dependency-path: uv.lock

- name: Setup uv
uses: astral-sh/setup-uv@v2

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools

- name: Install dependencies
run: pip install ".[tests]"
- name: Cache Rust
uses: Swatinem/rust-cache@v2

- name: Run Benchmarks on changes
run: pytest --benchmark-only --benchmark-save=changes differt-core/tests/benchmarks
- name: Install dependencies
run: uv pip install -r pyproject.toml --extra tests --python '${{ steps.setup-python.outputs.python-path }}'

- name: Build wheel with profiling profile
uses: PyO3/maturin-action@v1
with:
args: >
--release
--out pgo-wheel
working-directory: differt-core
- name: Build differt-core for profiling
run: |
rm -f python/differt_core/*.so
pip install -e . --config-settings=build-args='--profile profiling'
working-directory: differt-core
env:
RUSTFLAGS: -Cprofile-generate=${{ github.workspace }}/profdata

Expand All @@ -150,79 +152,23 @@ jobs:
shell: bash

- name: Generate profile data
run: |
python -m ensurepip
python -m pip install differt-core --no-index --no-deps --find-links differt-core/pgo-wheel --force-reinstall
pytest --benchmark-only differt-core/tests/benchmarks
rustup run stable bash -c 'echo LLVM_PROFDATA=$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/${{ env.RUST_HOST }}/bin/llvm-profdata >> "$GITHUB_ENV"'
run: pytest --dist=no -n0 --benchmark-enable differt/tests/benchmarks

- name: Merge GO data
run: ${{ env.LLVM_PROFDATA }} merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata
- name: Merge PGO data
run: rustup run stable bash -c '$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/${{ env.RUST_HOST }}/bin/llvm-profdata merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata'

- name: Build PGO-optimized wheel
uses: PyO3/maturin-action@v1
with:
args: >
--release
--out opt-wheel
working-directory: differt-core
- name: Build differt-core for benchmarking
run: |
rm -f python/differt_core/*.so
pip install -e . --config-settings=build-args='--profile profiling'
working-directory: differt-core
env:
RUSTFLAGS: -Cprofile-use=${{ github.workspace }}/merged.profdata

- name: Run Benchmarks on changes with PGO-optimized wheel
run: |
python -m pip install differt-core --no-index --no-deps --find-links differt-core/opt-wheel --force-reinstall
pytest --benchmark-only --benchmark-save=pgo differt-core/tests/benchmarks
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
clean: false

- name: Install dependencies (before changes)
run: pip install ".[tests]"

- name: Build wheel before changes
uses: PyO3/maturin-action@v1
- name: Run CodSpeed benchmarks
uses: CodSpeedHQ/action@v3
with:
args: >
--release
--out dist
working-directory: differt-core

- name: Run Benchmarks before changes
run: |
python -m pip install differt-core --no-index --no-deps --find-links differt-core/dist --force-reinstall
pytest --benchmark-only --benchmark-save=before differt-core/tests/benchmarks
- name: Compare benchmarks
run: |
echo 'results<<EOF' >> $GITHUB_OUTPUT
pytest-benchmark compare --group-by=name --columns="mean,stddev,ops" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
id: compare

- name: Comment PR with benchmarks
uses: thollander/actions-comment-pull-request@v2
continue-on-error: true
with:
message: |
Python benchmark results:
```
${{ steps.compare.outputs.results }}
```
comment_tag: python-benchmarks

id: comment

- name: If PR comment failed, write to PR summary
if: steps.comment.outcome != 'success'
run: |
echo '### Python benchmark results' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '${{ steps.compare.outputs.results }}' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
run: pytest differt/tests/benchmarks --codspeed

rust-benchmark:
runs-on: ubuntu-latest
Expand All @@ -232,57 +178,20 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions/setup-python@v5
- name: Setup Python
uses: actions/setup-python@v5

- name: Install NumPy
run: pip install numpy
run: pip install "numpy<2"

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

- uses: taiki-e/install-action@v2
with:
tool: critcmp@0.1.8

- name: Run Benchmarks on changes
run: cargo bench --bench bench_main -- --save-baseline changes

- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
clean: false

- name: Run Benchmarks before changes
run: cargo bench --bench bench_main -- --save-baseline before
- name: Cache Rust
uses: Swatinem/rust-cache@v2

- name: Compare benchmarks
run: |
echo 'results<<EOF' >> $GITHUB_OUTPUT
critcmp before changes >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
id: compare

- name: Comment PR with benchmarks
uses: thollander/actions-comment-pull-request@v2
continue-on-error: true
with:
message: |
Rust benchmark results:
```
${{ steps.compare.outputs.results }}
```
comment_tag: rust-benchmarks

id: comment

- name: If PR comment failed, write to PR summary
if: steps.comment.outcome != 'success'
run: |
echo '### Rust benchmark results' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '${{ steps.compare.outputs.results }}' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Run Benchmarks
run: cargo bench

linkcheck-docs:
runs-on: ubuntu-latest
Expand All @@ -296,7 +205,7 @@ jobs:
enable-cache: true

- name: Install dependencies
run: uv sync --no-dev --extra docs
run: uv sync --locked --no-dev --extra docs

- name: Install Just
uses: taiki-e/install-action@just
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ differt/src/differt/scene/scenes/

# Tools

.coverage
.benchmarks/
.coverage*
coverage.xml
13 changes: 6 additions & 7 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ build:
jobs:
post_system_dependencies:
- nohup Xvfb $DISPLAY -screen 0 1400x900x24 -dpi 96 +extension RANDR +render &
post_create_environment:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv pip install . -r pyproject.toml --extra docs --no-cache --python $READTHEDOCS_VIRTUALENV_PATH
sphinx:
builder: html
configuration: docs/source/conf.py
fail_on_warning: true
python:
install:
- method: pip
path: .
extra_requirements:
- docs
fail_on_warning: false # TODO: enable me
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ imports_granularity = "Crate"
match_block_trailing_comma = true
normalize_doc_attributes = true
reorder_modules = true
style_edition = "2024"
unstable_features = true
version = "Two"
wrap_comments = true
25 changes: 25 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
debug = true
strip = false

[profile.profiling]
debug = true
inherits = "release"
strip = false

[profile.release]
codegen-units = 1
lto = "fat"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ but performant program. It also heavily uses the capabilities brought by

To run build this package locally, you need:

- [Python 3.9](https://www.python.org/) or above;
- [Python 3.10](https://www.python.org/) or above;
- [Rust](https://www.rust-lang.org/) stable toolchain;
- any modern C compiler;
- [just](https://github.com/casey/just) to easily run commands listed in `justfile`s;
Expand Down Expand Up @@ -120,7 +120,7 @@ pytest
or benchmark it:

```bash
pytest --benchmark-only
pytest --benchmark-enable differt/tests/benchmarks
```

[pypi-version-badge]: https://img.shields.io/pypi/v/DiffeRT?label=DiffeRT&color=blueviolet
Expand Down
1 change: 1 addition & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ If you feel something is missing, please create
## GitHub

- Add CITATION.cff file
- Build PGO wheels for release too
6 changes: 5 additions & 1 deletion differt-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ harness = false
name = "bench_main"

[dependencies]
indexmap = {version = "2.5.0", features = ["serde"]}
log = "0.4.21"
nalgebra = "0.32.3"
ndarray = {version = "0.15", features = ["rayon"]}
numpy = "0.21"
obj-rs = "0.7.1"
ply-rs = "0.1.3"
pyo3 = "0.21"
pyo3 = {version = "0.21", features = ["indexmap"]}
pyo3-log = "0.10"
quick-xml = {version = "0.31.0", features = ["serialize"]}
serde = {version = "1.0.197", features = ["derive"]}
Expand All @@ -28,6 +29,9 @@ crate-type = ["cdylib", "rlib"]
doctest = false
name = "differt_core"

[lints.rust]
unexpected_cfgs = {level = "warn", check-cfg = ['cfg(tarpaulin_include)']}

[package]
edition = "2021"
name = "differt-core"
Expand Down
2 changes: 1 addition & 1 deletion differt-core/benches/benchmarks/graph_iterators.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use criterion::{black_box, criterion_group, Criterion, Throughput};
use criterion::{Criterion, Throughput, black_box, criterion_group};
use differt_core::rt::graph::{complete::CompleteGraph, directed::DiGraph};

const NUM_NODES: usize = 1000;
Expand Down
Loading

0 comments on commit 06cade7

Please sign in to comment.