From 471d3d3b5a090c86267cdc707b814eead957e4aa Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Fri, 15 Aug 2025 22:32:37 +0200 Subject: [PATCH 01/10] chore: add pre-commit hooks --- .buildkite/pipeline.yml | 2 +- .github/workflows/CompatHelper.yml | 2 +- .github/workflows/Documentation.yml | 4 ++-- .github/workflows/Register.yml | 2 +- .github/workflows/TagBot.yml | 2 +- .gitignore | 2 +- .pre-commit-config.yaml | 13 +++++++++++++ DifferentiationInterface/CHANGELOG.md | 2 +- DifferentiationInterface/README.md | 10 +++++----- DifferentiationInterface/docs/src/assets/logo.jl | 2 +- .../docs/src/faq/differentiability.md | 4 ++-- .../ext/DifferentiationInterfaceGTPSAExt/onearg.jl | 10 +++++----- DifferentiationInterface/test/Back/GTPSA/test.jl | 2 +- DifferentiationInterfaceTest/CHANGELOG.md | 2 +- DifferentiationInterfaceTest/Project.toml | 3 --- DifferentiationInterfaceTest/README.md | 2 +- DifferentiationInterfaceTest/test/formalities.jl | 6 ------ 17 files changed, 37 insertions(+), 33 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 2893aedef..ee85be538 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -8,4 +8,4 @@ steps: agents: queue: "juliagpu" cuda: "*" - timeout_in_minutes: 60 \ No newline at end of file + timeout_in_minutes: 60 diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index d6cf9b637..bd9a98157 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -42,4 +42,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} - # COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }} \ No newline at end of file + # COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }} diff --git a/.github/workflows/Documentation.yml b/.github/workflows/Documentation.yml index 3d22d7dca..48f803c46 100644 --- a/.github/workflows/Documentation.yml +++ b/.github/workflows/Documentation.yml @@ -15,7 +15,7 @@ concurrency: cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} jobs: - + docs: name: ${{ matrix.pkg.shortcut }} runs-on: ubuntu-latest @@ -33,7 +33,7 @@ jobs: - name: DifferentiationInterfaceTest shortcut: DIT dir: './DifferentiationInterfaceTest' - + steps: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v2 diff --git a/.github/workflows/Register.yml b/.github/workflows/Register.yml index 1cd7f515b..8993e12a2 100644 --- a/.github/workflows/Register.yml +++ b/.github/workflows/Register.yml @@ -13,4 +13,4 @@ jobs: steps: - uses: julia-actions/RegisterAction@latest with: - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml index 236c5e7cc..4b5204195 100644 --- a/.github/workflows/TagBot.yml +++ b/.github/workflows/TagBot.yml @@ -36,4 +36,4 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} ssh: ${{ secrets.DOCUMENTER_KEY }} - subdir: DifferentiationInterfaceTest \ No newline at end of file + subdir: DifferentiationInterfaceTest diff --git a/.gitignore b/.gitignore index 024591613..3e2063221 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ *.csv playground.jl -.vscode \ No newline at end of file +.vscode diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..ebb58f299 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files +- repo: "https://github.com/domluna/JuliaFormatter.jl" + rev: "v2.1.6" # or whatever the desired release is + hooks: + - id: "julia-formatter" +fail_fast: true diff --git a/DifferentiationInterface/CHANGELOG.md b/DifferentiationInterface/CHANGELOG.md index 07423260d..a40a9a1fa 100644 --- a/DifferentiationInterface/CHANGELOG.md +++ b/DifferentiationInterface/CHANGELOG.md @@ -93,4 +93,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#790]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/790 [#788]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/788 [#782]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/782 -[#768]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/768 \ No newline at end of file +[#768]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/768 diff --git a/DifferentiationInterface/README.md b/DifferentiationInterface/README.md index 81b4919cb..a82202fe5 100644 --- a/DifferentiationInterface/README.md +++ b/DifferentiationInterface/README.md @@ -73,7 +73,7 @@ Pkg.add( ```julia using DifferentiationInterface -import ForwardDiff, Enzyme, Zygote # AD backends you want to use +import ForwardDiff, Enzyme, Zygote # AD backends you want to use f(x) = sum(abs2, x) @@ -97,23 +97,23 @@ You can use the provided [`CITATION.cff`](https://github.com/JuliaDiff/Different ```bibtex @misc{dalle2025commoninterfaceautomaticdifferentiation, - title={A Common Interface for Automatic Differentiation}, + title={A Common Interface for Automatic Differentiation}, author={Guillaume Dalle and Adrian Hill}, year={2025}, eprint={2505.05542}, archivePrefix={arXiv}, primaryClass={cs.MS}, - url={https://arxiv.org/abs/2505.05542}, + url={https://arxiv.org/abs/2505.05542}, } @misc{schäfer2022abstractdifferentiationjlbackendagnosticdifferentiableprogramming, - title={AbstractDifferentiation.jl: Backend-Agnostic Differentiable Programming in Julia}, + title={AbstractDifferentiation.jl: Backend-Agnostic Differentiable Programming in Julia}, author={Frank Schäfer and Mohamed Tarek and Lyndon White and Chris Rackauckas}, year={2022}, eprint={2109.12449}, archivePrefix={arXiv}, primaryClass={cs.MS}, - url={https://arxiv.org/abs/2109.12449}, + url={https://arxiv.org/abs/2109.12449}, } ``` diff --git a/DifferentiationInterface/docs/src/assets/logo.jl b/DifferentiationInterface/docs/src/assets/logo.jl index 610627c14..ef4609669 100644 --- a/DifferentiationInterface/docs/src/assets/logo.jl +++ b/DifferentiationInterface/docs/src/assets/logo.jl @@ -47,7 +47,7 @@ end # ╔═╡ 69d0fa4d-2585-42a0-981f-99d43f7e2c1f md"## Creating Favicons -Using Imagemagick, run +Using Imagemagick, run ```bash convert -background transparent logo.svg -define icon:auto-resize=256,128,48,32,16 favicon.ico ``` diff --git a/DifferentiationInterface/docs/src/faq/differentiability.md b/DifferentiationInterface/docs/src/faq/differentiability.md index 5845e80f5..1fd3be287 100644 --- a/DifferentiationInterface/docs/src/faq/differentiability.md +++ b/DifferentiationInterface/docs/src/faq/differentiability.md @@ -51,7 +51,7 @@ In some situations, manually writing overloads for `x::Dual` or `x::AbstractArra ### ReverseDiff [ReverseDiff.jl](https://github.com/JuliaDiff/ReverseDiff.jl) relies on operator overloading for scalars, but also for arrays. -The relevant types are called `TrackedReal` and `TrackedArray`, they have a set of [limitations](https://juliadiff.org/ReverseDiff.jl/stable/limits/) very similar to that of ForwardDiff.jl's `Dual` and will cause similar errors. +The relevant types are called `TrackedReal` and `TrackedArray`, they have a set of [limitations](https://juliadiff.org/ReverseDiff.jl/stable/limits/) very similar to that of ForwardDiff.jl's `Dual` and will cause similar errors. ### Symbolic backends @@ -112,4 +112,4 @@ There are, however, translation utilities: Also note the existence of [`DifferentiationInterface.DifferentiateWith`](@ref), which allows the user to wrap a function that should be differentiated with a specific backend. -Right now, it only targets [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl), [Mooncake.jl](), [ChainRules.jl](https://juliadiff.org/ChainRulesCore.jl/stable/)-compatible backends (e.g., [Zygote.jl](https://github.com/FluxML/Zygote.jl)), but PRs are welcome to define Enzyme.jl rules for this object. \ No newline at end of file +Right now, it only targets [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl), [Mooncake.jl](), [ChainRules.jl](https://juliadiff.org/ChainRulesCore.jl/stable/)-compatible backends (e.g., [Zygote.jl](https://github.com/FluxML/Zygote.jl)), but PRs are welcome to define Enzyme.jl rules for this object. diff --git a/DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/onearg.jl b/DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/onearg.jl index 58baad569..45257d21c 100644 --- a/DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/onearg.jl +++ b/DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/onearg.jl @@ -114,7 +114,7 @@ struct GTPSAOneArgGradientPrep{SIG,X} <: DI.GradientPrep{SIG} xt::X end -# Unlike JVP, this requires us to use all variables +# Unlike JVP, this requires us to use all variables function DI.prepare_gradient_nokwarg( strict::Val, f, backend::AutoGTPSA{D}, x, contexts::Vararg{DI.Constant,C} ) where {D,C} @@ -197,7 +197,7 @@ struct GTPSAOneArgJacobianPrep{SIG,X} <: DI.JacobianPrep{SIG} xt::X end -# To materialize the entire Jacobian we use all variables +# To materialize the entire Jacobian we use all variables function DI.prepare_jacobian_nokwarg( strict::Val, f, backend::AutoGTPSA{D}, x, contexts::Vararg{DI.Constant,C} ) where {D,C} @@ -406,7 +406,7 @@ function DI.value_derivative_and_second_derivative!( end ## Hessian -# Stores allocated array of TPS and an array for the monomial coefficient +# Stores allocated array of TPS and an array for the monomial coefficient # indexing in GTPSA.cycle! (which is used if a Descriptor is specified) struct GTPSAOneArgHessianPrep{SIG,X,M} <: DI.HessianPrep{SIG} _sig::Val{SIG} @@ -424,14 +424,14 @@ function DI.prepare_hessian_nokwarg( else nn = length(x) d = Descriptor(nn, 2) - # If all variables/variable+parameters have truncation order > 2, then + # If all variables/variable+parameters have truncation order > 2, then # the indexing is known beforehand and we can do it (very slightly) faster m = nothing end xt = similar(x, TPS{promote_type(eltype(x), Float64)}) # xt and x have same indexing because of similar - # Setting the first derivatives must be 1-based + # Setting the first derivatives must be 1-based # linear with the variables. j = 1 for i in eachindex(xt) diff --git a/DifferentiationInterface/test/Back/GTPSA/test.jl b/DifferentiationInterface/test/Back/GTPSA/test.jl index 68b66918e..c0541406f 100644 --- a/DifferentiationInterface/test/Back/GTPSA/test.jl +++ b/DifferentiationInterface/test/Back/GTPSA/test.jl @@ -27,7 +27,7 @@ test_differentiation( d1 = GTPSA.Descriptor(20, 2) # 20 variables to 2nd order test_differentiation(AutoGTPSA(d1); type_stability=:full, logging=LOGGING); -# Test with Descriptor using varying orders +# Test with Descriptor using varying orders vos = 2 * ones(Int, 20) vos[1] = 3 d2 = GTPSA.Descriptor(vos, 3) diff --git a/DifferentiationInterfaceTest/CHANGELOG.md b/DifferentiationInterfaceTest/CHANGELOG.md index c0eca7a37..569fbe0ab 100644 --- a/DifferentiationInterfaceTest/CHANGELOG.md +++ b/DifferentiationInterfaceTest/CHANGELOG.md @@ -38,4 +38,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#786]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/786 [#749]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/749 [#748]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/748 -[#745]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/745 \ No newline at end of file +[#745]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/745 diff --git a/DifferentiationInterfaceTest/Project.toml b/DifferentiationInterfaceTest/Project.toml index 5b98aed4c..e0fb1e147 100644 --- a/DifferentiationInterfaceTest/Project.toml +++ b/DifferentiationInterfaceTest/Project.toml @@ -59,7 +59,6 @@ ForwardDiff = "0.10.36,1" Functors = "0.4, 0.5" JET = "0.4 - 0.8, 0.9" JLArrays = "0.1, 0.2" -JuliaFormatter = "1,2" LinearAlgebra = "1" Lux = "1.1.0" LuxTestUtils = "1.3.1" @@ -88,7 +87,6 @@ Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb" -JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" Lux = "b2108857-7c20-44ae-9111-449ecde12c47" LuxTestUtils = "ac9de150-d08f-4546-94fb-7472b5760531" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" @@ -114,7 +112,6 @@ test = [ "ForwardDiff", "JET", "JLArrays", - "JuliaFormatter", "Pkg", "Random", "SparseArrays", diff --git a/DifferentiationInterfaceTest/README.md b/DifferentiationInterfaceTest/README.md index 54090ed5d..f3036cf32 100644 --- a/DifferentiationInterfaceTest/README.md +++ b/DifferentiationInterfaceTest/README.md @@ -47,7 +47,7 @@ Pkg.add( url="https://github.com/JuliaDiff/DifferentiationInterface.jl", subdir="DifferentiationInterface" ) - + Pkg.add( url="https://github.com/JuliaDiff/DifferentiationInterface.jl", subdir="DifferentiationInterfaceTest" diff --git a/DifferentiationInterfaceTest/test/formalities.jl b/DifferentiationInterfaceTest/test/formalities.jl index 37a8e39d6..5f827e8f4 100644 --- a/DifferentiationInterfaceTest/test/formalities.jl +++ b/DifferentiationInterfaceTest/test/formalities.jl @@ -3,18 +3,12 @@ using DifferentiationInterfaceTest using Aqua: Aqua using ExplicitImports using JET: JET -using JuliaFormatter: JuliaFormatter using SparseMatrixColorings: SparseMatrixColorings using Test @testset "Aqua" begin Aqua.test_all(DifferentiationInterfaceTest; ambiguities=false, undocumented_names=true) end -@testset "JuliaFormatter" begin - @test JuliaFormatter.format( - DifferentiationInterfaceTest; verbose=false, overwrite=false - ) -end @testset verbose = true "JET" begin JET.test_package(DifferentiationInterfaceTest; target_defined_modules=true) end From 61992c75e7957ab2f6be32b7b898ca94518c7a3a Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Fri, 15 Aug 2025 22:51:48 +0200 Subject: [PATCH 02/10] Add CI job --- .github/workflows/PreCommit.yml | 17 +++++++++++++++++ .pre-commit-config.yaml | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 .github/workflows/PreCommit.yml diff --git a/.github/workflows/PreCommit.yml b/.github/workflows/PreCommit.yml new file mode 100644 index 000000000..aa1df35af --- /dev/null +++ b/.github/workflows/PreCommit.yml @@ -0,0 +1,17 @@ +name: Pre-Commit + +on: + push: + branches: + - main + tags: ["*"] + pull_request: + types: [opened, reopened, synchronize, ready_for_review] + workflow_dispatch: + +jobs: + pre-commit-ci-lite: + runs-on: ubuntu-latest + steps: + - uses: pre-commit-ci/lite-action@v1.1.0 + if: always() diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ebb58f299..bfa4f3a3e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,8 @@ repos: - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files + - id: check-merge-conflict + - id: no-commit-to-branch - repo: "https://github.com/domluna/JuliaFormatter.jl" rev: "v2.1.6" # or whatever the desired release is hooks: From fdc152b66af37929561a8089327ec9a4261abcf5 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Fri, 15 Aug 2025 22:54:33 +0200 Subject: [PATCH 03/10] Manually install pre-commit --- .github/workflows/PreCommit.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/PreCommit.yml b/.github/workflows/PreCommit.yml index aa1df35af..7ac76c7e4 100644 --- a/.github/workflows/PreCommit.yml +++ b/.github/workflows/PreCommit.yml @@ -10,8 +10,13 @@ on: workflow_dispatch: jobs: - pre-commit-ci-lite: + pre-commit: runs-on: ubuntu-latest steps: - - uses: pre-commit-ci/lite-action@v1.1.0 - if: always() + - uses: actions/checkout@v4 + - name: Install uv + uses: astral-sh/setup-uv@v6 + - name: Install pre-commit + run: uv tool install pre-commit + - name: Run pre-commit + run: pre-commit run --all-files From 3fcccb4bc3c6c747e18f04e2c3cbeba57561059b Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Fri, 15 Aug 2025 23:02:50 +0200 Subject: [PATCH 04/10] Install JuliaFormatter --- .github/workflows/PreCommit.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/PreCommit.yml b/.github/workflows/PreCommit.yml index 7ac76c7e4..06b1f1fbe 100644 --- a/.github/workflows/PreCommit.yml +++ b/.github/workflows/PreCommit.yml @@ -14,6 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Install Julia + uses: julia-actions/setup-julia@v2 + - name: Install JuliaFormatter + run: julia 'using Pkg; Pkg.add("JuliaFormatter")' - name: Install uv uses: astral-sh/setup-uv@v6 - name: Install pre-commit From 3cf51ce8e24f176e9a8a838ff6eeeaeb0f418bd0 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Fri, 15 Aug 2025 23:03:53 +0200 Subject: [PATCH 05/10] Execute --- .github/workflows/PreCommit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/PreCommit.yml b/.github/workflows/PreCommit.yml index 06b1f1fbe..ae0e5ae01 100644 --- a/.github/workflows/PreCommit.yml +++ b/.github/workflows/PreCommit.yml @@ -17,7 +17,7 @@ jobs: - name: Install Julia uses: julia-actions/setup-julia@v2 - name: Install JuliaFormatter - run: julia 'using Pkg; Pkg.add("JuliaFormatter")' + run: julia -e 'using Pkg; Pkg.add("JuliaFormatter")' - name: Install uv uses: astral-sh/setup-uv@v6 - name: Install pre-commit From 069cfde9d38f03221690284358e1a796ba787eed Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Fri, 15 Aug 2025 23:07:12 +0200 Subject: [PATCH 06/10] Try bad formatting --- .github/workflows/PreCommit.yml | 1 + DifferentiationInterface/src/DifferentiationInterface.jl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/PreCommit.yml b/.github/workflows/PreCommit.yml index ae0e5ae01..2b9aaf5ac 100644 --- a/.github/workflows/PreCommit.yml +++ b/.github/workflows/PreCommit.yml @@ -16,6 +16,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Julia uses: julia-actions/setup-julia@v2 + - uses: julia-actions/cache@v2 - name: Install JuliaFormatter run: julia -e 'using Pkg; Pkg.add("JuliaFormatter")' - name: Install uv diff --git a/DifferentiationInterface/src/DifferentiationInterface.jl b/DifferentiationInterface/src/DifferentiationInterface.jl index 32bfc4703..5ec8252ba 100644 --- a/DifferentiationInterface/src/DifferentiationInterface.jl +++ b/DifferentiationInterface/src/DifferentiationInterface.jl @@ -58,7 +58,7 @@ include("first_order/derivative.jl") include("first_order/gradient.jl") include("first_order/jacobian.jl") -include("second_order/second_derivative.jl") +include( "second_order/second_derivative.jl") include("second_order/hvp.jl") include("second_order/hessian.jl") From 4e56b8a79c354b5e18739b9ad61a1f4874d46e62 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Fri, 15 Aug 2025 23:10:23 +0200 Subject: [PATCH 07/10] Add show diff --- .github/workflows/PreCommit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/PreCommit.yml b/.github/workflows/PreCommit.yml index 2b9aaf5ac..a06d6da09 100644 --- a/.github/workflows/PreCommit.yml +++ b/.github/workflows/PreCommit.yml @@ -24,4 +24,4 @@ jobs: - name: Install pre-commit run: uv tool install pre-commit - name: Run pre-commit - run: pre-commit run --all-files + run: pre-commit run --all-files --show-diff-on-failure --color always From ccbf8b7842ff6a13c61a4e797a45a1d2f5199a3a Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Fri, 15 Aug 2025 23:13:22 +0200 Subject: [PATCH 08/10] Add mention of pre-commit to CONTRIBUTING --- CONTRIBUTING.md | 4 +++- DifferentiationInterface/src/DifferentiationInterface.jl | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a7bef8a60..d3aad94fa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,5 +9,7 @@ _Only the two maintainers are allowed to approve and merge pull requests._ Feel free to ping them if they do not answer within a week or so. Apart from the conditions above, this repository follows the [ColPrac](https://github.com/SciML/ColPrac) best practices and [Conventional Commits](https://www.conventionalcommits.org/en/). -Its code is formatted using [JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl) with [BlueStyle](https://github.com/JuliaDiff/BlueStyle) -- please format any modified code before opening a pull request, otherwise CI will fail. +Its code is formatted using [JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl) with [BlueStyle](https://github.com/JuliaDiff/BlueStyle). +As part of continuous integration, a set of formal tests is run using [pre-commit](https://pre-commit.com/). +We invite you to install pre-commit so that these checks are performed locally before you open or update a pull request. You can refer to the [dev guide](https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/dev/dev_guide/) for details on the package structure and the testing pipeline. diff --git a/DifferentiationInterface/src/DifferentiationInterface.jl b/DifferentiationInterface/src/DifferentiationInterface.jl index 5ec8252ba..32bfc4703 100644 --- a/DifferentiationInterface/src/DifferentiationInterface.jl +++ b/DifferentiationInterface/src/DifferentiationInterface.jl @@ -58,7 +58,7 @@ include("first_order/derivative.jl") include("first_order/gradient.jl") include("first_order/jacobian.jl") -include( "second_order/second_derivative.jl") +include("second_order/second_derivative.jl") include("second_order/hvp.jl") include("second_order/hessian.jl") From e86eb4132da78b4cd9af6c9b9164303bbdee1686 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Fri, 15 Aug 2025 23:16:51 +0200 Subject: [PATCH 09/10] Enable cache --- .github/workflows/PreCommit.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/PreCommit.yml b/.github/workflows/PreCommit.yml index a06d6da09..973b79567 100644 --- a/.github/workflows/PreCommit.yml +++ b/.github/workflows/PreCommit.yml @@ -1,5 +1,10 @@ name: Pre-Commit +# needed to allow julia-actions/cache to delete old caches that it has created +permissions: + actions: write + contents: read + on: push: branches: @@ -14,14 +19,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Julia - uses: julia-actions/setup-julia@v2 + - uses: julia-actions/setup-julia@v2 - uses: julia-actions/cache@v2 - - name: Install JuliaFormatter - run: julia -e 'using Pkg; Pkg.add("JuliaFormatter")' - - name: Install uv - uses: astral-sh/setup-uv@v6 - - name: Install pre-commit - run: uv tool install pre-commit - - name: Run pre-commit - run: pre-commit run --all-files --show-diff-on-failure --color always + - run: julia -e 'using Pkg; Pkg.add("JuliaFormatter")' + - uses: astral-sh/setup-uv@v6 + - run: uv tool install pre-commit + - run: pre-commit run --all-files --show-diff-on-failure --color always From b6eb987f95d988668142f53442ef990460365884 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Fri, 15 Aug 2025 23:18:21 +0200 Subject: [PATCH 10/10] Remove JuliaFormatter from tests --- DifferentiationInterface/Project.toml | 3 --- DifferentiationInterface/test/Core/Internals/_formalities.jl | 5 ----- 2 files changed, 8 deletions(-) diff --git a/DifferentiationInterface/Project.toml b/DifferentiationInterface/Project.toml index cef7316e7..aae70a9d6 100644 --- a/DifferentiationInterface/Project.toml +++ b/DifferentiationInterface/Project.toml @@ -75,7 +75,6 @@ GPUArraysCore = "0.2" GTPSA = "1.4.0" JET = "0.9" JLArrays = "0.2.0" -JuliaFormatter = "1,2" LinearAlgebra = "1" Mooncake = "0.4.147" Pkg = "1" @@ -110,7 +109,6 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" GTPSA = "b27dd330-f138-47c5-815b-40db9dd9b6e8" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb" -JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" PolyesterForwardDiff = "98d1487c-24ca-40b6-b7ab-df2af84e126b" @@ -136,7 +134,6 @@ test = [ "ExplicitImports", "JET", "JLArrays", - "JuliaFormatter", "Pkg", "Random", "SparseArrays", diff --git a/DifferentiationInterface/test/Core/Internals/_formalities.jl b/DifferentiationInterface/test/Core/Internals/_formalities.jl index aa1050c9d..475676702 100644 --- a/DifferentiationInterface/test/Core/Internals/_formalities.jl +++ b/DifferentiationInterface/test/Core/Internals/_formalities.jl @@ -4,7 +4,6 @@ using Aqua: Aqua using DifferentiationInterface using ExplicitImports using JET: JET -using JuliaFormatter: JuliaFormatter using Test using SparseMatrixColorings using SparseArrays @@ -17,10 +16,6 @@ end JET.test_package(DifferentiationInterface; target_defined_modules=true) end -@testset "JuliaFormatter" begin - @test JuliaFormatter.format(DifferentiationInterface; verbose=false, overwrite=false) -end - @testset "Documentation" begin if VERSION >= v"1.11" @test isempty(Docs.undocumented_names(DifferentiationInterface))