mirror of
https://github.com/ANL-CEEESA/RELOG.git
synced 2025-12-06 15:48:51 -06:00
Validate input files against schema
This commit is contained in:
@@ -96,6 +96,18 @@ git-tree-sha1 = "f80ea86cb88db337a1906e245e495592f0b5cc25"
|
|||||||
uuid = "0ef565a4-170c-5f04-8de2-149903a85f3d"
|
uuid = "0ef565a4-170c-5f04-8de2-149903a85f3d"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
|
||||||
|
[[HTTP]]
|
||||||
|
deps = ["Base64", "Dates", "IniFile", "MbedTLS", "Sockets"]
|
||||||
|
git-tree-sha1 = "5c49dab19938b119fe204fd7d7e8e174f4e9c68b"
|
||||||
|
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
|
||||||
|
version = "0.8.8"
|
||||||
|
|
||||||
|
[[IniFile]]
|
||||||
|
deps = ["Test"]
|
||||||
|
git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8"
|
||||||
|
uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f"
|
||||||
|
version = "0.5.0"
|
||||||
|
|
||||||
[[InteractiveUtils]]
|
[[InteractiveUtils]]
|
||||||
deps = ["Markdown"]
|
deps = ["Markdown"]
|
||||||
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
|
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
|
||||||
@@ -106,6 +118,12 @@ git-tree-sha1 = "b34d7cef7b337321e97d22242c3c2b91f476748e"
|
|||||||
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
|
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
|
||||||
version = "0.21.0"
|
version = "0.21.0"
|
||||||
|
|
||||||
|
[[JSONSchema]]
|
||||||
|
deps = ["BinaryProvider", "HTTP", "JSON"]
|
||||||
|
git-tree-sha1 = "b0a7f9328967df5213691d318a03cf70ea8c76b1"
|
||||||
|
uuid = "7d188eb4-7ad8-530c-ae41-71a32a6d4692"
|
||||||
|
version = "0.2.0"
|
||||||
|
|
||||||
[[JuMP]]
|
[[JuMP]]
|
||||||
deps = ["Calculus", "DataStructures", "ForwardDiff", "LinearAlgebra", "MathOptInterface", "NaNMath", "Random", "SparseArrays", "Statistics"]
|
deps = ["Calculus", "DataStructures", "ForwardDiff", "LinearAlgebra", "MathOptInterface", "NaNMath", "Random", "SparseArrays", "Statistics"]
|
||||||
git-tree-sha1 = "ba7f96010ed290d77d5c941c32e5df107ca688a4"
|
git-tree-sha1 = "ba7f96010ed290d77d5c941c32e5df107ca688a4"
|
||||||
@@ -153,6 +171,12 @@ git-tree-sha1 = "3bf2e534e635df810e5f4b4f1a8b6de9004a0d53"
|
|||||||
uuid = "fdba3010-5040-5b88-9595-932c9decdf73"
|
uuid = "fdba3010-5040-5b88-9595-932c9decdf73"
|
||||||
version = "0.7.7"
|
version = "0.7.7"
|
||||||
|
|
||||||
|
[[MbedTLS]]
|
||||||
|
deps = ["BinaryProvider", "Dates", "Libdl", "Random", "Sockets"]
|
||||||
|
git-tree-sha1 = "85f5947b53c8cfd53ccfa3f4abae31faa22c2181"
|
||||||
|
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
|
||||||
|
version = "0.7.0"
|
||||||
|
|
||||||
[[Mmap]]
|
[[Mmap]]
|
||||||
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
|
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ version = "1.0.0"
|
|||||||
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
|
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
|
||||||
Geodesy = "0ef565a4-170c-5f04-8de2-149903a85f3d"
|
Geodesy = "0ef565a4-170c-5f04-8de2-149903a85f3d"
|
||||||
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
|
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
|
||||||
|
JSONSchema = "7d188eb4-7ad8-530c-ae41-71a32a6d4692"
|
||||||
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
|
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
|
||||||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
||||||
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (C) 2020 Argonne National Laboratory
|
# Copyright (C) 2020 Argonne National Laboratory
|
||||||
# Written by Alinson Santos Xavier <axavier@anl.gov>
|
# Written by Alinson Santos Xavier <axavier@anl.gov>
|
||||||
|
|
||||||
using Printf, JSON
|
using Printf, JSON, JSONSchema
|
||||||
import Base.getindex, Base.time
|
import Base.getindex, Base.time
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -52,7 +52,15 @@ Example
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
function readfile(path::String)::ReverseManufacturingInstance
|
function readfile(path::String)::ReverseManufacturingInstance
|
||||||
|
basedir = dirname(@__FILE__)
|
||||||
json = JSON.parsefile(path)
|
json = JSON.parsefile(path)
|
||||||
|
schema = Schema(JSON.parsefile("$basedir/schemas/input.json"))
|
||||||
|
|
||||||
|
validation_results = JSONSchema.validate(json, schema)
|
||||||
|
if validation_results !== nothing
|
||||||
|
println(validation_results)
|
||||||
|
throw("Invalid input file")
|
||||||
|
end
|
||||||
|
|
||||||
for plant_name in keys(json["plants"])
|
for plant_name in keys(json["plants"])
|
||||||
"outputs" in keys(json["plants"][plant_name]) || continue
|
"outputs" in keys(json["plants"][plant_name]) || continue
|
||||||
|
|||||||
Reference in New Issue
Block a user