Skip to content

Commit

Permalink
fix DataServiceModel and add test (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshday authored Jul 17, 2023
1 parent a97e389 commit df4909a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/SimulationService.jl
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,11 @@ Base.@kwdef mutable struct DataServiceModel
execution_payload::Config = Config() # untouched JSON from request sent by HMI
workflow_id::String = "IGNORED" # (ignore)
# Optional
description::String = "" # (ignore)
timestamp::Union{Nothing, DateTime} = nothing # (ignore?)
name::Union{Nothing, String} = nothing # (ignore)
description::Union{Nothing, String} = nothing # (ignore)
timestamp::Union{Nothing, DateTime} = nothing # (ignore?)
result_files::Union{Nothing, Vector{String}} = nothing # URLs of result files in S3
status::Union{Nothing, String} = "queued" # queued|running|complete|error|cancelled|failed"
status::Union{Nothing, String} = "queued" # queued|running|complete|error|cancelled|failed"
reason::Union{Nothing, String} = nothing # why simulation failed (returned junk results)
start_time::Union{Nothing, DateTime} = nothing # when job started
completed_time::Union{Nothing, DateTime} = nothing # when job completed
Expand Down
32 changes: 32 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,38 @@ end

#-----------------------------------------------------------# DataServiceModel and OperationRequest
@testset "DataServiceModel and OperationRequest" begin
@testset "DataServiceModel" begin
example = """{
"id": "sciml-dfca06dd-b044-436f-a744-0d0a30cc130f",
"name": null,
"description": null,
"timestamp": "2023-07-16T21:00:47",
"engine": "sciml",
"type": "simulation",
"status": "queued",
"execution_payload": {
"engine": "sciml",
"model_config_id": "84d0b51d-7d4c-497f-98fa-a00e31c344db",
"timespan": {
"start": 1,
"end": 100
},
"num_samples": null,
"extra": {},
"interventions": null
},
"start_time": null,
"completed_time": null,
"workflow_id": "dummy",
"user_id": 0,
"project_id": 0,
"result_files": []
}"""
@test JSON3.read(example, DataServiceModel) isa DataServiceModel

end


m = DataServiceModel()
@test m.engine == "sciml"
@test m.id == ""
Expand Down

0 comments on commit df4909a

Please sign in to comment.