Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] exclude Gurobi examples if built from fork #3919

Merged
merged 6 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
34 changes: 30 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import Documenter
import DocumenterCitations
import Downloads
import Gurobi
import Literate
import MathOptInterface
import Pkg
Expand All @@ -30,6 +31,24 @@ const _IS_GITHUB_ACTIONS = get(ENV, "GITHUB_ACTIONS", "false") == "true"
# Pass --pdf to build the PDF. On GitHub actions, we always build the PDF.
const _PDF = findfirst(isequal("--pdf"), ARGS) !== nothing || _IS_GITHUB_ACTIONS

# Exclude these files because they require ${{ secrets.WLSLICENSE }}, which
# is not available to forks.
const _HAS_GUROBI = try
Gurobi.Env()
true
catch
false
end
@show _HAS_GUROBI

const _GUROBI_EXCLUDES = String[]
if !_HAS_GUROBI
push!(_GUROBI_EXCLUDES, "benders_decomposition")
push!(_GUROBI_EXCLUDES, "tsp_lazy_constraints")
push!(_GUROBI_EXCLUDES, "callbacks")
push!(_GUROBI_EXCLUDES, "multiple_solutions")
end

# ==============================================================================
# Run literate.jl
# ==============================================================================
Expand All @@ -55,10 +74,17 @@ function _link_example(content)
end

function _file_list(full_dir, relative_dir, extension)
return map(
file -> joinpath(relative_dir, file),
filter(file -> endswith(file, extension), sort(readdir(full_dir))),
)
function filter_fn(filename)
if !endswith(filename, extension)
return false
elseif _HAS_GUROBI
return true
end
return all(f -> !endswith(filename, f * extension), _GUROBI_EXCLUDES)
end
return map(filter!(filter_fn, sort!(readdir(full_dir)))) do file
return joinpath(relative_dir, file)
end
end

"""
Expand Down
8 changes: 8 additions & 0 deletions docs/src/tutorials/algorithms/benders_decomposition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```@meta
EditURL = "benders_decomposition.jl"
```

# [Benders decomposition](@id benders_decomposition_classical)

This page is a placeholder that appears only if the documentation is built from
a fork.
odow marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions docs/src/tutorials/algorithms/tsp_lazy_constraints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```@meta
EditURL = "tsp_lazy_constraints.jl"
```

# [Traveling Salesperson Problem](@id tsp_lazy)

This page is a placeholder that appears only if the documentation is built from
a fork.
8 changes: 8 additions & 0 deletions docs/src/tutorials/linear/callbacks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```@meta
EditURL = "callbacks.jl"
```

# [Callbacks](@id callbacks_tutorial)

This page is a placeholder that appears only if the documentation is built from
a fork.
8 changes: 8 additions & 0 deletions docs/src/tutorials/linear/multiple_solutions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```@meta
EditURL = "multiple_solutions.jl"
```

# Finding multiple feasible solutions

This page is a placeholder that appears only if the documentation is built from
a fork.
14 changes: 2 additions & 12 deletions src/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@ primal solution available from [`callback_value`](@ref) is integer feasible.

## Example

```jldoctest; filter=r"CALLBACK_NODE_STATUS_.+"
```julia
julia> import Gurobi

julia> model = Model(Gurobi.Optimizer);
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 722777
Set parameter GURO_PAR_SPECIAL
WLS license 722777 - registered to JuMP Development

julia> set_silent(model)

Expand Down Expand Up @@ -73,15 +68,10 @@ Use [`callback_node_status`](@ref) to check whether a solution is available.

## Example

```jldoctest
```julia
julia> import Gurobi

julia> model = Model(Gurobi.Optimizer);
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 722777
Set parameter GURO_PAR_SPECIAL
WLS license 722777 - registered to JuMP Development

julia> set_silent(model)

Expand Down
Loading