Skip to content

Commit

Permalink
heta_compiler v check moved to load_jlplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
ivborissov committed Sep 3, 2024
1 parent 2d24be4 commit 55f899d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/heta_cli/connect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ function load_jlplatform(
model_jl::AbstractString;
rm_out::Bool = false
)

# load model to Main
Base.include(Main, model_jl)

version = Main.__platform__[3]
@assert version == HETA_COMPILER_VERSION "The model was build with Heta compiler v$version, which is not supported.\n"*
"This HetaSimulator release includes Heta compiler v$HETA_COMPILER_VERSION. Please re-compile the model with HetaSimulator load_platform()."

# remove output after model load
rm_out && rm(dirname("$model_jl"); force=true, recursive=true)
Expand Down
4 changes: 0 additions & 4 deletions src/import_platform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ function Platform(
scenarios::Tuple,
version::String
)
# TODO: semver approach might be better
@assert version == HETA_COMPILER_VERSION "The model was build with Heta compiler v$version, which is not supported.\n"*
"This HetaSimulator release includes Heta compiler v$HETA_COMPILER_VERSION. Please re-compile the model with HetaSimulator load_platform()."

print("Loading platform... ")
model_pairs = [pair[1] => Model(pair[2]...) for pair in pairs(models)]

Expand Down
18 changes: 18 additions & 0 deletions test/dummy_jlmodel.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#=
This code was generated by heta-compiler 0.0.1
=#

__platform__ = (function()

### NO MODEL CODE ###

return (
(
nameless = nothing,
),
(),
"0.0.1"
)

end
)()
3 changes: 2 additions & 1 deletion test/heta_compiler_test.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

@test chomp(read(`$(HetaSimulator.heta_exe_path) -v`, String)) == HetaSimulator.HETA_COMPILER_VERSION
@test chomp(read(`$(HetaSimulator.heta_exe_path) -v`, String)) == HetaSimulator.HETA_COMPILER_VERSION
@test_throws AssertionError("The model was build with Heta compiler v0.0.1, which is not supported.\nThis HetaSimulator release includes Heta compiler v0.8.6. Please re-compile the model with HetaSimulator load_platform().") load_jlplatform("$HetaSimulatorDir/test/dummy_jlmodel.jl")

0 comments on commit 55f899d

Please sign in to comment.