Skip to content

Commit

Permalink
Run doctests in the test CI
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Jun 16, 2024
1 parent 500ce6e commit 4061b2a
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ concurrency:

jobs:
ci:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }}
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.test_group }}
if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }}
runs-on: ${{ matrix.os }}
strategy:
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:

downgrade:
if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }} && github.base_ref == github.event.repository.default_branch
name: Downgrade Julia ${{ matrix.version }} - ${{ github.event_name }}
name: Downgrade Julia ${{ matrix.version }} - ${{ matrix.test_group }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: CompatHelper

on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
CompatHelper:
runs-on: ubuntu-latest
Expand All @@ -31,7 +34,7 @@ jobs:
- name: "Run CompatHelper"
run: |
import CompatHelper
subdirs = [""]
subdirs = ["", "docs"]
append!(subdirs, joinpath.(("examples",), filter(p -> isdir(joinpath("examples", p)), readdir("examples"))))
CompatHelper.main(; subdirs)
shell: julia --color=yes {0}
Expand Down
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ ChainRulesCore = "1.23"
ComponentArrays = "0.15.11"
ConcreteStructs = "0.2.3"
ConstructionBase = "1.5"
Documenter = "1.4"
DynamicExpressions = "0.16, 0.17"
Enzyme = "0.12.12"
ExplicitImports = "1.1.1"
Expand All @@ -95,6 +96,7 @@ MLUtils = "0.4.3"
MPI = "0.20.19"
MacroTools = "0.5.13"
Markdown = "1.10"
Metalhead = "0.9.3"
NCCL = "0.1.1"
OhMyThreads = "0.5.1"
Optimisers = "0.3"
Expand All @@ -119,6 +121,7 @@ julia = "1.10"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DynamicExpressions = "a40a106e-89c9-4ca8-8020-a735e8728b6b"
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
Expand All @@ -131,6 +134,7 @@ LuxCUDA = "d0bbae9a-e099-4d5b-a835-1c6931763bda"
LuxTestUtils = "ac9de150-d08f-4546-94fb-7472b5760531"
MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
Metalhead = "dbeba491-748d-5e0e-a39e-b530a07fa0cc"
NCCL = "3fe64909-d7a1-4096-9b7d-7a0f12cf0f6b"
Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand All @@ -144,4 +148,4 @@ Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["Aqua", "ComponentArrays", "DynamicExpressions", "Enzyme", "ExplicitImports", "FiniteDifferences", "Flux", "ForwardDiff", "Logging", "LuxAMDGPU", "LuxCUDA", "LuxTestUtils", "MLUtils", "MPI", "NCCL", "Optimisers", "Pkg", "ReTestItems", "ReverseDiff", "SimpleChains", "StableRNGs", "Statistics", "Test", "Tracker", "Zygote"]
test = ["Aqua", "ComponentArrays", "Documenter", "DynamicExpressions", "Enzyme", "ExplicitImports", "FiniteDifferences", "Flux", "ForwardDiff", "Logging", "LuxAMDGPU", "LuxCUDA", "LuxTestUtils", "MLUtils", "MPI", "Metalhead", "NCCL", "Optimisers", "Pkg", "ReTestItems", "ReverseDiff", "SimpleChains", "StableRNGs", "Statistics", "Test", "Tracker", "Zygote"]
30 changes: 24 additions & 6 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365"
DynamicExpressions = "a40a106e-89c9-4ca8-8020-a735e8728b6b"
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
Expand All @@ -19,16 +17,36 @@ LuxCore = "bb33d45b-7691-41d6-9220-0943567d0623"
LuxDeviceUtils = "34f89e08-e1d5-43b4-8944-0b49ac560553"
LuxLib = "82251201-b29d-42c6-8e01-566dec8acb11"
LuxTestUtils = "ac9de150-d08f-4546-94fb-7472b5760531"
Metalhead = "dbeba491-748d-5e0e-a39e-b530a07fa0cc"
Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
SimpleChains = "de6bee2f-e2f4-4ec7-b6ed-219cc6f6e9e5"
WeightInitializers = "d49dbf32-c5c2-4618-8acc-27bb2598ef2d"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[compat]
Boltz = "0.3.7"
ADTypes = "1.3"
Adapt = "4"
Boltz = "0.3.8"
ChainRulesCore = "1.24"
ComponentArrays = "0.15"
Documenter = "1.4"
DocumenterVitepress = "0.1.1"
FiniteDiff = "2.23.1"
ForwardDiff = "0.10.36"
LinearAlgebra = "1.10"
Literate = "2.18.0"
Lux = "0.5.53"
LuxAMDGPU = "0.2.3"
LuxCUDA = "0.3.2"
LuxCore = "0.1.15"
LuxDeviceUtils = "0.1.21"
LuxLib = "0.3.26"
LuxTestUtils = "0.1.15"
Optimisers = "0.3.3"
Pkg = "1.10"
Printf = "1.10"
Random = "1.10"
WeightInitializers = "0.1.7"
Zygote = "0.6.70"
julia = "1.10"
13 changes: 1 addition & 12 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@ using Lux, LuxCore, LuxLib, WeightInitializers, Boltz
using LuxTestUtils, LuxDeviceUtils
using LuxAMDGPU, LuxCUDA

# Doctest Imports
doctestexpr = quote
using SimpleChains: static
using Flux: Flux
using Metalhead: Metalhead
using DynamicExpressions
using Adapt, Lux, Random, Optimisers, Zygote
end

DocMeta.setdocmeta!(Lux, :DocTestSetup, doctestexpr; recursive=true)

#! format: off

pages = [
Expand Down Expand Up @@ -93,7 +82,7 @@ deploy_decision = Documenter.deploy_folder(deploy_config; repo="github.com/LuxDL
makedocs(; sitename="Lux.jl Documentation",
authors="Avik Pal et al.",
clean=true,
doctest=true,
doctest=false, # We test it in the CI, no need to run it here
modules=[Lux, LuxCore, LuxLib, WeightInitializers, Boltz,
LuxTestUtils, LuxDeviceUtils, LuxAMDGPU, LuxCUDA],
linkcheck=true,
Expand Down
10 changes: 5 additions & 5 deletions src/transform/flux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ Convert a Flux Model to Lux Model.
## Example
```jldoctest
julia> import Flux, Metalhead
julia> import Flux
julia> using Adapt, Lux, Random
julia> m = Metalhead.ResNet(18);
julia> m = Flux.Chain(Flux.Dense(2 => 3, relu), Flux.Dense(3 => 2));
julia> m2 = adapt(FromFluxAdaptor(), m.layers); # or FromFluxAdaptor()(m.layers)
julia> m2 = adapt(FromFluxAdaptor(), m); # or FromFluxAdaptor()(m.layers)
julia> x = randn(Float32, 224, 224, 3, 2);
julia> x = randn(Float32, 2, 32);
julia> ps, st = Lux.setup(Random.default_rng(), m2);
julia> size(first(m2(x, ps, st)))
(1000, 2)
(2, 32)
```
"""
@kwdef struct FromFluxAdaptor <: AbstractToLuxAdaptor
Expand Down
15 changes: 15 additions & 0 deletions test/qa_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@ end
ignore=(:inputsize, :setup, :testmode, :trainmode, :update_state, :AbstractRNG)) ===
nothing
end

@testitem "doctests: Quality Assurance" tags=[:others] begin
using Documenter

doctestexpr = quote
using SimpleChains: static
using Flux: Flux
using Metalhead: Metalhead
using DynamicExpressions
using Adapt, Lux, Random, Optimisers, Zygote
end

DocMeta.setdocmeta!(Lux, :DocTestSetup, doctestexpr; recursive=true)
doctest(Lux; manual=false)
end

0 comments on commit 4061b2a

Please sign in to comment.