Skip to content

Commit

Permalink
Merge pull request #62 from hetalang/hc-090
Browse files Browse the repository at this point in the history
heta-compiler v0.9.0 support
  • Loading branch information
ivborissov authored Sep 27, 2024
2 parents 9832873 + 3a37142 commit cc3f424
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 51 deletions.
24 changes: 12 additions & 12 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
[[heta_app]]
arch = "x86_64"
git-tree-sha1 = "a23558d3a8dafc1280df998cda01be5f3df5322b"
git-tree-sha1 = "3555032f7d9bf3667af7c796e7c5e6ef65ab184d"
libc = "glibc"
os = "linux"

[[heta_app.download]]
sha256 = "c3de7b6935653e4f0e4b0ff7251b639e76d5fecda1a825784f72ee02cb2381c5"
url = "https://github.com/hetalang/heta-compiler/releases/download/v0.8.7/heta-compiler-linux.tar.gz"
sha256 = "93b951ccf358cdd06f525a6022d1fae801d9e135f7196d082bc1b1ff44069058"
url = "https://github.com/hetalang/heta-compiler/releases/download/v0.9.0/heta-compiler-linux.tar.gz"
[[heta_app]]
arch = "x86_64"
git-tree-sha1 = "b31deea146ed62c2f686888074499a99fb876080"
git-tree-sha1 = "f9a91d0fab917fbd4567bd9c1330670483f77431"
os = "windows"

[[heta_app.download]]
sha256 = "0b8af8715f6a50240dd475599615c466c4d4bd7979477a512c0b8de20d6cacdf"
url = "https://github.com/hetalang/heta-compiler/releases/download/v0.8.7/heta-compiler-windows.tar.gz"
sha256 = "950b729cf15a60ab83bd3997b9cc0424f0f8885b311d319690052093c9bc2ef6"
url = "https://github.com/hetalang/heta-compiler/releases/download/v0.9.0/heta-compiler-windows.tar.gz"
[[heta_app]]
arch = "x86_64"
git-tree-sha1 = "a741cebf5cd6872b9da78a1713e5b835f9bc919b"
git-tree-sha1 = "0da38cac8b6fbf9d7d20316a2b1c0e6dc1b4adc3"
os = "macos"

[[heta_app.download]]
sha256 = "9454cd0b5a47f5692a5a5decdf47a0e03ef18892f4be5c55d28777bf499176a3"
url = "https://github.com/hetalang/heta-compiler/releases/download/v0.8.7/heta-compiler-macos.tar.gz"
sha256 = "8cb8bf7d3fe70926726074debd3692ac641903623669e3d0930552eb2c8ed8be"
url = "https://github.com/hetalang/heta-compiler/releases/download/v0.9.0/heta-compiler-macos.tar.gz"
[[heta_app]]
arch = "aarch64"
git-tree-sha1 = "a741cebf5cd6872b9da78a1713e5b835f9bc919b"
git-tree-sha1 = "0da38cac8b6fbf9d7d20316a2b1c0e6dc1b4adc3"
os = "macos"

[[heta_app.download]]
sha256 = "9454cd0b5a47f5692a5a5decdf47a0e03ef18892f4be5c55d28777bf499176a3"
url = "https://github.com/hetalang/heta-compiler/releases/download/v0.8.7/heta-compiler-macos.tar.gz"
sha256 = "8cb8bf7d3fe70926726074debd3692ac641903623669e3d0930552eb2c8ed8be"
url = "https://github.com/hetalang/heta-compiler/releases/download/v0.9.0/heta-compiler-macos.tar.gz"
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 0.7.0

- heta-compiler updated to 0.9.0
- changes in `load_platform`: add `spaceFilter`

## 0.6.2

- added aarch64 macos support
Expand Down
6 changes: 3 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ _The rest of ideas and issues are posted in https://github.com/hetalang/heta-dis

## bugs

- Big models can result in StackOverFlow because of Savings
- выдает warning при отсутствие параметра в модели - неудобно при фиттниге
- `parameters` method in Scenario should get the scenario-level parameters but not the full list of constants
- wrong get parameters from MCResults, Pair{Symbol, MCResults}, Vector{Pair{Symbol, MCResults}}
-
- не выводит параметры уровня `Scenario` в `DataFrame(::SimResult)`
- "NaN dt detected" при `sim` если параметр задается на уровне `Scenario`

## fitting

Expand Down
2 changes: 1 addition & 1 deletion artifacts_scripts/build_artifacts.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ArtifactUtils
using Pkg.Artifacts

const HETA_COMPILER_RELEASE = "v0.8.7"
const HETA_COMPILER_RELEASE = "v0.9.0"

const artifacts_toml = joinpath(@__DIR__, "..", "Artifacts.toml")

Expand Down
1 change: 0 additions & 1 deletion cases/story_3/index.heta
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ Vol1 = 6.000102e+00;
kmax = 2.221855e+03;
Km = 9.997290e+03;
*/
#export {format: Julia, filepath: julia_platform};
10 changes: 4 additions & 6 deletions docs/src/basics/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Heta is a modeling language for quantitative systems pharmacology (QSP) and syst
It is a DSL (domain-specific language) describing dynamic model or multiple models in process-description format.
Heta compiler converts it into variety of formats including Julia code, which can be loaded to Julia/HetaSimulator environment.

HetaSimulator supports all features of the [Heta language](https://hetalang.github.io/#/specifications/). One can organize modeling project with re-used modules (files), include any number of models into a single platform with the namespaces mechanism. The platform can use the declaration file __platform.json__ or can be loaded directly from the heta file.
HetaSimulator supports all features of the [Heta language](https://hetalang.github.io/#/specifications/). One can organize modeling project with re-used modules (files), include any number of models into a single platform with the namespaces mechanism. The platform can use the declaration file __platform.yml__ or can be loaded directly from the heta file.
All Heta modules: Heta code, tables, SBML and JSON can be loaded as a modeling platform and compiled into ODE-based mathematical representation.

To read more about Heta-based modeling platforms and Heta compiler visit the homepage <https://hetalang.github.io/#/>.
Expand Down Expand Up @@ -141,20 +141,18 @@ The list of additional arguments is approximately the same as [CLI options](http

Alternatively you can use files generated with stand-alone [Heta compiler](https://hetalang.github.io/#/heta-compiler/).

To do so the model code should be updated with the `#export` statement.
To do so the model code should be build with `--export Julia` options.

```heta
...
sw2 @TimeSwitcher {start: 0, period: 24, active: false};
A0 [sw2]= dose;
#export {format: Julia, filepath: julia_platform};
```

Running the code with the console command `heta build my_project` produces the file __my\_example/dist/julia\_platform/model.jl__ which can be loaded with [`load_jlplatform`](@ref) method.
Running the code with the console command `heta build --export Julia my_project` produces the file __my\_example/dist/julia/model.jl__ which can be loaded with [`load_jlplatform`](@ref) method.

```julia
p = load_jlplatform("./my_example/dist/julia_platform/model.jl")
p = load_jlplatform("./my_example/dist/julia/model.jl")
```
```julia
Loading platform... OK!
Expand Down
2 changes: 0 additions & 2 deletions docs/src/tutorial/fit-files/index.heta
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ A0 [sw2]= dose;
sigma1 @Const = 0.1;
sigma2 @Const = 0.1;
sigma3 @Const = 0.1;

#export {format: Julia, filepath: julia_platform};
2 changes: 1 addition & 1 deletion src/HetaSimulator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module HetaSimulator
import Base: SHA1

# heta-compiler supported version
const HETA_COMPILER_VERSION = "0.8.7"
const HETA_COMPILER_VERSION = "0.9.0"
#const SUPPORTED_VERSIONS = ["0.8.4", "0.8.5", "0.8.6"]

function heta_compiler_load()
Expand Down
15 changes: 10 additions & 5 deletions src/heta_cli/connect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const MODEL_NAME = "model.jl"
"""
load_platform(
target_dir::AbstractString;
rm_out::Bool = true,
julia_only::Bool = true,
rm_out::Bool = true,
dist_dir::String = ".",
source::String = "index.heta",
type::String = "heta",
Expand All @@ -30,10 +29,16 @@ function load_platform(
target_dir::AbstractString;
rm_out::Bool = true,
dist_dir::String = ".",
spaceFilter::Union{String, Vector{:Symbol}, Nothing} = nothing,
kwargs...
)
# convert heta model to julia
build_res = heta_build(target_dir; julia_only = true, dist_dir = dist_dir, kwargs...)
if spaceFilter isa Vector{String}
spaceFilter = "^(" * join(spaceFilter, "|") * ")\$"
end

export_ = isnothing(spaceFilter) ? "{format:Julia,filepath:$MODEL_DIR}" : "{format:Julia,filepath:$MODEL_DIR,spaceFilter:'$spaceFilter'}"
# convert heta model to julia
build_res = heta_build(target_dir; dist_dir = dist_dir, export_ = export_, kwargs...)

# check the exitcode (0 - success, 1 - failure)
build_res == 1 && throw("Compilation errors. Likely there is an error in the code of the model. See logs")
Expand All @@ -42,7 +47,7 @@ function load_platform(
_target_dir = abspath(target_dir)

# load model to Main
return load_jlplatform("$_target_dir/$MODEL_DIR/$MODEL_NAME"; rm_out)
return load_jlplatform("$_target_dir/$dist_dir/$MODEL_DIR/$MODEL_NAME"; rm_out)
end

"""
Expand Down
22 changes: 6 additions & 16 deletions src/heta_cli/heta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,14 @@ end
heta_build(
target_dir::AbstractString;
declaration::String = "platform",
skip_export::Bool = false,
units_check::Bool = false,
log_mode::String = "error",
debug::Bool = false,
julia_only::Bool = false,
debug::Bool = false
dist_dir::String = "dist",
meta_dir::String = "meta",
source::String = "index.heta",
type::String = "heta"
export::String = nothing
)
Builds the models from Heta-based platform
Expand All @@ -91,53 +90,44 @@ Arguments:
- `target_dir` : path to a Heta platform directory
- `declaration` : path to declaration file. Default is `"platform"`
- `skip_export` : if set to `true` no files will be created. Default is `false`
- `units_check` : if set to `true` units will be checked for the consistancy
- `log_mode` : log mode. Default is `"error"`
- `debug` : turn on debug mode. Default is `false`
- `julia_only` : export only julia-based model. Default is `false`
- `dist_dir` : directory path, where to write distributives to. Default is `"dist"`
- `meta_dir` : meta directory path. Default is `"meta"`
- `source` : path to the main heta module. Default is `"index.heta"`
- `type` : type of the source file. Default is `"heta"`
- `export` : export the model to the specified format: `Julia,JSON`, `{format:SBML,version:L3V1},JSON`
"""
function heta_build(
target_dir::AbstractString;
declaration::String = "platform",
skip_export::Bool = false,
units_check::Bool = false,
log_mode::String = "error",
debug::Bool = false,
julia_only::Bool = false,
dist_dir::String = "dist",
meta_dir::String = "meta",
source::String = "index.heta",
type::String = "heta"
type::String = "heta",
export_::Union{String, Nothing} = nothing,
)

# convert to absolute path
_target_dir = abspath(target_dir)

# check if the dir contains src, index.heta, platform.json
#isdir("$_target_dir/src") && throw("src directory not found in $_target_dir")
#!isfile("$_target_dir/index.heta") && throw("index.heta file not found in $_target_dir")
#!isfile("$_target_dir/platform.json") && throw("platform.json file not found in $_target_dir")

# cmd options supported by heta-compiler
options_array = String[]

declaration != "platform" && push!(options_array, "--declaration", declaration)
skip_export && push!(options_array, "--skip-export")
units_check && push!(options_array, "--units-check")
log_mode != "error" && push!(options_array, "--log-mode", log_mode)
debug && push!(options_array, "--debug")
julia_only && push!(options_array, "--julia-only")
dist_dir != "dist" && push!(options_array, "--dist-dir", dist_dir)
meta_dir != "meta" && push!(options_array, "--meta-dir", meta_dir)
source != "index.heta" && push!(options_array, "--source", source)
type != "heta" && push!(options_array, "--type", type)
push!(options_array, "--skip-updates")

!isnothing(export_) && push!(options_array, "--export", export_)

run_build = run(ignorestatus(`$heta_exe_path build $options_array $_target_dir`))

Expand Down
2 changes: 0 additions & 2 deletions test/examples/single_comp_events/index.heta
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ include ./qsp-units.heta
// include model.heta

include one-compartment.heta

// #export { format: DBSolve, filepath: dbsolve_in_vitro };
2 changes: 0 additions & 2 deletions test/examples/single_comp_events/one-compartment.heta
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,3 @@ switch [sw]= 1;

sw_end @TimeSwitcher { start: time_end, active: false };
switch [sw_end]= 0;

// #export { format: SBML, filepath: sbml_output };

0 comments on commit cc3f424

Please sign in to comment.