Skip to content

Commit 0644640

Browse files
authored
Merge pull request #93 from control-toolbox/92-updates
Updates
2 parents bb2f848 + 887a389 commit 0644640

418 files changed

Lines changed: 123811 additions & 7532 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/SpellCheck.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ on:
77
jobs:
88
call:
99
uses: control-toolbox/CTActions/.github/workflows/spell-check.yml@main
10+
with:
11+
config-path: '.typos.toml'

.github/workflows/benchmark-reusable.yml

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ jobs:
116116
run: |
117117
echo "🚀 Starting benchmark execution..."
118118
119+
BENCH_FILENAME=$(basename "$SCRIPT_PATH")
120+
BENCH_ID="${BENCH_FILENAME%.jl}"
121+
OUTPUT_DIR="docs/src/assets/benchmarks/$BENCH_ID"
122+
mkdir -p "$OUTPUT_DIR"
123+
export BENCHMARK_OUTPUT_DIR="$OUTPUT_DIR"
124+
export BENCHMARK_ID="$BENCH_ID"
125+
echo "BENCHMARK_OUTPUT_DIR=$OUTPUT_DIR" >> $GITHUB_ENV
126+
echo "BENCHMARK_ID=$BENCH_ID" >> $GITHUB_ENV
127+
128+
echo "🏷️ Benchmark ID: $BENCH_ID"
129+
echo "📁 Output directory (pre-created): $OUTPUT_DIR"
130+
119131
julia --color=yes -e '
120132
using Pkg
121133
@@ -134,17 +146,34 @@ jobs:
134146
135147
println("🔄 Loading CTBenchmarks package...")
136148
using CTBenchmarks
137-
149+
138150
include(ENV["SCRIPT_PATH"])
139-
out = main()
140-
println("📄 Output file: ", out)
141-
open(ENV["BENCHMARK_OUTPUT_FILE"], "w") do f
142-
write(f, string(out))
151+
if !isdefined(Main, :run)
152+
error("Benchmark script must define a run() function that returns benchmark results")
153+
end
154+
155+
println("▶️ Running benchmark script...")
156+
results = run()
157+
158+
bench_id = ENV["BENCHMARK_ID"]
159+
outpath = ENV["BENCHMARK_OUTPUT_DIR"]
160+
figures_dir = joinpath(outpath, "figures")
161+
162+
println("📊 Generating solution plots...")
163+
CTBenchmarks.plot_solutions(results, figures_dir)
164+
165+
json_path = joinpath(outpath, string(bench_id, ".json"))
166+
println("💾 Saving results to ", json_path)
167+
CTBenchmarks.save_json(results, json_path)
168+
println("📄 JSON file created: ", json_path)
169+
open(ENV["GITHUB_ENV"], "a") do io
170+
println(io, "BENCHMARK_JSON=$json_path")
143171
end
144-
println("💾 Output path saved to ", ENV["BENCHMARK_OUTPUT_FILE"])
145172
'
146173
147174
echo "✅ Benchmark execution completed"
175+
echo "$OUTPUT_DIR" > "$BENCHMARK_OUTPUT_FILE"
176+
echo "💾 Output path saved to $BENCHMARK_OUTPUT_FILE"
148177
echo "benchmark_success=true" >> $GITHUB_OUTPUT
149178
150179
# ---------------------------
@@ -202,7 +231,8 @@ jobs:
202231
OUTPUT_DIR=$(cat "$BENCHMARK_OUTPUT_FILE")
203232
echo "✅ Benchmark output directory found: $OUTPUT_DIR"
204233
205-
DATA_JSON_PATH="$OUTPUT_DIR/data.json"
234+
BENCH_ID="${BENCHMARK_ID:-$(basename "$OUTPUT_DIR") }"
235+
DATA_JSON_PATH="$OUTPUT_DIR/$BENCH_ID.json"
206236
echo "📄 Resolved JSON path: $DATA_JSON_PATH"
207237
208238
if [ -f "$DATA_JSON_PATH" ]; then
@@ -276,10 +306,11 @@ jobs:
276306
DIR_NAME=$(basename "$OUTPUT_DIR")
277307
278308
ARTIFACTS=(
279-
"$OUTPUT_DIR/data.json"
309+
"$OUTPUT_DIR/$DIR_NAME.json"
280310
"$OUTPUT_DIR/Project.toml"
281311
"$OUTPUT_DIR/Manifest.toml"
282312
"$OUTPUT_DIR/$DIR_NAME.jl"
313+
"$OUTPUT_DIR/figures"
283314
)
284315
285316
# Add only benchmark artifacts
@@ -294,7 +325,7 @@ jobs:
294325
295326
echo "📝 Committing $STAGED file(s) to branch $BRANCH_NAME..."
296327
git commit -m "📊 Add benchmark results (${DIR_NAME})" \
297-
-m "Results saved to ${OUTPUT_DIR}/data.json" \
328+
-m "Results saved to ${OUTPUT_DIR}/${DIR_NAME}.json" \
298329
-m "Includes environment TOMLs and benchmark script" \
299330
>/dev/null 2>&1 || {
300331
echo "❌ Commit failed"
@@ -333,9 +364,10 @@ jobs:
333364
exit 1
334365
fi
335366
367+
DIR_NAME=$(basename "$OUTPUT_DIR")
336368
echo "📊 Benchmark workflow summary:"
337369
echo "✅ Benchmark execution: SUCCESS"
338-
echo "📁 Results saved to: $OUTPUT_DIR/data.json"
370+
echo "📁 Results saved to: $OUTPUT_DIR/$DIR_NAME.json"
339371
echo "🌳 Results committed to: ${{ github.head_ref || github.ref_name }} branch"
340372
echo "📘 Ready for documentation generation"
341373
echo "🎉 Reusable benchmark workflow completed successfully!"

.github/workflows/benchmarks-orchestrator.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,21 @@ jobs:
215215
ignore-no-cache: true
216216

217217
- name: Install dependencies for docs
218-
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
218+
env:
219+
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
220+
JULIA_PKG_PRECOMPILE_DELAY: 0
221+
run: |
222+
julia --project=docs/ --startup-file=no -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
223+
continue-on-error: true
224+
225+
- name: Retry install dependencies for docs (if failed)
226+
if: failure()
227+
env:
228+
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
229+
JULIA_PKG_PRECOMPILE_DELAY: 0
230+
run: |
231+
sleep 30
232+
julia --project=docs/ --startup-file=no -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
219233
220234
# ---------------------------
221235
# Build and deploy documentation
@@ -242,7 +256,7 @@ jobs:
242256
script: |
243257
console.log('🚨 Workflow failure detected - posting/updating comment...');
244258
245-
const marker = '<!-- ctbenchmarks-failure-comment -->';
259+
const marker = '<!-- ctbenchmarks-status-comment -->';
246260
const prNumber = context.payload.pull_request.number;
247261
const failedJobs = [];
248262
@@ -334,7 +348,7 @@ jobs:
334348
script: |
335349
console.log('🎉 Workflow success detected - posting/updating comment...');
336350
337-
const marker = '<!-- ctbenchmarks-success-comment -->';
351+
const marker = '<!-- ctbenchmarks-status-comment -->';
338352
const prNumber = context.payload.pull_request.number;
339353
const previewUrl = `https://control-toolbox.org/CTBenchmarks.jl/previews/PR${prNumber}/index.html`;
340354
const benchmarksSummary = process.env.BENCHMARKS_SUMMARY;

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,4 +356,6 @@ Manifest.toml
356356
**/Manifest.toml
357357
# ...except the one inside docs/
358358
!docs/src/assets/**/Manifest.toml
359-
tmp/
359+
tmp/
360+
test/build
361+
reports

.markdownlint.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"MD025": false,
3+
"MD013": false,
4+
"MD041": false,
5+
"MD024": false
6+
}

.typos.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[default]
2+
locale = "en"
3+
4+
[default.extend-identifiers]
5+
6+
[files]
7+
extend-exclude = [
8+
"*.json",
9+
"*.toml",
10+
"*.svg",
11+
"docs/src/assets/plots/*",
12+
]

Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ authors = ["Olivier Cots <olivier.cots@toulouse-inp.fr>"]
55

66
[deps]
77
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
8+
CTBase = "54762871-cc72-4466-b8e8-f6c8b58076cd"
89
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
910
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
1011
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
12+
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1113
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
1214
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
1315
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
@@ -18,15 +20,18 @@ NLPModelsIpopt = "f4238b75-b362-5c4c-b852-0801c9a21d71"
1820
OptimalControl = "5f98b655-cc9a-415a-b60e-744165666948"
1921
OptimalControlProblems = "59046045-fb9c-4c23-964f-ff0a25704f96"
2022
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
23+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
2124
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
2225
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
2326
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
2427

2528
[compat]
2629
BenchmarkTools = "1"
30+
CTBase = "0.16"
2731
CUDA = "5"
2832
DataFrames = "1"
2933
Dates = "1"
34+
DocStringExtensions = "0.9"
3035
InteractiveUtils = "1"
3136
Ipopt = "1"
3237
JSON = "1"
@@ -37,6 +42,7 @@ NLPModelsIpopt = "0.11"
3742
OptimalControl = "1"
3843
OptimalControlProblems = "0.3"
3944
Pkg = "1"
45+
Plots = "1.41"
4046
Printf = "1"
4147
Sockets = "1"
4248
Tables = "1"

benchmarks/benchmarks-config.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,14 @@
1111
"id": "core-moonshot-cpu",
1212
"julia_version": "1.11",
1313
"julia_arch": "x64",
14-
"runs_on": "[\"self-hosted\", \"Linux\", \"gpu\", \"cuda\", \"cuda12\"]",
14+
"runs_on": "[\"moonshot\"]",
1515
"runner": "self-hosted"
1616
},
1717
{
1818
"id": "core-moonshot-gpu",
1919
"julia_version": "1.11",
2020
"julia_arch": "x64",
21-
"runs_on": "[\"self-hosted\", \"Linux\", \"gpu\", \"cuda\", \"cuda12\"]",
22-
"runner": "self-hosted"
23-
},
24-
{
25-
"id": "core-mothra-gpu",
26-
"julia_version": "1.11",
27-
"julia_arch": "x64",
28-
"runs_on": "[\"self-hosted\", \"Linux\", \"gpu\", \"cuda\", \"cuda13\"]",
21+
"runs_on": "[\"moonshot\"]",
2922
"runner": "self-hosted"
3023
}
3124
]

benchmarks/core-moonshot-cpu.jl

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
# Benchmark script for core-moonshot-cpu
22
# Setup (Pkg.activate, instantiate, update, using CTBenchmarks) is handled by the workflow
33

4-
function main()
5-
project_dir = normpath(@__DIR__, "..")
6-
outpath=joinpath(
7-
project_dir, "docs", "src", "assets", "benchmarks", "core-moonshot-cpu"
8-
)
9-
CTBenchmarks.benchmark(;
10-
outpath=outpath,
4+
function run()
5+
results = CTBenchmarks.benchmark(;
116
problems=[
127
:beam,
138
:chain,
@@ -24,15 +19,15 @@ function main()
2419
:steering,
2520
:vanderpol,
2621
],
27-
solver_models=[:ipopt => [:JuMP, :adnlp, :exa], :madnlp => [:JuMP, :adnlp, :exa]],
22+
solver_models=[:ipopt => [:jump, :adnlp, :exa], :madnlp => [:jump, :adnlp, :exa]],
2823
grid_sizes=[200, 500, 1000, 2000, 5000],
2924
disc_methods=[:trapeze],
30-
tol=1e-6,
25+
tol=1e-8,
3126
ipopt_mu_strategy="adaptive",
3227
print_trace=false,
3328
max_iter=1000,
34-
max_wall_time=200.0,
29+
max_wall_time=400.0,
3530
)
3631
println("✅ Benchmark completed successfully!")
37-
return outpath
32+
return results
3833
end

benchmarks/core-moonshot-gpu.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
# Benchmark script for core-moonshot
1+
# Benchmark script for core-moonshot-gpu
22
# Setup (Pkg.activate, instantiate, update, using CTBenchmarks) is handled by the workflow
33

4-
function main()
5-
project_dir = normpath(@__DIR__, "..")
6-
outpath = joinpath(project_dir, "docs", "src", "assets", "benchmarks", "core-moonshot-gpu")
7-
CTBenchmarks.benchmark(;
8-
outpath=outpath,
4+
function run()
5+
results = CTBenchmarks.benchmark(;
96
problems=[
107
:beam,
118
:chain,
129
:double_oscillator,
13-
:ducted_fan,
10+
# :ducted_fan,
1411
:electric_vehicle,
1512
:glider,
1613
:insurance,
@@ -32,5 +29,5 @@ function main()
3229
max_wall_time=1000.0,
3330
)
3431
println("✅ Benchmark completed successfully!")
35-
return outpath
32+
return results
3633
end

0 commit comments

Comments
 (0)