diff --git a/.gitignore b/.gitignore index f6abaa9..bfcf178 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ TODO.md docs/_build .vscode Manifest.toml +*/Manifest.toml diff --git a/Makefile b/Makefile index 78e597d..73f5423 100644 --- a/Makefile +++ b/Makefile @@ -5,23 +5,20 @@ JULIA := julia --color=yes --project=@. VERSION := 0.2 -build/sysimage.so: src/utils/sysimage.jl Project.toml Manifest.toml - mkdir -p build - mkdir -p benchmark/results/test - cd benchmark; $(JULIA) --trace-compile=../build/precompile.jl benchmark.jl test/case14 - $(JULIA) src/utils/sysimage.jl +build/sysimage.so: src/utils/sysimage.jl Project.toml + julia --project=. -e "using Pkg; Pkg.instantiate()" + julia --project=test -e "using Pkg; Pkg.instantiate()" + $(JULIA) src/utils/sysimage.jl test/runtests.jl clean: - rm -rf build/* + rm -rfv build docs: cd docs; make clean; make dirhtml rsync -avP --delete-after docs/_build/dirhtml/ ../docs/$(VERSION)/ test: build/sysimage.so - @echo Running tests... - $(JULIA) --sysimage build/sysimage.so -e 'using Pkg; Pkg.test("UnitCommitment")' | tee build/test.log - + $(JULIA) --sysimage build/sysimage.so test/runtests.jl format: julia -e 'using JuliaFormatter; format(["src", "test", "benchmark"], verbose=true);' diff --git a/Project.toml b/Project.toml index c7b62f5..f288cd8 100644 --- a/Project.toml +++ b/Project.toml @@ -19,7 +19,6 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [compat] -Cbc = "0.7" DataStructures = "0.18" Distributions = "0.25" GZip = "0.5" @@ -28,11 +27,3 @@ JuMP = "0.21" MathOptInterface = "0.9" PackageCompiler = "1" julia = "1" - -[extras] -Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76" -Gurobi = "2e9cd046-0924-5485-92f1-d5272153d98b" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["Cbc", "Test", "Gurobi"] diff --git a/src/utils/sysimage.jl b/src/utils/sysimage.jl index b51f6be..b64d0ff 100644 --- a/src/utils/sysimage.jl +++ b/src/utils/sysimage.jl @@ -3,26 +3,31 @@ # Released under the modified BSD license. See COPYING.md for more details. using PackageCompiler +using TOML +using Logging -using DataStructures -using Distributions -using JSON -using JuMP -using MathOptInterface -using SparseArrays +Logging.disable_logging(Logging.Info) +mkpath("build") -pkg = [ - :DataStructures, - :Distributions, - :JSON, - :JuMP, - :MathOptInterface, - :SparseArrays, -] +println("Generating precompilation statements...") +run(`julia --project=. --trace-compile=build/precompile.jl $(ARGS)`) -@info "Building system image..." +println("Finding dependencies...") +project = TOML.parsefile("Project.toml") +manifest = TOML.parsefile("Manifest.toml") +deps = Symbol[] +for dep in keys(project["deps"]) + if "path" in keys(manifest[dep][1]) + println(" - $(dep) [skip]") + else + println(" - $(dep)") + push!(deps, Symbol(dep)) + end +end + +println("Building system image...") create_sysimage( - pkg, + deps, precompile_statements_file = "build/precompile.jl", sysimage_path = "build/sysimage.so", ) diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 0000000..7d70fe1 --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,26 @@ +[deps] +Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76" +DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" +Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" +GZip = "92fee26a-97fe-5a0c-ad85-20a5f3185b63" +Gurobi = "2e9cd046-0924-5485-92f1-d5272153d98b" +JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +JuMP = "4076af6c-e467-56ae-b986-b466b2749572" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" +MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" +PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d" +Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[compat] +DataStructures = "0.18" +Distributions = "0.25" +GZip = "0.5" +JSON = "0.21" +JuMP = "0.21" +MathOptInterface = "0.9" +PackageCompiler = "1" +julia = "1" diff --git a/test/import/egret_test.jl b/test/import/egret_test.jl index 60b481d..494067a 100644 --- a/test/import/egret_test.jl +++ b/test/import/egret_test.jl @@ -4,9 +4,12 @@ using UnitCommitment +basedir = @__DIR__ + @testset "read_egret_solution" begin - solution = - UnitCommitment.read_egret_solution("fixtures/egret_output.json.gz") + solution = UnitCommitment.read_egret_solution( + "$basedir/../fixtures/egret_output.json.gz", + ) for attr in ["Is on", "Production (MW)", "Production cost (\$)"] @test attr in keys(solution) @test "115_STEAM_1" in keys(solution[attr]) diff --git a/test/runtests.jl b/test/runtests.jl index 594d9cd..836eda2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,6 +5,7 @@ using Test using UnitCommitment +push!(Base.LOAD_PATH, @__DIR__) UnitCommitment._setup_logger() const ENABLE_LARGE_TESTS = ("UCJL_LARGE_TESTS" in keys(ENV)) diff --git a/test/transform/initcond_test.jl b/test/transform/initcond_test.jl index 8de438b..3d891f3 100644 --- a/test/transform/initcond_test.jl +++ b/test/transform/initcond_test.jl @@ -4,9 +4,12 @@ using UnitCommitment, Cbc, JuMP +basedir = @__DIR__ + @testset "generate_initial_conditions!" begin # Load instance - instance = UnitCommitment.read("$(pwd())/fixtures/case118-initcond.json.gz") + instance = + UnitCommitment.read("$basedir/../fixtures/case118-initcond.json.gz") optimizer = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0) # All units should have unknown initial conditions diff --git a/test/validation/repair_test.jl b/test/validation/repair_test.jl index f53e087..70e8751 100644 --- a/test/validation/repair_test.jl +++ b/test/validation/repair_test.jl @@ -4,9 +4,11 @@ using UnitCommitment, JSON, GZip, DataStructures +basedir = @__DIR__ + function parse_case14() return JSON.parse( - GZip.gzopen("../instances/test/case14.json.gz"), + GZip.gzopen("$basedir/../../instances/test/case14.json.gz"), dicttype = () -> DefaultOrderedDict(nothing), ) end