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 all 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
20 changes: 11 additions & 9 deletions src/SimulationService.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ 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.@post "/model-equation" modelToEquation
Oxygen.@get "/model-equation/{id}" model_equation

Oxygen.@get "/health" health
Oxygen.@get "/status/{id}" job_status
Expand Down Expand Up @@ -220,17 +218,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

# POST /model-equation
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