Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message for failing to create model in model-equation endpoint #173

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/SimulationService.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function start!(; host=HOST[], port=PORT[], kw...)
Oxygen.resetstate()


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

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

# GET /model-equation/{id}
function modelEquation(::HTTP.Request, id::String)
function model_equation(::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)
])
try
sys = amr_get(model_json, ODESystem)

model_latex = latexify(sys)
catch ex
error_string = sprint(showerror,ex)
return HTTP.Response(500, "/model-equation failure. Server error: $error_string")
end
return Dict([(:latex, model_latex.s)])
end


Expand Down
14 changes: 7 additions & 7 deletions src/operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
# Get `ModelingToolkit.ODESystem` from AMR

function amr_get(amr::JSON3.Object,::Type{ODESystem})
schema_url = amr.header.schema
if contains(schema_url,"petrinet_schema")
schema_url = amr.header.schema
if contains(schema_url,"petrinet_schema")
return amr_get_petrinet(amr)
elseif contains(schema_url, "stockflow_schema")
return amr_get_stockflow(amr)
elseif contains(schema_url,"regnet_schema")
return amr_get_regnet(amr)
end
elseif contains(schema_url, "stockflow_schema")
return amr_get_stockflow(amr)
elseif contains(schema_url,"regnet_schema")
return amr_get_regnet(amr)
end
end

function amr_get_stockflow(amr::JSON3.Object)
Expand Down
Loading