Skip to content

Commit

Permalink
add route to convert petrinet/regnet/stocknflow odes to latex (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwdchang authored Feb 27, 2024
1 parent 975bb88 commit 91908b1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 1 addition & 3 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.0"
manifest_format = "2.0"
project_hash = "f3500466fcd1d59a9ad020eef74d6b5586887411"
project_hash = "819df7b0c2833641a6772ed64d7f3c032be68dcd"

[[deps.ACSets]]
deps = ["AlgebraicInterfaces", "Base64", "CompTime", "DataStructures", "JSON3", "MLStyle", "OrderedCollections", "Permutations", "Pkg", "PrettyTables", "Random", "Reexport", "SHA", "StaticArrays", "StructEquality", "Tables"]
Expand All @@ -18,7 +18,6 @@ version = "0.2.12"
XLSX = "fdbf4ff8-1666-58a4-91e7-1b58723a45e0"
nauty_jll = "55c6dc9b-343a-50ca-8ff2-b71adb3733d5"


[[deps.ADTypes]]
git-tree-sha1 = "41c37aa88889c171f1300ceac1313c06e891d245"
uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down Expand Up @@ -2086,7 +2085,6 @@ git-tree-sha1 = "c7745750b8a829bc6039b7f1f0981bcda526a946"
uuid = "2ae35dd2-176d-5d53-8349-f30d82d94d4f"
version = "0.4.19"


[[deps.Pipe]]
git-tree-sha1 = "6842804e7867b115ca9de748a0cf6b364523c16d"
uuid = "b98c9c47-44ae-5843-9183-064241ee97a0"
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
JSONSchema = "7d188eb4-7ad8-530c-ae41-71a32a6d4692"
JobSchedulers = "eeff360b-c02d-44d3-ab26-4013c616a17e"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
MathML = "abcecc63-2b08-419c-80c4-c63dca6fa478"
Expand Down
19 changes: 19 additions & 0 deletions src/SimulationService.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import Statistics
import MLStyle
import Catlab
import RegNets
using Latexify
end

export start!, stop!
Expand Down Expand Up @@ -129,6 +130,9 @@ function start!(; host=HOST[], port=PORT[], kw...)
JobSchedulers.set_scheduler(max_cpu=JobSchedulers.SCHEDULER_MAX_CPU, max_mem=0.5, update_second=0.05, max_job=5000)
Oxygen.resetstate()


Oxygen.@get "/model-equation/{id}" modelEquation

Oxygen.@get "/health" health
Oxygen.@get "/status/{id}" job_status
Oxygen.@post "/kill/{id}" job_kill
Expand Down Expand Up @@ -216,6 +220,21 @@ function job_kill(::HTTP.Request, id::String)
end
end

# GET /model-equation/{id}
function modelEquation(::HTTP.Request, id::String)
@assert ENABLE_TDS[]

tds_url = "$(TDS_URL[])/models/$id"
model_json = JSON3.read(HTTP.get(tds_url, [basic_auth_header[], json_content_header, snake_case_header]).body)
sys = amr_get(model_json, ODESystem)

model_latex = latexify(sys)
return Dict([
(:latex, model_latex.s)
])
end


#-----------------------------------------------------------------------------# health: GET /
function health(::HTTP.Request)
version_filepath = normpath(joinpath(@__FILE__,"../../.version"))
Expand Down

0 comments on commit 91908b1

Please sign in to comment.