Skip to content

Commit 46acec1

Browse files
authored
Add support for Plasmo's distributed implementation (#32)
* Initial changes * initial remote operation * Improved distributed performance * Remote working with distributed * minor updates * Fixed bottleneck in instantiation time * fixed bug in slack calls * Debugging for new proxy variables * added time_limit to termination_status * commit before changing forward pass structure * parallelized Benders more efficient for distributed * checkpoint for refactoring * cleaned up code * fixed setting to node objectives * updated tests for remote problem * Added timing code for master problem * Fixed option * Added possible fix for regularization with feasibility cuts * Fixed regularize in infeasible MIPs * Saving quadratic support * Removed quadratics * Updated version of Project.toml * Added support for remote optigraphs and sequential backward pass * Added to docs * fixed time tracking for master problem * Updated workflow to use separate envs for testing * Updated doc pages to handle different dependencies * Error fix on doc building * Fixed bug in figures * HTML potential fix * Potential fix for 403 error
1 parent 03197ba commit 46acec1

23 files changed

Lines changed: 1928 additions & 680 deletions

.ci/ci.jl

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,69 @@
1-
# This file is adapted from MadNLP's source code here:
2-
# https://github.com/MadNLP/MadNLP.jl/blob/master/.ci/ci.jl
1+
"""
2+
Continuous Integration test driver
33
4-
# Because the subdirectories include packages that need to be tested, this file
5-
# will perform those tests and is called by the test.yaml file in the workflow
4+
This script runs tests for packages under `lib/` in isolated Julia environments
5+
so that conflicting dependency requirements do not interfere with each other.
66
7-
rm(joinpath(@__DIR__, "Project.toml"); force=true)
8-
rm(joinpath(@__DIR__, "Manifest.toml"); force=true)
7+
It is invoked by the GitHub Actions workflow and creates one environment per
8+
package under `.ci/` before running tests. Dependency versions (including
9+
Plasmo) are resolved automatically from each package's compat entries.
10+
"""
911

1012
using Pkg
13+
using Dates
1114

12-
Pkg.activate(@__DIR__)
15+
# Utility to (re)create a clean environment directory
16+
function _clean_env!(envdir::AbstractString)
17+
if !isdir(envdir)
18+
mkpath(envdir)
19+
end
20+
for f in ("Project.toml", "Manifest.toml")
21+
fp = joinpath(envdir, f)
22+
if isfile(fp)
23+
rm(fp; force=true)
24+
end
25+
end
26+
return envdir
27+
end
1328

14-
# if other packages are added to lib, this file can be updated with those package names
15-
pkgs = ["PlasmoBenders", "PlasmoSchwarz"]
29+
"""
30+
test_package(pkg::AbstractString)
1631
17-
Pkg.develop.([PackageSpec(path=joinpath(@__DIR__,"..","lib",pkg)) for pkg in pkgs])
18-
Pkg.build()
32+
Create a fresh isolated environment for `pkg`, develop the package from
33+
`lib/pkg`, and run its tests with coverage enabled. All dependency versions are
34+
resolved by Julia's package manager according to the package's compat bounds.
35+
"""
36+
function test_package(pkg::AbstractString)
37+
envdir = joinpath(@__DIR__, "env-" * pkg)
38+
_clean_env!(envdir)
1939

20-
Pkg.test.(pkgs, coverage=true)
40+
# Activate isolated env for this package
41+
Pkg.activate(envdir)
42+
43+
# Bring the target package into this environment in development mode
44+
Pkg.develop(PackageSpec(path = joinpath(@__DIR__, "..", "lib", pkg)))
45+
46+
# Resolve, build, and precompile before testing
47+
Pkg.instantiate()
48+
Pkg.build()
49+
try
50+
Pkg.precompile()
51+
catch err
52+
@warn "Precompile failed; proceeding to tests" exception=(err, catch_backtrace())
53+
end
54+
55+
@info "Running tests for $(pkg) (auto-resolved dependencies)" timestamp=Dates.now()
56+
Pkg.test(pkg; coverage = true)
57+
end
58+
59+
# Allow selection via environment variables for CI job splitting.
60+
# If PKG is set, only test that package. Otherwise, test both sequentially.
61+
pkg_sel = get(ENV, "PKG", nothing)
62+
63+
if pkg_sel !== nothing
64+
test_package(pkg_sel)
65+
else
66+
# Run both if not explicitly selected
67+
test_package("PlasmoBenders")
68+
test_package("PlasmoSchwarz")
69+
end

.github/workflows/Documentation.yaml

Lines changed: 100 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ on:
88
pull_request:
99

1010
jobs:
11-
build:
11+
benders-docs:
12+
name: Docs (PlasmoBenders)
1213
permissions:
1314
actions: write
1415
contents: write
@@ -19,12 +20,104 @@ jobs:
1920
- uses: actions/checkout@v4
2021
- uses: julia-actions/setup-julia@latest
2122
with:
22-
version: '1.6'
23+
version: '1.10'
2324
- uses: julia-actions/cache@v1
24-
- name: Install dependencies
25+
- name: Install dependencies (PlasmoBenders)
26+
env:
27+
DOC_PKG: PlasmoBenders
28+
run: julia --project=docs/ docs/install.jl
29+
- name: Build and deploy (PlasmoBenders)
30+
env:
31+
DOC_PKG: PlasmoBenders
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
34+
run: julia --project=docs/ docs/make.jl
35+
36+
schwarz-docs:
37+
name: Docs (PlasmoSchwarz)
38+
needs: benders-docs
39+
permissions:
40+
actions: write
41+
contents: write
42+
pull-requests: read
43+
statuses: write
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: julia-actions/setup-julia@latest
48+
with:
49+
version: '1.10'
50+
- uses: julia-actions/cache@v1
51+
- name: Install dependencies (PlasmoSchwarz)
52+
env:
53+
DOC_PKG: PlasmoSchwarz
2554
run: julia --project=docs/ docs/install.jl
26-
- name: Build and deploy
55+
- name: Build and deploy (PlasmoSchwarz)
56+
env:
57+
DOC_PKG: PlasmoSchwarz
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
60+
run: julia --project=docs/ docs/make.jl
61+
62+
docs-index:
63+
name: Docs (index)
64+
needs: [benders-docs, schwarz-docs]
65+
if: github.event_name == 'push'
66+
permissions:
67+
contents: write
68+
runs-on: ubuntu-latest
69+
steps:
70+
- name: Fetch gh-pages branch
71+
run: |
72+
git init
73+
git remote add origin https://github.com/${{ github.repository }}.git
74+
git fetch origin gh-pages || echo "gh-pages branch will be created"
75+
git checkout -B gh-pages
76+
- name: Create dev index with links
77+
run: |
78+
mkdir -p dev
79+
cat > dev/index.html <<'EOF'
80+
<!doctype html>
81+
<html lang="en">
82+
<head>
83+
<meta charset="utf-8" />
84+
<meta name="viewport" content="width=device-width, initial-scale=1" />
85+
<title>PlasmoAlgorithms.jl Docs</title>
86+
<style>
87+
body { font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; margin: 2rem; }
88+
h1 { margin-bottom: 0.5rem; }
89+
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 1rem; }
90+
.card { border: 1px solid #e0e0e0; border-radius: 8px; padding: 1rem; }
91+
a { text-decoration: none; color: #0059b3; font-weight: 600; }
92+
small { color: #666; }
93+
</style>
94+
</head>
95+
<body>
96+
<h1>PlasmoAlgorithms.jl documentation</h1>
97+
<p>Select a sub-package:</p>
98+
<div class="cards">
99+
<div class="card">
100+
<a href="../benders/">PlasmoBenders</a>
101+
<div><small>Decomposition via Benders</small></div>
102+
</div>
103+
<div class="card">
104+
<a href="../schwarz/">PlasmoSchwarz</a>
105+
<div><small>Domain decomposition (Schwarz)</small></div>
106+
</div>
107+
</div>
108+
</body>
109+
</html>
110+
EOF
111+
- name: Commit and push index
27112
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
29-
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
30-
run: julia --project=docs/ docs/make.jl
113+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
run: |
115+
git config user.name "github-actions[bot]"
116+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
117+
git add dev/index.html
118+
if git diff --cached --quiet; then
119+
echo "No changes to commit"
120+
else
121+
git commit -m "Update docs dev index with links to benders and schwarz"
122+
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git gh-pages
123+
fi

.github/workflows/test.yaml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build
1+
name: tests
22

33
on:
44
push:
@@ -12,17 +12,40 @@ permissions:
1212
contents: read
1313

1414
jobs:
15-
test-github:
15+
benders:
16+
name: PlasmoBenders
1617
runs-on: ${{ matrix.os }}
1718
strategy:
19+
fail-fast: false
1820
matrix:
1921
julia-version: ['1.10']
20-
julia-arch: [x64]
21-
os: [ubuntu-latest,macos-latest,windows-latest]
22+
os: [ubuntu-latest, macos-latest, windows-latest]
2223
steps:
23-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v4
2425
- uses: julia-actions/setup-julia@latest
2526
with:
26-
version: ${{ matrix.julia-version }}
27+
version: ${{ matrix.julia-version }}
2728
- uses: julia-actions/cache@v1
28-
- run: julia --color=yes --project=.ci .ci/ci.jl
29+
- name: Run tests (PlasmoBenders)
30+
env:
31+
PKG: PlasmoBenders
32+
run: julia --color=yes .ci/ci.jl
33+
34+
schwarz:
35+
name: PlasmoSchwarz
36+
runs-on: ${{ matrix.os }}
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
julia-version: ['1.10']
41+
os: [ubuntu-latest, macos-latest, windows-latest]
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: julia-actions/setup-julia@latest
45+
with:
46+
version: ${{ matrix.julia-version }}
47+
- uses: julia-actions/cache@v1
48+
- name: Run tests (PlasmoSchwarz)
49+
env:
50+
PKG: PlasmoSchwarz
51+
run: julia --color=yes .ci/ci.jl

docs/install.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ using Pkg
22

33
PA_DIR = pwd()
44

5-
Pkg.develop(path=joinpath(PA_DIR, "lib", "PlasmoBenders"))
6-
Pkg.develop(path=joinpath(PA_DIR, "lib", "PlasmoSchwarz"))
5+
doc_pkg = get(ENV, "DOC_PKG", nothing)
6+
7+
if doc_pkg === nothing
8+
# Fallback: develop both (may conflict if dependencies are incompatible)
9+
@info "DOC_PKG not set; developing both PlasmoBenders and PlasmoSchwarz"
10+
Pkg.develop(path=joinpath(PA_DIR, "lib", "PlasmoBenders"))
11+
Pkg.develop(path=joinpath(PA_DIR, "lib", "PlasmoSchwarz"))
12+
else
13+
@info "Developing only $(doc_pkg) for docs build"
14+
Pkg.develop(path=joinpath(PA_DIR, "lib", doc_pkg))
15+
end
16+
717
Pkg.instantiate()

0 commit comments

Comments
 (0)