Skip to content

Commit

Permalink
Switch to JSON3
Browse files Browse the repository at this point in the history
  • Loading branch information
fivegrant committed Oct 25, 2023
1 parent 0ea07d0 commit 10792a5
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion contexts/codesets/dataset/julia-1.9/df_info.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ for _var_sym in _var_syms
end
end

JSON.json(_result) |> DisplayAs.unlimited
JSON3.write(_result) |> DisplayAs.unlimited
10 changes: 5 additions & 5 deletions contexts/codesets/dataset/julia-1.9/df_save_as.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Dates

_parent_url = "{{dataservice_url}}/datasets/{{parent_dataset_id}}"
_response = HTTP.get(_parent_url)
_parent_dataset = JSON.parse(String(_response.body))
_parent_dataset = JSON3.read(String(_response.body))

if isempty(_parent_dataset)
error("Unable to locate parent dataset '{{ parent_dataset_id }}'")
Expand All @@ -14,13 +14,13 @@ _new_dataset["name"] = "{{ new_name }}"
_new_dataset["description"] *= "\nTransformed from dataset '$(_parent_dataset["name"])' ($(_parent_dataset["id"])) at $(Dates.format(Dates.now(), "c U"))"
_new_dataset["file_names"] = ["{{ filename }}"]

_create_req = HTTP.post("{{ dataservice_url }}/datasets", body=JSON.json(_new_dataset))
_new_dataset_id = JSON.parse(String(_create_req.body))["id"]
_create_req = HTTP.post("{{ dataservice_url }}/datasets", body=JSON3.write(_new_dataset))
_new_dataset_id = JSON3.read(String(_create_req.body))["id"]

_new_dataset["id"] = _new_dataset_id
_new_dataset_url = "{{ dataservice_url }}/datasets/$(_new_dataset_id)"
_data_url_req = HTTP.get("$(_new_dataset_url)/upload-url?filename={{ filename }}")
_data_url = get!(JSON.parse(String(_data_url_req.body)), "url", nothing)
_data_url = get!(JSON3.read(String(_data_url_req.body)), "url", nothing)

_temp_csv_file = tempname()
CSV.write(_temp_csv_file, {{ var_name|default("df") }}, writeheader=true)
Expand All @@ -35,4 +35,4 @@ end
rm(_temp_csv_file)

_result = Dict("dataset_id" => _new_dataset_id)
JSON.json(_result) |> DisplayAs.unlimited
JSON3.write(_result) |> DisplayAs.unlimited
2 changes: 1 addition & 1 deletion contexts/codesets/dataset/julia-1.9/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Julia",
"libraries": "DataFrames, CSV, HTTP, JSON",
"libraries": "DataFrames, CSV, HTTP, JSON3",
"df_lib_name": "DataFrames.jl"
}
2 changes: 1 addition & 1 deletion contexts/codesets/dataset/julia-1.9/setup.jl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
using DataFrames, CSV, HTTP, JSON, DisplayAs
using DataFrames, CSV, HTTP, JSON3, DisplayAs
12 changes: 7 additions & 5 deletions contexts/codesets/decapodes/julia-1.9/load_model.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using ACSets, Decapodes
import HTTP, JSON, DisplayAs
_decapode = JSON.parse(String(HTTP.get("{{ model_url }}").body))["model"]
{{ var_name|default("model") }} = parse_json_acset(SummationDecapode{String, String, String}, _decapode)
Dict(["var_name" => "{{ var_name|default("model") }}"]) |> DisplayAs.unlimited # TODO: Fix 'Unable to parse result' false error
using ACSets, Decapodes, SyntacticModels
import HTTP, JSON3, DisplayAs
# _decapode = JSON.parse(String(HTTP.get("{{ model_url }}").body))["model"]
# {{ var_name|default("model") }} = parse_json_acset(SummationDecapode{String, String, String}, _decapode)
# Dict(["var_name" => "{{ var_name|default("model") }}"]) |> DisplayAs.unlimited # TODO: Fix 'Unable to parse result' false error
_amr = HTTP.get("{{ model_url }}").body |> JSON.parse String
{{ var_name|default("model") }} = _amr |> Decapodes.SummationDecapode SyntacticModels.AMR.amr_to_expr
2 changes: 1 addition & 1 deletion environments/julia/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.9.3"
manifest_format = "2.0"
project_hash = "6d26bb7ca92e6d4cc1859ec2c6b30bee8fe80cbb"
project_hash = "4a9d3126724719cfa1d6b792afd903642ede525b"

[[deps.ACSets]]
deps = ["CompTime", "JSON", "MLStyle", "OrderedCollections", "Pkg", "PrettyTables", "Reexport", "StaticArrays", "StructEquality", "Tables"]
Expand Down
1 change: 1 addition & 0 deletions environments/julia/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
SyntacticModels = "22bb929c-8bcf-4852-b455-eb3e1675e09c"
XLSX = "fdbf4ff8-1666-58a4-91e7-1b58723a45e0"

0 comments on commit 10792a5

Please sign in to comment.